File: tutorial-tracking-me.dox

package info (click to toggle)
visp 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 119,296 kB
  • sloc: cpp: 500,914; ansic: 52,904; xml: 22,642; python: 7,365; java: 4,247; sh: 482; makefile: 237; objc: 145
file content (103 lines) | stat: -rw-r--r-- 5,206 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**

\page tutorial-tracking-me Tutorial: Moving-edges tracking
\tableofcontents

\section tracking_me_intro Introduction

ViSP moving-edges tracker provide real-time tracking capabilities of points normal to the object contours. Such a tracker allow to track a line, an ellipse or more complex objects using model-based approaches.

All the material (source code and video) described in this tutorial is part of ViSP source code and could be downloaded using the following command:

\verbatim
$ svn export https://github.com/lagadic/visp.git/trunk/tutorial/tracking/moving-edges
\endverbatim

\section tracking_me_line Line tracking

With ViSP you can track a line using moving edges. The following example code available in tutorial-me-line-tracker.cpp shows how to use ViSP vpMeLine class to this end.

\include tutorial-me-line-tracker.cpp

The video shows the result of the tracking:

\htmlonly
<iframe width="560" height="315" src="https://www.youtube.com/embed/uQspOFH-W6Y" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
\endhtmlonly

Here after we explain line by line the program.

Images that are processed could be acquired from a firewire camera on Unix or Windows, of from an usb camera under Unix. That is allowed by including the grabber headers.

\snippet tutorial-me-line-tracker.cpp camera headers

To display these images we then include the headers of the viewers.

\snippet tutorial-me-line-tracker.cpp display headers

The Graphical Display Interface (GDI) allows to display images under Windows, while X11 allows this feature under unix-like systems.

Finally, to track a line with the moving edges, we include the header of the vpMeLine class.

\snippet tutorial-me-line-tracker.cpp me line headers

In the main() function, The source code is build only if one of the grabbers is available.

\snippet tutorial-me-line-tracker.cpp me line headers

Here we create a gray level image container \c I that will contain the images acquired by our camera.

\snippet tutorial-me-line-tracker.cpp image container

Then, we create a grabber instance, first for a firewire camera under Unix if libdc1394 3rd party is installed,
secondly for a firewire camera under Windows if CMU1394 3rd party is installed, next for an usb camera
under Unix if none of the previous 3rd party are installed and if libv4l is installed, and finally with OpenCV.
The \ref tutorial-grabber gives more details concerning the framegrabbing.

\snippet tutorial-me-line-tracker.cpp grabber container

We then open the connection with the grabber and acquire an image in \c I.
\snippet tutorial-me-line-tracker.cpp first image acquisition

To be able to display image \c I and the tracking results in overlay in a window, we create a display instance.
\snippet tutorial-me-line-tracker.cpp display container

Then we display the image in the window created previously.
\snippet tutorial-me-line-tracker.cpp display image

We then initialize the moving edges parameters used later by the tracker. From the previous position of a moving
edge, we are tracking its new position along the normal of the contour with a range of 25 pixels. For each pixel
along the normal we will compute the oriented convolution. The pixel that will be selected by the moving edges
algorithm will be the one that has a convolution higher than 15000. Between two consecutive moving edges on the
contour we keep a space of 10 pixels.
\snippet tutorial-me-line-tracker.cpp me container

We then, create an instance of the vpMeTracker class that will track our line.
We initialize the tracker with the previous moving-egdes parameters. We allow also the tracker to display additional information on the viewer overlay. The user has than to initialize the tracker on image \c I by clicking on two points located on the line to track.
\snippet tutorial-me-line-tracker.cpp me line container

Once the tracker is initialized, we enter in a while loop where we successively acquire a new image, display it, track the line, display the tracking results and finally flush the overlay drawings in the viewer.
\snippet tutorial-me-line-tracker.cpp loop

\section tracking_me_ellipse Ellipse tracking

With ViSP you can also track an ellipse using moving edges. The following example code available in tutorial-me-ellipse-tracker.cpp shows how to use ViSP vpMeEllipse class to this end.

\include tutorial-me-ellipse-tracker.cpp

The video shows the result of the tracking:

\htmlonly
<iframe width="560" height="315" src="https://www.youtube.com/embed/IK-VgFyK_Tc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
\endhtmlonly

This example is very similar to the one presented in \ref tracking_me_line. It differs only in the name of the class and its header that is used to allow ellipse tracking:

\snippet tutorial-me-ellipse-tracker.cpp me ellipse container

Note here that the user has to initialize the tracker on image \c I by clicking on five points located on the ellipse to track.

\section tracking_me_next Next tutorial
You are now ready to see the next \ref tutorial-tracking-mb-generic.

*/