使用ViSP,您可以使用vpDot或vpDot2类跟踪blob。

#include <visp/vp1394CMUGrabber.h>
#include <visp/vp1394TwoGrabber.h>
#include <visp/vpDisplayGDI.h>
#include <visp/vpDisplayX.h>
#include <visp/vpDot2.h>
int main()
{#if (defined(VISP_HAVE_DC1394_2) || defined(VISP_HAVE_CMU1394))try {vpImage<unsigned char> I; // Create a gray level image container
#if defined(VISP_HAVE_DC1394_2)vp1394TwoGrabber g(false);
#elif defined(VISP_HAVE_CMU1394)vp1394CMUGrabber g;
#endifg.open(I);g.acquire(I);
#if defined(VISP_HAVE_X11)vpDisplayX d(I, 0, 0, "Camera view");
#elif defined(VISP_HAVE_GDI)vpDisplayGDI d(I, 0, 0, "Camera view");
#elsestd::cout << "No image viewer is available..." << std::endl;
#endifvpDisplay::display(I);vpDisplay::flush(I);vpDot2 blob;blob.setGraphics(true);blob.setGraphicsThickness(2);blob.initTracking(I);while(1) {g.acquire(I); // Acquire an imagevpDisplay::display(I);blob.track(I);vpDisplay::flush(I);if (vpDisplay::getClick(I, false))break;}}catch(vpException e) {std::cout << "Catch an exception: " << e << std::endl;}
#endif
}

首先创建blob跟踪器的一个实例。

vpDot2 d;

然后,我们正在修改一些默认设置,以允许图形覆盖轮廓像素和重心位置,厚度为2像素。

blob.setGraphics(true);
blob.setGraphicsThickness(2);

然后,我们等待用户初始化在blob中抛出鼠标单击事件进行跟踪。

blob.initTracking(I);

跟踪器现在已初始化。可以对新图像执行跟踪:

blob.track(I);

blob自动检测与跟踪

下面的示例演示如何在第一个图像中检测斑点,然后跟踪所有检测到的斑点。此功能仅适用于vpDot2类。

#include <visp/vpDisplayGDI.h>
#include <visp/vpDisplayX.h>
#include <visp/vpDot2.h>
#include <visp/vpImageIo.h>
int main()
{try {bool learn = false;vpImage<unsigned char> I; // Create a gray level image containervpImageIo::read(I, "./target.pgm");
#if defined(VISP_HAVE_X11)vpDisplayX d(I, 0, 0, "Camera view");
#elif defined(VISP_HAVE_GDI)vpDisplayGDI d(I, 0, 0, "Camera view");
#elsestd::cout << "No image viewer is available..." << std::endl;
#endifvpDisplay::display(I);vpDisplay::flush(I);vpDot2 blob;if (learn) {// Learn the characteristics of the blob to auto detectblob.setGraphics(true);blob.setGraphicsThickness(1);blob.initTracking(I);blob.track(I);std::cout << "Blob characteristics: " << std::endl;std::cout << " width : " << blob.getWidth() << std::endl;std::cout << " height: " << blob.getHeight() << std::endl;
#if VISP_VERSION_INT > VP_VERSION_INT(2,7,0)std::cout << " area: " << blob.getArea() << std::endl;
#endifstd::cout << " gray level min: " << blob.getGrayLevelMin() << std::endl;std::cout << " gray level max: " << blob.getGrayLevelMax() << std::endl;std::cout << " grayLevelPrecision: " << blob.getGrayLevelPrecision() << std::endl;std::cout << " sizePrecision: " << blob.getSizePrecision() << std::endl;std::cout << " ellipsoidShapePrecision: " << blob.getEllipsoidShapePrecision() << std::endl;}else {// Set blob characteristics for the auto detectionblob.setWidth(50);blob.setHeight(50);
#if VISP_VERSION_INT > VP_VERSION_INT(2,7,0)blob.setArea(1700);
#endifblob.setGrayLevelMin(0);blob.setGrayLevelMax(30);blob.setGrayLevelPrecision(0.8);blob.setSizePrecision(0.65);blob.setEllipsoidShapePrecision(0.65);}std::list<vpDot2> blob_list;blob.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), blob_list);if (learn) {// The blob that is tracked by initTracking() is not in the list of auto detected blobs// We add it:blob_list.push_back(blob);}std::cout << "Number of auto detected blob: " << blob_list.size() << std::endl;std::cout << "A click to exit..." << std::endl;while(1) {vpDisplay::display(I);for(std::list<vpDot2>::iterator it=blob_list.begin(); it != blob_list.end(); ++it) {(*it).setGraphics(true);(*it).setGraphicsThickness(3);(*it).track(I);}vpDisplay::flush(I);if (vpDisplay::getClick(I, false))break;vpTime::wait(40);}}catch(vpException e) {std::cout << "Catch an exception: " << e << std::endl;}
}

以下是对源码的详细说明:
首先,我们创建一个跟踪器实例。

vpDot2 blob;

然后,处理了两个实例。当learn设置为true时,第一种情况是学习blob特性。用户必须单击用作参考blob的blob。大小、面积、灰度最小值和最大值以及一些精度参数将用于搜索整个图像中的相似blob。

f (learn) {// Learn the characteristics of the blob to auto detectblob.setGraphics(true);blob.setGraphicsThickness(1);blob.initTracking(I);blob.track(I);std::cout << "Blob characteristics: " << std::endl;std::cout << " width : " << blob.getWidth() << std::endl;std::cout << " height: " << blob.getHeight() << std::endl;std::cout << " area: " << blob.getArea() << std::endl;std::cout << " gray level min: " << blob.getGrayLevelMin() << std::endl;std::cout << " gray level max: " << blob.getGrayLevelMax() << std::endl;std::cout << " grayLevelPrecision: " << blob.getGrayLevelPrecision() << std::endl;std::cout << " sizePrecision: " << blob.getSizePrecision() << std::endl;std::cout << " ellipsoidShapePrecision: " << blob.getEllipsoidShapePrecision() << std::endl;
}

如果您对要搜索的blob的尺寸有精确的了解,则第二种情况是直接设置参考特征。

else {// Set blob characteristics for the auto detectionblob.setWidth(50);blob.setHeight(50);blob.setArea(1700);blob.setGrayLevelMin(0);blob.setGrayLevelMax(30);blob.setGrayLevelPrecision(0.8);blob.setSizePrecision(0.65);blob.setEllipsoidShapePrecision(0.65);
}

已知blob特征后,只需通过以下方法搜索图像中的类似斑点:

std::list<vpDot2> blob_list;
blob.searchDotsInArea(I, 0, 0, I.getWidth(), I.getHeight(), auto_detected_blob_list);

此处blob_list包含图像I中检测到的blob列表。启用学习时,跟踪的blob不在自动检测到的blob列表中。我们将其添加到列表的末尾:

if (learn) {// The blob that is tracked by initTracking() is not in the list of auto detected blobs// We add it:blob_list.push_back(blob);
}

最后,当新图像可用时,我们将跟踪所有blob:

for(std::list<vpDot2>::iterator it=blob_list.begin(); it != blob_list.end(); ++it) {(*it).setGraphics(true);(*it).setGraphicsThickness(3);(*it).track(I);
}

视觉伺服控制工具Visual Servoing Platform---VISP(4)----目标检测与跟踪相关推荐

  1. 视觉伺服控制工具Visual Servoing Platform---VISP(7)----vpServo这个看懂了就会用VISP了,很简单

    看好了,基本上我们实现真实的机械臂控制的所有方法需要用到的类都可以在这个博客中找到. 这个类是整个VISP的核心部分了,因为其他的部分可以用现有的所有算法替换,但是这个vpServo和另一个姿态估计类 ...

  2. 视觉伺服控制工具Visual Servoing Platform---VISP(6)----基于4个平面点的姿态估计

    本教程重点介绍平面或非平面点的姿势估计.从它们在图像平面中的二维坐标以及在对象坐标系中指定的相应三维坐标,ViSP能够估计相机和对象坐标系之间的相对姿势.此姿势作为齐次矩阵cMo返回.请注意,要估计姿 ...

  3. 视觉伺服控制工具Visual Servoing Platform---VISP(2)----使用ViSP滤波图像。

    在本教程中,您将学习如何使用vpImageFilter类中实现的ViSP过滤函数. #include <visp/vpDisplayD3D.h> #include <visp/vpD ...

  4. 视觉伺服控制完整解析

    视觉伺服控制完整解析 视觉伺服控制简介 相关符号及概念的说明 坐标变换 刚体运动 相机模型 视觉伺服控制理论 基于位置的视觉伺服控制 基于图像的视觉伺服控制 参考文献 视觉伺服控制简介 视觉伺服控制( ...

  5. 基于视觉的目标检测与跟踪

    运动目标的检测和跟踪主要用于获取运动目标的位置.姿态.轨迹等基本运动信息,是理解服务对象或对目标进行控制的前提和基础. 目标检测可看作是目标跟踪的组成部分 , 主要用于对目标状态的初始化 , 目标跟踪 ...

  6. 机器人视觉分析算法_机器视觉处理:目标检测和跟踪

    得益于人工智能,机器学习和计算机视觉等融合技术的进步,机器人每天都能看到,分析和做出更像人类的决策.开发此类视觉分析逻辑涉及实现解决方案,这些解决方案可以确定对象的方向,处理移动的对象并执行导航.为此 ...

  7. 实验日志一:Sawyer Robot IBVS Using Visp and Visp_ros(sawyer 机器人视觉伺服)

    写在开头 从8月份开始接触准备机器人实物实验,使用sawyer机器人以及realsense D435i相机,采用IBVS及eye-in-hand,第一次接触visp以及c++程序,记录一下实验过程以及 ...

  8. Visp_ros学习笔记(二):在Gazebo环境下实现Pionner3dx移动机器人视觉伺服仿真

    开发环境:Unbuntu 18.04 LTS + ROS Melodic + ViSP 3.3.1   本文主要介绍了如何实现Pionner3dx移动机器人视觉伺服仿真,仿真环境是ROS+Gazebo ...

  9. matlab相机标定_【显微视界】基于视觉伺服的工业机器人系统研究(摄像机标定、手眼标定、目标单目定位)...

    今日光电        有人说,20世纪是电的世纪,21世纪是光的世纪:知光解电,再小的个体都可以被赋能.欢迎来到今日光电! ----与智者为伍 为创新赋能---- 标定技术 常见的机器人视觉伺服中要 ...

最新文章

  1. 《人类简史》八、融合统一(下)——宗教的法则、历史的混沌
  2. 使用QUIC协议实现实时视频直播0卡顿
  3. java利用intellij进行类型推断
  4. mysql批量插入数据的函数和存储过程
  5. java jar 没有主清单属性_Spring Boot jar中没有主清单属性的解决方法
  6. How to get Intellisense for Web.config and App.config in Visual Studio .NET?(转载)
  7. 用JS写的无缝滚动特效
  8. Bootstrap3 滚动监听插件的调用方式
  9. mysqlbackup 重建带有gtid特性的slave
  10. 穿越障碍物JAVA编程_JAVA 基础编程练习题1 【程序 1 不死神兔】
  11. springboot+poi导出excel
  12. 2020-10-28网络安全之网络安全产品
  13. mac charles4.0.2免费破解版安装
  14. 浪涌特性及保护电路Surgc Stop
  15. MD5简介与代码实现
  16. Mysql中查找附近人的查询语句
  17. html 水平、垂直 菜单栏
  18. 腾讯金融云mysql,腾讯云金融级云数据库优势与功能介绍
  19. 多年后再回头看那海市蜃楼
  20. vue渲染大量数据优化_vue大数据表格卡顿问题的完美解决方案

热门文章

  1. 学习工具使用 Markdown语法讲解
  2. c#学习—JSON文件及解析
  3. flex布局(详解)
  4. 31个Python实战项目教你掌握图像处理,PDF开放下载
  5. C语言 - qsort函数详解
  6. Macbook Pro 201 装Win10 声卡_飞利浦256P1FR显示器一线直连MacBook使用体验分享
  7. 开机后,桌面上没图标,开始菜单,只有壁纸
  8. Conditional Channel Gated Networks for Task-Aware Continual Learning 笔记
  9. 蓝牙资讯|苹果AirPods Pro充电盒将换用USB-C接口,还有新功能在测试
  10. 81条不为大多人了解却十分好用的小窍门