Project--3D Rigid Object Tracking -------终结篇

终于到了说再见的时候了,说实话从最开始对这个工程的满脸懵的状态到现在能弄出个像样的3D Rigid Object Tracking出来,感觉自己学到很多高大上的东西(opencv,图像处理算法,android等)。最深的体会有两点:
1,网上的代码到自己手里并不是那么容易跑出效果来的,你需要配置很多的环境,必须具备一定的基础知识才能找到错误所在,还要有坚强的意志不停的调试。
2,团结力量大!非常谢谢我的队友们,特别要谢谢老师给我们提供参考的代码,谢谢师兄的帮忙!

Team & Project

课程名称: 图像分析与理解
项目名称: 3D Rigid Object Tracking
HeadLine: 6/17/2016
队员姓名:杨梅,许佳琪,罗音
华中科技大学 电子信息与通信学院

Introduction

The objective of 3D rigid object tracking is to associate 3D target objects in consecutive video frames and meanwhile estimate the relative pose (3D translation and 3D rotation) between the 3D targetand the camera. Rigid means the relative position among object components do not change. For instance, a cup, a book and a car are rigid object while a human face and a cat are non-rigid object. It has a variety of uses, some of which are: humancomputer interaction, security and surveillance, video communication and compression, augmented reality, traffic control, medical imaging and video editing.3D object tracking can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations the tracking system usually employs a motion model whichdescribes how the image of the target might change for different possible motions of the object.

Progress

一 环境

我们用到的环境是:
系统:win8
软件平台:vs2012+ opencv3.1.0

二 项目介绍:

这个工程是 opencv3.1.0里自带的例子,放在 samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/ 。该项目主要由2部分组成:Model registration和 Model detection,即目标的注册和追踪。
(1)Model registration:流程图如下:
test

也就是说如果我们在第一个模块输入的原图是下面这些:
test
test
test
他们的3D mesh 的ply文件分别是:(ply文件主要是人工标注立方体的8个顶点的坐标,这8个坐标是根据实实在在的物体的长宽高比例确定的)
test
test
test
那么运行Model registration会得到下面的结果,并产生对应的myl格式的文件作为下一个模块(Model detection)的输入。
test
test
test
说明一下:之所以选上面3副图像是因为魔方是正方体,但特征点不是很多;而墨水属于长方体,而且特征丰富;而杯子是不规则图形。

(2)Model detection:流程图如下:
test
More info: Real Time pose estimation of a textured object

Demo:

最终运行的结果如下:


可以看出该算法的帧率大概是8fps,但追踪的还是很正确的。

总结

总结几点要注意的地方:
(1)如何保证代码能顺利的跑起来,这是第一步。最开始我直接在vs2012上新建一个c++解决方案,配置好opencv环境,新建项目后将opencv里面OpenCV\sources\samples\cpp\tutorial_code\calib3d的real_time_pose_estimation源代码加进来,能够编译通过,运行的时候第一个register项目运行到将八个点标完之后,程序跑死,第二个detect项目完全跑不起来,没找到原因。由于opencv教程里讲的是直接运行编译好的opencv库里面的.exe文件,而我们所下的opencv3.1里面的bin文件夹下并没有所需要的两个.exe文件,所以决定重新编译一次opencv源代码库。按照网上教程Windows下利用CMake和VS2013编译OpenCV 利用cmake和opencv3.1下的sources源代码来产生所需vs版本下的opencv解决方案,我所用的是vs2012,然后打开解决方案编译即可。直接编译opencv出来的解决方案里面还是没有我所需要的两个项目,然后查看sources文件夹的CMakeLists.txt发现“OCV_OPTION(BUILD_EXAMPLES “Build all examples” OFF )”,将OFF改为ON后重新用cmake产生解决方案,然后打开,发现opencv解决方案下有了我们所需的两个项目register和detect,运行register发现运行到waitkey(0)处输入按键无反应,一直等待在那里,将其参数改为其他任何参数都可运行,不知道原因。至此两个程序都可以正常运行了。
(2)如何保证刚追踪第一帧时准确匹配,这是跟踪成功的第一步。跑代码时我们发现模块 registration中用来注册目标的图片和模块 detection的输入视频的起始帧不一致,所以导致跟踪一开始就不成功,于是我们把视频的第一帧保存为模块一的输入图像,结果就成功了!
(3)ply文件的更改。随着跟踪目标的形状不一致,8个顶点的对应坐标要自己手动敲进去(顶点的标记要和定义的坐标点的顺序一致)。
(4)用程序跑自己拍的视频时,发现会出现视频旋转180度的情况,更改程序将读出的视频帧旋转180度后再处理可以解决(此时用来register的图片也要跟着旋转)。

参考代码:

More info: 我的github

References

[1]. Multiple 3D Object Tracking for Augmented Reality, In ISMAR, 2008.
[2]. https://www.ssontech.com/tutes/tuteobj.html
[3]. Manipulator and Object Tracking for In-Hand 3D Object Modeling, IN IJRR, 2011.
[4]. Robust Statistics for 3D Object Tracking, In ICRA 2006.
[5]. Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo. In IROS.

Project--3D Rigid Object Tracking -------chapter 4

这周压力很大,感觉得弄个实实在在的项目出来!所以几乎整个一周都在调项目!下午终于有点进展,很开心!(顺便说一下,今天端午节,祝杨老师节日快乐!)
今天更新了这周做的一个基于安卓开发,利用opencv库实现增强现实的小项目! 还有基于c++的ar_marker,还在调试中!
具体介绍看我的 Progress

Team & Project

课程名称: 图像分析与理解
项目名称: 3D Rigid Object Tracking
HeadLine: 6/17/2016
队员姓名:杨梅,许佳琪,罗音
华中科技大学 电子信息与通信学院

Introduction

The objective of 3D rigid object tracking is to associate 3D target objects in consecutive video frames and meanwhile estimate the relative pose (3D translation and 3D rotation) between the 3D targetand the camera. Rigid means the relative position among object components do not change. For instance, a cup, a book and a car are rigid object while a human face and a cat are non-rigid object. It has a variety of uses, some of which are: humancomputer interaction, security and surveillance, video communication and compression, augmented reality, traffic control, medical imaging and video editing.3D object tracking can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations the tracking system usually employs a motion model whichdescribes how the image of the target might change for different possible motions of the object.

Progress

一 配置基于eclipse 安卓开发环境

我们采取的方式是;Java(JDK+JRE)+Eclipse+ADT+Android SDK来搭建Android开发环境。
(1)Java(JDK+JRE):可以在Oracle官网下载 Java SE Development Kit 8u66(或者别的版本,根据自己的系统选择),我下的时候出现如下问题:
test
这时候我们可以选择在蝴蝶上下载,版本也很新(1.8.0_74)。我下的是 Newest Version of Eclipse and JDK ,很不错。
这时候我们需要给JDK配置环境变量,参考如下链接:http://blog.my-eclipse.cn/jdk-install-classpath.html
(2)Eclipse :Eclipse 官网下载2015年最新版本Mars,安装Eclipse Mars.或者从蝴蝶上下载名为 eclipse-java-mars-R-win32-x86_64的文件夹,是免安装版的。
(3)在android studio官网下载最新的android-sdk 我的系统是win7 64位,下载的是android-sdk_r24.4.1-windows。官网链接: https://developer.android.com/studio/index.html
(4)至此Eclipse和android-sdk还是分开,独立的,我们需要安装插件ADT将两者联系起来。下载最新的ADT.我下的是ADT-23.0.6。然后安装离线ADT,参考链接如下:
http://jingyan.baidu.com/article/3aed632e66858770108091bf.html
安装完后我们需要重启eclipse.重启之后我们会发现多了两个图标(SDK manager 和虚拟机),还有提示你打开sdk manager去更新我们的sdk工具,这是一个漫长的过程。可参考如下链接:http://www.zhihu.com/question/31935836 确定安装哪些tools.
至此我们就搭建了一个开发环境。这只是第一步!
More info: Android开发环境搭建:Eclipse篇

二 关于项目

先用个小Demo展示一下我们目前的成果:

这是一个小AR的app,用到的卡片如下图:
test
最开始我们是用虚拟机做测试,可是开机特别慢,终于等到开机了,可又一直提示process system is not responding。。。
test 我们点wait之后,显示如下:
test
接着就是http://zhidao.baidu.com/link?url=J0cdwb5C79TKigkQWVR1wHNEPWpRo4BwV_vO8rqVsAC2fz9FuJIrweQjgt7qMKM7-SDI6_zGqBOMmwy4W_k5EK,这样的错误。
最后好不容易没错了,有一直保持下面状态不动,而且虚拟机就没有该App:
test
可能是我的电脑太卡或者安卓本版太高(我装的是6.0)?或者别的原因,总之一直解决不了。于是我们就只能采取真机调试,步骤如下:
(1)为手机装驱动:(这也挺让我这个新手挺抓狂的)
像以前那样直接更新驱动是装不了的(D:\install_file\JAVA\android-sdk-windows\extras\google\usb_driver),会显示找不到设备的驱动文件。
花了好长时间,终于找到下面这位高手写的博客:http://blog.csdn.net/yao_guet/article/details/24106085
大概就是这样的:首先要知道自家手机的VendorID跟ProductID,然后找到android_winusb.inf文件夹,将自家手机的VendorID跟ProductID添加进去。如图:
test
然后找到adb_usb.ini文件,在里面编辑你手机的ID,我的如下:
test
到此,驱动就装好了。
(2)在SDK manager 里下载对应手机的安卓版本的工具(我的手机是4.4.2),如下图:
test
然后选择真机设备运行.
(3)在手机上安装opencv sdk manager:运行成功之后手机上会提示你安装opencv sdk manager,这时候你需要百度你手机对应的cpu架构,然后在该文件夹(E:\Java_project\OpenCV-android-sdk\apk)
找到对应的apk安装到手机即可,最后我的手机如图:
test

注:为了最终做出能够在手机上看AR的一个APP效果,我们先用了一个测试项目————helloandroid,效果如下:
test
写起来感觉很简单,可做的时候由于刚开始什么都不懂,身边也没有懂这方面的朋友,于是都得靠自己摸索,真的遇到很多困难,好几天都感觉没有任何进展。
当看到自己的测试项目能在手机上成为个app,并且打印出了东西,我和我的小伙伴真的不知道有多高兴,多自豪!
虽然感觉不属于追踪,但能找到marker,并且加上虚拟物品还算行吧.

Next Plan

尽力做出3D-Rigid-Object-Tracking!
(上周问老师的问题还没去解决,主要是发现我的vs是2013,然后没有对应的openframeworks,
然后那个opencv里的关于2d-3d的函数还不知道怎么用,不是这个方向的得摸索一段时间。)

参考代码:

见little-AR.zip,要用到的卡片是ARmarkers.pdf。主要是关于AR的。可以运行!
More info: 我的github

References

[1]. Multiple 3D Object Tracking for Augmented Reality, In ISMAR, 2008.
[2]. https://www.ssontech.com/tutes/tuteobj.html
[3]. Manipulator and Object Tracking for In-Hand 3D Object Modeling, IN IJRR, 2011.
[4]. Robust Statistics for 3D Object Tracking, In ICRA 2006.
[5]. Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo. In IROS.

Project--3D Rigid Object Tracking -------chapter 3

这周我们大部分时间都在找代码,想着借鉴学习一下,但发现二维的图像跟踪代码比较多,三维的特别少。总共分3个部分进行学习,大致都是关于对视频中动态目标进行追踪:
1 罗音同学主要学习Matlab相关的对视频中动态目标进行追踪;
2 许佳琪同学学了一下openCV,调试了一个相关的程序;
3 我学了一下openCV,主要找一些三维方面的对目标进行追踪的代码,想根据老师给的文献5自己试着进行实现,还有依旧负责网站更新;
具体介绍看我的 Progress

Team & Project

课程名称: 图像分析与理解
项目名称: 3D Rigid Object Tracking
HeadLine: 6/17/2016
队员姓名:杨梅,许佳琪,罗音
华中科技大学 电子信息与通信学院

Introduction

The objective of 3D rigid object tracking is to associate 3D target objects in consecutive video frames and meanwhile estimate the relative pose (3D translation and 3D rotation) between the 3D targetand the camera. Rigid means the relative position among object components do not change. For instance, a cup, a book and a car are rigid object while a human face and a cat are non-rigid object. It has a variety of uses, some of which are: humancomputer interaction, security and surveillance, video communication and compression, augmented reality, traffic control, medical imaging and video editing.3D object tracking can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations the tracking system usually employs a motion model whichdescribes how the image of the target might change for different possible motions of the object.

Progress

一 关于Matlab

要不是做项目应该永远都不会用到Matlab的,要不是亲自体验,还不知道功能如此强大!罗音同学发现Matlab中有一些自带的多目标追踪的实例(要求版本R13a以上):可在D:\Program Files\MATLAB\R2014a\toolbox\vision\visiondemos找到。在命令窗口中输入”edit multiObjectTracking”就可以看到multiObjectTracking的代码,我们发现MATLAB还有自带的视频播放器,为了上传我主要学习了如何将Matlab跑出来的帧序列保存成.avi格式的视频,然后上传到YouTube详见如下链接:matlab写入/合成视频VideoWriter类(http://blog.163.com/yuyang_tech/blog/static/21605008320139854818157/)
这个追踪方法达到的效果如下:


它这个系统基于一个假设:所有被探测的物体做匀速直线运动,如果不是的话可能会出现错误,概括起来如下:
The detection of moving objects uses a background subtraction algorithm based on Gaussian mixture models. Morphological operations are applied to the resulting foreground mask to eliminate noise. Finally, blob analysis detects groups of connected pixels, which are likely to correspond to moving objects.
The association of detections to the same object is based solely on motion. The motion of each track is estimated by a Kalman filter. The filter is used to predict the track’s location in each frame, and determine the likelihood of each detection being assigned to each track.

More info: Motion-Based Multiple Object Tracking

二 关于openCV

为了最终做出3D的效果,我们想利用openCV的强大的图像处理功能,做了如下工作:
(1)配置openCV:http://blog.csdn.net/huang9012/article/details/21811129
(这个链接基本上解决了今后要用openCV运行时出现的所有让人抓狂的问题)
经验:千万注意lib库的配置(否则每次新建工程都得配置一遍)
(2)例子1:用openCV实现对视频中动态目标的追踪 http://wenku.baidu.com/view/0a3d2449f7ec4afe04a1dffa.html?from=search 第一次学习建立MFC对话框,发现学起来并不容易:要注意的地方:
1.使用OpenCVS函数库,要注意包含的头文件的顺序,要先包含VS的头文件在包含OpenCV的头文件
2.CFileDialog的用法:
http://www.cnblogs.com/doublesnke/archive/2011/07/19/2110341.html
http://blog.sina.com.cn/s/blog_915fe1f201019xx2.html
3.出现如下抓狂的错误:
test
More info: [处理方法]http://www.xuebuyuan.com/997244.html
依旧用Matlab用的原视频,处理效果如下:


(3)例子2:我们写的代码,效果如下:
test
test

Next Plan

做出3D的刚体目标追踪效果

参考代码:

More info: 我的github

References

[1]. Multiple 3D Object Tracking for Augmented Reality, In ISMAR, 2008.
[2]. https://www.ssontech.com/tutes/tuteobj.html
[3]. Manipulator and Object Tracking for In-Hand 3D Object Modeling, IN IJRR, 2011.
[4]. Robust Statistics for 3D Object Tracking, In ICRA 2006.
[5]. Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo. In IROS.

3D-Rigid-Object-Tracking--chapter2

由于这周实验室比较忙,加上准备考试,所以网站更新较慢,下周把进度赶上。

Team & Project

课程名称: 图像分析与理解
项目名称: 3D Rigid Object Tracking
HeadLine: 6/17/2016
队员姓名:杨梅,许佳琪,罗音
华中科技大学 电子信息与通信学院

Introduction

The objective of 3D rigid object tracking is to associate 3D target objects in consecutive video frames and meanwhile estimate the relative pose (3D translation and 3D rotation) between the 3D targetand the camera. Rigid means the relative position among object components do not change. For instance, a cup, a book and a car are rigid object while a human face and a cat are non-rigid object. It has a variety of uses, some of which are: humancomputer interaction, security and surveillance, video communication and compression, augmented reality, traffic control, medical imaging and video editing.3D object tracking can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations the tracking system usually employs a motion model whichdescribes how the image of the target might change for different possible motions of the object.

Progress

一 阅读了老师给的4篇文献,了解了相关算法,做出归纳:

1 Multiple 3D Object Tracking for Augmented Reality
文章是实现多目标跟踪,所以就把目标检测和帧对帧跟踪结合其他,第一次出现的新物体,直接就可以帧对帧跟踪,但是之前出现过的物体就要讲检测与跟踪结合起来估计物体的状态。
test
2 Manipulator and object tracking for in-hand 3D object modeling
文章是基于机器人的,物体是拿在机器人手上的,机器人有传感器,所以一开始有一个基本的检测,然后跟踪主要是通过机器人手臂的角度移动来实现,中间提出了一种新的寻找最近点的一个方法,然后加上了一个滤波器来虑除一些遮挡,噪音之类的干扰。
test
test
3 Robust Statistics for 3D Object Tracking
文章讲的是3D object tracking的增强表现的方法,主要是对三种statistic method(原始的,M-estimator和RANSAC)和边缘检测的方法进行了评估,最后结论是改进后的基于Kirsch detector的边缘检测的方法效果最好.这里面关于算法讲得不是很详细,主要是对各种方法的评估,然后提出了一个改进的边缘检测的方法
Conclusion: The best recovery after a partial loss of track was achieved with the Kirsch-algorithm. Hence, for a 3D model based tracker, it is better to concentrate on obtaining good measurements with improved detection (Kirsch-filter) than to enhance the matching step with statistical means (Estimators, RANSAC and Histograms).
4 Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo
可用于实时处理的一个系统,根据摄像机的不同分为mono和stereo两种,里面分别给出了两种算法,如果对速度有要求的话用前面的,后面的stereo更注重精度。实现的时候用到了SIFT和一个KLT算法.
test
test
Conclusion:In this paper, a method for tracking 3D roto-translation of rigid objects using scale invariant feature based matching and Kande-Lucas-Tomasi (KLT) tracke is proposed and verified to be used in real-time processing. The method has two mode, mono mode using a mono camera and stereo mode using a stereo camera. Mono mode guarantees higher frame rate performance, and stereo mode shows better pose results.
总结:通过对四篇文献的阅读,我们觉得第一篇文献中提到的算法易于实现。

二 在网上查找了相关的算法代码

发现Matlab更适用于2D的目标追踪,对于3D的目标我们采用opencv,学起来简单点。

Next Plan

1 多参考网上的代码,实现基本的目标追踪功能。
2 学习matlab opencv (可参考范子健、李文杰、邹雨泽“组:http://120.27.106.26/project/wst.php 中给的网址 )

参考网址:

More info: Object Tracking Matlab Code
More info: How to Detect and Track Objects Using Matlab
More info: How to Detect and Track Object With OpenCV

References

[1]. Multiple 3D Object Tracking for Augmented Reality, In ISMAR, 2008.
[2]. https://www.ssontech.com/tutes/tuteobj.html
[3]. Manipulator and Object Tracking for In-Hand 3D Object Modeling, IN IJRR, 2011.
[4]. Robust Statistics for 3D Object Tracking, In ICRA 2006.
[5]. Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo. In IROS.

Project--3D Rigid Object Tracking -------chapter 1

Welcome to our website! Next is first progress about our project. If you have any problems about it,
you can ask me via my email:2207000342@qq.com

Team & Project

课程名称: 图像分析与理解
项目名称: 3D Rigid Object Tracking
HeadLine: 6/17/2016
队员姓名:杨梅,许佳琪,罗音
华中科技大学 电子信息与通信学院

Introduction

The objective of 3D rigid object tracking is to associate 3D target objects in consecutive video frames and meanwhile estimate the relative pose (3D translation and 3D rotation) between the 3D targetand the camera. Rigid means the relative position among object components do not change. For instance, a cup, a book and a car are rigid object while a human face and a cat are non-rigid object. It has a variety of uses, some of which are: humancomputer interaction, security and surveillance, video communication and compression, augmented reality, traffic control, medical imaging and video editing.3D object tracking can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations the tracking system usually employs a motion model whichdescribes how the image of the target might change for different possible motions of the object.

Progress

1 Building our teams, selected our projects and make a site for generating links
2 Understanding some basic knowledge of 3D rigid object tracking and watching the relevant video

Next Plan

1 Reading a lot of references literature
2 Understandings the basic principle of correlation algorithms
3 Determining the final implementation

Demo

Image:

test

Video:


More info: YouTube video two
More info: YouTube video three
More info: YouTube video four

References

[1]. Multiple 3D Object Tracking for Augmented Reality, In ISMAR, 2008.
[2]. https://www.ssontech.com/tutes/tuteobj.html
[3]. Manipulator and Object Tracking for In-Hand 3D Object Modeling, IN IJRR, 2011.
[4]. Robust Statistics for 3D Object Tracking, In ICRA 2006.
[5]. Real-time 3D Object Pose Estimation and Tracking for Natural Landmark Based Visual Servo. In IROS.