Move the sources to trunk
[opencv] / docs / appPage / CamShift / camshift.htm
1 <HTML>\r
2   <HEAD>\r
3     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\r
4     <META NAME="Generator" CONTENT="Microsoft Word 97">\r
5     <META NAME="Template" CONTENT="D:\WIN32APP\msoffice97\Office\html.dot">\r
6     <META NAME="GENERATOR" CONTENT="Microsoft FrontPage 4.0">\r
7     <META NAME="Author" CONTENT="Gary Bradski">\r
8     <META NAME="Description" CONTENT="Header for main functions">\r
9     <META NAME="KeyWords" CONTENT="CV.h">\r
10     <TITLE>CAMShift Demo</TITLE>\r
11     <!-- Formatted and proofed in GNU Emacs by: Michael Chu, 00.06.05 -->\r
12   </HEAD>\r
13   <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">\r
14     <A NAME="Top">\r
15       <!-- <CENTER>\r
16     <BLOCKQUOTE>\r
17     <table border = 3 WIDTH="70%" >\r
18     <TR><TD>\r
19       -->\r
20     <CENTER><TABLE CELLSPACING=0 CELLPADDING=5 WIDTH="90%" BGCOLOR="#6A9BED" NOSAVE >\r
21         <TR NOSAVE>\r
22           <TD NOSAVE>\r
23             <CENTER><I><FONT COLOR="#000000"><FONT SIZE=+4>CAMSHIFT\r
24                     DEMO</FONT></FONT></I></CENTER>\r
25 \r
26             <CENTER><I><FONT COLOR="#000000"><FONT SIZE=+4>Face and Color Tracking</FONT></FONT></I></CENTER>\r
27           </TD>\r
28         </TR>\r
29       </TABLE></CENTER>\r
30 \r
31     <H1>\r
32       <!--\r
33     </TD></TR>\r
34     </table>\r
35       </BLOCKQUOTE>\r
36     </center>\r
37       --></H1>\r
38 \r
39     <br>\r
40     <H1>\r
41       Description</H1>\r
42     This application demonstrates a fast, simple color tracking algorithm that\r
43     can be used to track faces, hands etc described in <B><A HREF="../../papers/camshift.pdf">camshift.pdf</A></B>.\r
44     The CAMSHIFT algorithm is a modification of the Meanshift algorithm which\r
45     is a robust statistical method of finding the mode (top) of a probability\r
46     distribution. Both CAMSHIFT and Meanshift algorithms exist in the library.\r
47     While it is a very fast and simple method of tracking, because CAMSHIFT\r
48     tracks the center and size of the probability distribution of an object,\r
49     it is only as good as the probability distribution that you produce for\r
50     the object. Typically the probability distribution is derived from\r
51     color via a histogram, although it could be produced from correlation,\r
52     recognition scores or bolstered by frame differencing or motion detection\r
53     schemes, or joint probabilities of different colors/motions etc.\r
54     \r
55     <br><br>\r
56     In this application, we use only the most simplistic approach:\r
57     A 1-D Hue histogram is sampled from the object in an HSV color space version\r
58     of the image. To produce the probability image to track, histogram\r
59     "back projection" (we replace image pixels by their histogram hue value)\r
60     is used. The raw video image and backprojection is shown in the following\r
61     image:<br><br>\r
62     <CENTER><IMG SRC="faceNback.png" HEIGHT=130 WIDTH=347></CENTER>\r
63 \r
64     <CENTER><B>Figure 1</B></CENTER>\r
65 \r
66     <br>\r
67     Since we use such a simple method in this application, you must tune\r
68     the parameters for your camera and the lighting in the image as described\r
69     below.\r
70     <BR><BR>\r
71     Note that this filter requires that you have DirectShow 6.0 or greater installed.\r
72     DirectShow 6.0 for NT4.0, DirectShow 7.0 for Win 98 or Win2000). \r
73     You will also need a video camera source filter which should\r
74     be supplied by your USB camera vendor. <!-- except most don't support NT4.0. -->\r
75 <!-- %%Some friendly advice from Uncle Gary?? -->\r
76 <!--    Win2000 is your best bet for development, for just running the filter graph, Win98 will do.. An example filter graph is shown below (with the calibration filter processing a video source from a Matrox Meteor II card that we wrote ourselves) and then passing the output to a video renderer. -->\r
77 \r
78     Microsoft* Windows* 2000 may be the most suitable operating system\r
79     for development since many vendors do not supply filters for\r
80     Windows NT 4.0. However, Windows 98 will be adequate for just\r
81     running the filter graph.&nbsp;\r
82       <br>\r
83     <!-- <HR WIDTH="100%"> -->\r
84     <H2>\r
85       Controls</H2>\r
86     \r
87     <CENTER><IMG SRC="csmshiftTrack_labeled.JPG" HEIGHT=319 WIDTH=381></CENTER>\r
88 \r
89     <CENTER><IMG SRC="camshiftThresh_labeled.JPG" HEIGHT=138 WIDTH=855></CENTER>\r
90 \r
91     <CENTER><B>Figure 2</B></CENTER>\r
92     \r
93     <!-- <H2>Buttons</H2> -->\r
94     <B><FONT SIZE=+2>[1]</FONT></B> Select input from USB video camera.\r
95     <BR><B><FONT SIZE=+2>[2]</FONT></B> Select input from "bouncing ball" simulation.\r
96     <BR><B><FONT SIZE=+2>[3]</FONT></B> Select input from an AVI movie file.\r
97     <BR><B><FONT SIZE=+2>[4]</FONT></B> Stop and start AVI movie file if [3]\r
98     is selected.\r
99     <BR><B><FONT SIZE=+2>[5]</FONT></B> Threshold the histogram bins to clean\r
100     noise.\r
101     <BR><B><FONT SIZE=+2>[6]</FONT></B> Select the number of histogram bins\r
102     to use in the 1-D Hue histogram.\r
103     <BR><B><FONT SIZE=+2>[7]</FONT></B> Minimum color saturation to accept\r
104     threshold on Hue pixels.\r
105     <BR><B><FONT SIZE=+2>[8]</FONT></B> Minimum brightness to accept threshold\r
106     on Hue pixels.\r
107     <BR><B><FONT SIZE=+2>[9]</FONT></B> Maximum brightness to accept threshold\r
108     on Hue pixels.\r
109     <BR><B><FONT SIZE=+2>[10]</FONT></B> View (top) Raw video; (middle) Histogram\r
110     backprojection; (bottom) Histogram bins.\r
111     <BR><B><FONT SIZE=+2>[11]</FONT></B> Select display window size -- on slower\r
112     machines, a smaller display window will run faster.\r
113     <BR>\r
114     <H2>\r
115       How to</H2>\r
116     <h3>Track a colored object (face, ball etc):</h3>\r
117     (<B>a</B>) Reset thresholds: Set Threshold [5] to zero; Saturation\r
118     [7] far left; Minimum brightness [8] far left; Maximum brightness [9] far\r
119     right.\r
120     <BR>(<B>b</B>) Click video [1], bouncing ball [2] or AVI [3] to select\r
121     your input source.\r
122     <BR>(<B>c</B>) Check the raw video display [10] button.\r
123     <BR>(<B>d</B>) Set the number of bins [6] you want in your histogram (32-100\r
124     is a good number).\r
125     <BR>(<B>e</B>) Use your mouse to draw a sample box over the colored object\r
126     that you want to track.\r
127     <h3>...Tuning...</h3>\r
128     (<B>f</B>) Check the histogram "Back Project" [10] button. You\r
129     want the object to be well segmented as in figure 1 above. To get\r
130     things well segmented, adjust things in the order described below:\r
131     <BR>(<B>g</B>) Increase (move the slider to the right) the mimimum acceptable\r
132     saturation threshold [7]. Make sure you allow a little time to see\r
133     how your adjustment is working. Often moving it about 25% of the way to\r
134     the right is sufficient.\r
135     <BR>(<B>h</B>) If (g) doesn't do the whole job, then increase the minimum\r
136     acceptable brightness threshold [8] to the right allowing enough time to\r
137     see the effect at each position. Usually 20-50% of the way to the right\r
138     works.\r
139     <h3>...not working...</h3>\r
140     (<B>i</B>) If (g) &amp; (h) do not give you a well segmented object,\r
141     you probably need to change your camera settings and/or lighting.\r
142     Histogram threshold [5] can have a marginal effect on edge regions.\r
143     Decreasing (move to the left) high brightness threshold [9] can diminish\r
144     edges and glaring white regions in the video image, usually moving it no\r
145     more than 10% of the way to the left. Setting more histogram bins\r
146     [6] sometimes helps.\r
147     <BR>\r
148     <BR>\r
149 \r
150     <hr noshade size=2 width=100%>\r
151 \r
152   </BODY>\r
153 </HTML>\r