<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-95295597041874472</id><updated>2026-10-14T12:16:45.847-07:00</updated><category term="opencv 2.2"/><category term="opencv"/><category term="camera"/><category term="SURF"/><category term="live camera"/><category term="c++"/><category term="visual studio 2010"/><category term="OOP"/><category term="Viola and jones"/><category term="cpp"/><category term="images"/><category term="video"/><category term="Affine Transform"/><category term="ROI"/><category term="haar"/><category term="load video"/><category term="logpolar transform"/><category term="4 neighbors"/><category term="How to"/><category term="K NN"/><category term="KNN"/><category term="Kalman filter"/><category term="Perspective transform"/><category term="VJ Opencv"/><category term="VS2010 Opencv"/><category term="ann"/><category term="artificial neural network"/><category term="backpropagation"/><category term="blob detection"/><category term="blob labeling"/><category term="buy beer"/><category term="canny"/><category term="center"/><category term="classifier"/><category term="code"/><category term="connected components"/><category term="cvTemplateMatch"/><category term="donate"/><category term="drawcontours"/><category term="edge detection"/><category term="entropy"/><category term="findcontours"/><category term="floodfill"/><category term="gini index"/><category term="k nearest neighbor"/><category term="livec"/><category term="loading images"/><category term="measure of impurity"/><category term="mlp"/><category term="moments"/><category term="opencv C++"/><category term="opencv internal function"/><category term="opengl"/><category term="point matching"/><category term="rectangle"/><category term="region of interest"/><category term="selecting ROI"/><category term="selection of ROI"/><category term="shannon entropy"/><category term="shapes"/><category term="support vector machine"/><category term="support vector machine (SVM)"/><category term="svm"/><category term="tracking"/><category term="trials"/><category term="video stabilization"/><title type='text'>OpenCV- Working with OpenCV</title><subtitle type='html'>Aresh T. Saharkhiz</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-1117231907127789366</id><published>2020-06-12T06:54:00.001-07:00</published><updated>2020-06-12T06:54:13.638-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="buy beer"/><category scheme="http://www.blogger.com/atom/ns#" term="donate"/><title type='text'>If you found these codes useful buy me a beer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot; target=&quot;_top&quot;&gt;
&lt;input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;_s-xclick&quot; /&gt;
&lt;input name=&quot;hosted_button_id&quot; type=&quot;hidden&quot; value=&quot;Y8KAE87HNCC88&quot; /&gt;
&lt;input alt=&quot;Donate with PayPal button&quot; border=&quot;0&quot; name=&quot;submit&quot; src=&quot;https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif&quot; title=&quot;PayPal - The safer, easier way to pay online!&quot; type=&quot;image&quot; /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;https://www.paypal.com/en_PH/i/scr/pixel.gif&quot; width=&quot;1&quot; /&gt;
&lt;/form&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 14.85px;&quot;&gt;If you found these codes useful buy me a beer&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/1117231907127789366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2020/06/if-you-found-these-codes-useful-buy-me.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/1117231907127789366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/1117231907127789366'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2020/06/if-you-found-these-codes-useful-buy-me.html' title='If you found these codes useful buy me a beer'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-2995952567190875027</id><published>2012-02-03T23:01:00.000-08:00</published><updated>2012-02-03T23:01:46.106-08:00</updated><title type='text'>Results Update Feb 4</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFiDrCmoAxlEvvts6ANAOCFFl6s8CX_iJDMW0-IMOxZggaCu6gvl9EriXsBT2X1o1WgQ_3C5sxngXZYlv3M38OqvcxG1iG8n5oZ1eGqxusjZxFaiKd7RsW7p7yr98LAMCSRKd0ah4SIWnf/s1600/result_notConvincing.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFiDrCmoAxlEvvts6ANAOCFFl6s8CX_iJDMW0-IMOxZggaCu6gvl9EriXsBT2X1o1WgQ_3C5sxngXZYlv3M38OqvcxG1iG8n5oZ1eGqxusjZxFaiKd7RsW7p7yr98LAMCSRKd0ah4SIWnf/s1600/result_notConvincing.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdyEhIyDVKFAheJzNVABQ1eWowgc3Y5L_-sjUeeEFnhJeoURvDQ6Q5OxJJyhs77jlWc2j3yaZyDboI_Yi8MI0BZXbwXZU8yjZu3HkBxk5YkvTMCllL2duiN-AW-Gc4OZI6uFN1JGBEBap8/s1600/result1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;261&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdyEhIyDVKFAheJzNVABQ1eWowgc3Y5L_-sjUeeEFnhJeoURvDQ6Q5OxJJyhs77jlWc2j3yaZyDboI_Yi8MI0BZXbwXZU8yjZu3HkBxk5YkvTMCllL2duiN-AW-Gc4OZI6uFN1JGBEBap8/s320/result1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgZEDH12walMVjsygK67_HLE3-reW4rEJzZC39685GY-4bEoTLkhgIuEL8zjui1FWaker1nburb_qRHHNjJaXPXY6I6j4IX4f9w3vagPtUY27Vc8e1e7kBENA-AksrBbKBcBIsoUluFn55/s1600/result1_Corrected.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;174&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgZEDH12walMVjsygK67_HLE3-reW4rEJzZC39685GY-4bEoTLkhgIuEL8zjui1FWaker1nburb_qRHHNjJaXPXY6I6j4IX4f9w3vagPtUY27Vc8e1e7kBENA-AksrBbKBcBIsoUluFn55/s320/result1_Corrected.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/2995952567190875027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2012/02/results-update-feb-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2995952567190875027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2995952567190875027'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2012/02/results-update-feb-4.html' title='Results Update Feb 4'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFiDrCmoAxlEvvts6ANAOCFFl6s8CX_iJDMW0-IMOxZggaCu6gvl9EriXsBT2X1o1WgQ_3C5sxngXZYlv3M38OqvcxG1iG8n5oZ1eGqxusjZxFaiKd7RsW7p7yr98LAMCSRKd0ah4SIWnf/s72-c/result_notConvincing.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-6869313102415933071</id><published>2012-01-10T04:17:00.000-08:00</published><updated>2012-01-10T04:46:12.622-08:00</updated><title type='text'>getting SURF points of any image</title><content type='html'>this post uses OPENCV 2.2 and a simple change of the extract feature will allow use on version 2.3&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;class atsSURF&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat extractPoints(cv::Mat img)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int minHessian = 500;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::SurfFeatureDetector detector(minHessian);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; std::vector&amp;lt;cv::KeyPoint&amp;gt; keypoints;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; detector.detect(img,keypoints,img); //opencv 2.2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //detector.detect(img,keypoints); //opencv 2.3&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::SurfDescriptorExtractor extractor;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat descriptor;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; extractor.compute(img,keypoints,descriptor);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; thisDescriptor = descriptor;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; thisKeypoints = keypoints;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat outim = img;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::drawKeypoints(img,keypoints,outim,Scalar::all(-1),&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::DrawMatchesFlags::DEFAULT);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return outim;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat thisDescriptor;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::vector&amp;lt;cv::KeyPoint&amp;gt; thisKeypoints; &lt;br /&gt;};&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
to run from the main function&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;char code = (char)-1;&lt;br /&gt;atsImages im(&quot;C:/Users/Aresh/Documents/Visual Studio 2010/Projects/opencvTest/Debug/test_connectedComponent_sameColor_sameShape.jpg&quot;);&lt;br /&gt;Mat img = im.read(&quot;gray&quot;);&lt;br /&gt;&lt;br /&gt;atsSURF mypoints;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;//cv::Mat ima_gray; //in case in RGB&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;//cv::cvtColor(img,ima_gray,CV_BGR2GRAY); //convert to gray scale&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;//cv::Mat outim = mypoints.extractPoints(ima_gray);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;cv::Mat outim = mypoints.extractPoints(img);&lt;br /&gt;cv::imshow(&quot;SURF points&quot;, outim);&lt;br /&gt; code = (char)waitKey();&lt;br /&gt;&amp;nbsp;return 0;&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
and thats all. dont forget the SURF descriptor only accepts GRAY level images. if you feed it a colored image, it will give you the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #ffe599; font-family: Arial,Helvetica,sans-serif;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Unhandled exception at xxxxxx in opencv.exe: Microsoft C++ exception: &lt;br /&gt;cv::Exception at memory location xxxxxxx&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/6869313102415933071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2012/01/getting-surf-points-of-any-image.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6869313102415933071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6869313102415933071'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2012/01/getting-surf-points-of-any-image.html' title='getting SURF points of any image'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-8715703763828783755</id><published>2012-01-01T02:37:00.000-08:00</published><updated>2012-01-01T02:37:25.291-08:00</updated><title type='text'>Entropy and Gini index experiments</title><content type='html'>Conclusion:&lt;br /&gt;
1. Entropy and Gini index are unique when color and shape are different&lt;br /&gt;
2. Entropy and Gini Index are unique (Small Difference) Color remains the same but different shape&lt;br /&gt;
3. Entropy and Gini Index are unique (smaller difference) Color and shape are the same Area and size&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVbunJ6qPtdZH_94xUDE_BzbkAMJ6_Pw0EGLngt6wu-mZgM6el1jHgP2wV0FaUCMOCMUOz3yjkUoZyqrWx5uLtRif6ut8SQgz16x-rq8h517r_BFnleOSrNI7niSsDwhgDBEFXaau28F-3/s1600/samecolor_sameShape.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVbunJ6qPtdZH_94xUDE_BzbkAMJ6_Pw0EGLngt6wu-mZgM6el1jHgP2wV0FaUCMOCMUOz3yjkUoZyqrWx5uLtRif6ut8SQgz16x-rq8h517r_BFnleOSrNI7niSsDwhgDBEFXaau28F-3/s400/samecolor_sameShape.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Shape and Color are the same, however entropy is unique, Gini Index is even more unique &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_eQpQrAU-1GnRIECh7mYt1x49c2vDqGVTdlWK6ZVTzWKvc9RNMsjLoO7EU83saduK0XoqJR4Arqoch1ZSJEfnAwm_MMoO3ogUGmQdxGb0-6AvJI_Piu3r34cF045h8zoW9Coe2xewxlcE/s1600/different+shapes+with+the+same+color+produce+different+entropy.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_eQpQrAU-1GnRIECh7mYt1x49c2vDqGVTdlWK6ZVTzWKvc9RNMsjLoO7EU83saduK0XoqJR4Arqoch1ZSJEfnAwm_MMoO3ogUGmQdxGb0-6AvJI_Piu3r34cF045h8zoW9Coe2xewxlcE/s400/different+shapes+with+the+same+color+produce+different+entropy.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7mgUksfgWlng9AaYJ_nyMJ6pdKbiZSlzJ33n0EvABCJnIKH-1k1c7p0krJAXB5S1KQA4pKius8biSWUEmaAKb_weLRtm-HBHCRhoeFUbByaf-cc-dOKgxJHeSlcnuKgHRegqHJy7ewzr/s1600/entropy+are+not+the+same.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;161&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7mgUksfgWlng9AaYJ_nyMJ6pdKbiZSlzJ33n0EvABCJnIKH-1k1c7p0krJAXB5S1KQA4pKius8biSWUEmaAKb_weLRtm-HBHCRhoeFUbByaf-cc-dOKgxJHeSlcnuKgHRegqHJy7ewzr/s400/entropy+are+not+the+same.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/8715703763828783755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2012/01/entropy-and-gini-index-experiments.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/8715703763828783755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/8715703763828783755'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2012/01/entropy-and-gini-index-experiments.html' title='Entropy and Gini index experiments'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVbunJ6qPtdZH_94xUDE_BzbkAMJ6_Pw0EGLngt6wu-mZgM6el1jHgP2wV0FaUCMOCMUOz3yjkUoZyqrWx5uLtRif6ut8SQgz16x-rq8h517r_BFnleOSrNI7niSsDwhgDBEFXaau28F-3/s72-c/samecolor_sameShape.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-2801978640471208343</id><published>2011-12-31T03:10:00.000-08:00</published><updated>2020-06-12T06:54:54.661-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="4 neighbors"/><category scheme="http://www.blogger.com/atom/ns#" term="blob detection"/><category scheme="http://www.blogger.com/atom/ns#" term="blob labeling"/><category scheme="http://www.blogger.com/atom/ns#" term="code"/><category scheme="http://www.blogger.com/atom/ns#" term="connected components"/><category scheme="http://www.blogger.com/atom/ns#" term="floodfill"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv internal function"/><category scheme="http://www.blogger.com/atom/ns#" term="ROI"/><title type='text'>Blob Detection, Connected Component (Pure Opencv)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6josbwuZdPJO9H5MyQxbNmFbohHiXy8yeW2yFlxIdASc6dXx9gFW4Zhrg-cdv3fQqBCvWAPU7UYLuspml9L4L46DGfKkTmD-YhMFa7ywX7ssxGYXr9D0-H-sBhLRrj_IObB4O8JD7rWsD/s1600/result+Con+Comp.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6josbwuZdPJO9H5MyQxbNmFbohHiXy8yeW2yFlxIdASc6dXx9gFW4Zhrg-cdv3fQqBCvWAPU7UYLuspml9L4L46DGfKkTmD-YhMFa7ywX7ssxGYXr9D0-H-sBhLRrj_IObB4O8JD7rWsD/s320/result+Con+Comp.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Connected-component labeling (alternatively connected-component analysis, blob extraction, region labeling, blob discovery, or region extraction) is an algorithmic application of graph theory, where subsets of connected components are uniquely labeled based on a given heuristic. Connected-component labeling is not to be confused with segmentation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
i got the initial code from this URL: http://nghiaho.com/?p=1102&lt;br /&gt;
However the code did not compile with my setup of OpenCV 2.2, im guessing it was an older version. so a refactored and corrected the errors to come up with this Class&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot; style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;class atsBlobFinder&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; atsBlobFinder()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///Original Code by http://nghiaho.com/?p=1102&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///Changed and added commments. Removed Errors&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///works with VS2010 and OpenCV 2.2+&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; void FindBlobs(const cv::Mat &amp;amp;binary, vector &amp;lt; vector&amp;lt;cv::Point&amp;gt;&amp;nbsp; &amp;gt; &amp;amp;blobs)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; blobs.clear();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Fill the label_image with the blobs&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // 0&amp;nbsp; - background&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // 1&amp;nbsp; - unlabelled foreground&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // 2+ - labelled foreground&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///input is a binary image therefore values are either 0 or 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///out objective is to find a set of 1&#39;s that are together and assign 2 to it&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ///then look for other 1&#39;s, and assign 3 to it....so on a soforth&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat label_image;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; binary.convertTo(label_image, CV_32FC1); // weird it doesn&#39;t support CV_32S! Because the CV::SCALAR is a double value in the function floodfill&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int label_count = 2; // starts at 2 because 0,1 are used already&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //erode to remove noise-------------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat element = getStructuringElement( MORPH_RECT,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Size( 2*3 + 1, 2*3+1 ),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( 0, 0 ) );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /// Apply the erosion operation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; erode( label_image, label_image, element );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //---------------------------------------------------&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //just check the Matrix of label_image to make sure we have 0 and 1 only&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; label_image &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(int y=0; y &amp;lt; binary.rows; y++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(int x=0; x &amp;lt; binary.cols; x++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float checker = label_image.at&amp;lt;float&amp;gt;(y,x); //need to look for float and not int as the scalar value is of type double&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Rect rect;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; &quot;check:&quot; &amp;lt;&amp;lt; checker &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(checker == 1) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //fill region from a point&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::floodFill(label_image, cv::Point(x,y), cv::Scalar(label_count), &amp;amp;rect, cv::Scalar(0), cv::Scalar(0), 4);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; label_count++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; label_image &amp;lt;&amp;lt; endl &amp;lt;&amp;lt;&quot;by checking: &quot; &amp;lt;&amp;lt; label_image.at&amp;lt;float&amp;gt;(y,x) &amp;lt;&amp;lt;endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; label_image;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //a vector of all points in a blob&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; std::vector&amp;lt;cv::Point&amp;gt; blob;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i=rect.y; i &amp;lt; (rect.y+rect.height); i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j=rect.x; j &amp;lt; (rect.x+rect.width); j++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float chk = label_image.at&amp;lt;float&amp;gt;(i,j);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; chk &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(chk == label_count-1) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; blob.push_back(cv::Point(j,i));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //place the points of a single blob in a grouping&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //a vector of vector points&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; blobs.push_back(blob);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; label_count &amp;lt;&amp;lt;endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; imshow(&quot;label image&quot;,label_image);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
From the code comments, ive answered and tested a few parts which the original author did not discuss.&lt;br /&gt;
&lt;br /&gt;
Running on Visual Studio 2010 and OpenCV 2.2 using the 4 connected neighbors and opencv internal function FloodFill.&lt;br /&gt;
&lt;br /&gt;
1. Get the Binary image. the binary image should have values of 0 and 1 only.&lt;br /&gt;
2. go through each pixel and find the value 1, floodfill and replace all 1 with a counter ie. number 2&lt;br /&gt;
3. every blob found should now be part of floodfill and all neighbors value changed to an ascending number&lt;br /&gt;
4. from each blob, get the x and y coordinate of that blob and save it in a vector. giving you a vector&amp;lt;Point&amp;gt;&lt;br /&gt;
5. save each of those Vector&amp;lt;Point&amp;gt; into another Vector which represents all the blobs found&lt;br /&gt;
6. Output the value&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv5IAJunn9UBcFgeIap6gJ8O67FJi5MNKvQmhucLADBLrBHLbQss777xxwDlKCBZ2WgN2-ElAQgPy3sQkfnDUrdK3DKSV-6zo4Xt_TFBKTfUiENWakquSqVAKLTYt4fZ47KjkabM1TGX_0/s1600/connected+component+result.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv5IAJunn9UBcFgeIap6gJ8O67FJi5MNKvQmhucLADBLrBHLbQss777xxwDlKCBZ2WgN2-ElAQgPy3sQkfnDUrdK3DKSV-6zo4Xt_TFBKTfUiENWakquSqVAKLTYt4fZ47KjkabM1TGX_0/s400/connected+component+result.jpg&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
atsBlobFinder blb;&lt;br /&gt;
cv::Mat output = cv::Mat::zeros(img.size(), CV_8UC3); //3 Channels&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat binary;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vector &amp;lt;vector&amp;lt;cv::Point&amp;gt;&amp;gt; blobs;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; blb.FindBlobs(binary, blobs);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(size_t i=0; i &amp;lt; blobs.size(); i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char r = 255 * (rand()/(1.0 + RAND_MAX));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char g = 255 * (rand()/(1.0 + RAND_MAX));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char b = 255 * (rand()/(1.0 + RAND_MAX));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(size_t j=0; j &amp;lt; blobs[i].size(); j++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int x = blobs[i][j].x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int y = blobs[i][j].y;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; output.at&amp;lt;Vec3b&amp;gt;(y,x)[0] = ima.at&amp;lt;uchar&amp;gt;(y,x); //channel 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; output.at&amp;lt;Vec3b&amp;gt;(y,x)[1] = ima.at&amp;lt;uchar&amp;gt;(y,x); //channel 2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; output.at&amp;lt;Vec3b&amp;gt;(y,x)[2] = ima.at&amp;lt;uchar&amp;gt;(y,x); //channel 3&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; imshow(&quot;con comp&quot;,output);&lt;br /&gt;
&lt;br /&gt;
the vector&amp;lt;vector&amp;lt;Point&amp;gt;&amp;gt; blobs can create a mask and output the blob in separate images
&lt;br /&gt;
&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot; target=&quot;_top&quot;&gt;
&lt;input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;_s-xclick&quot; /&gt;
&lt;input name=&quot;hosted_button_id&quot; type=&quot;hidden&quot; value=&quot;Y8KAE87HNCC88&quot; /&gt;
&lt;input alt=&quot;Donate with PayPal button&quot; border=&quot;0&quot; name=&quot;submit&quot; src=&quot;https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif&quot; title=&quot;PayPal - The safer, easier way to pay online!&quot; type=&quot;image&quot; /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;https://www.paypal.com/en_PH/i/scr/pixel.gif&quot; width=&quot;1&quot; /&gt;
&lt;/form&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/2801978640471208343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/12/blob-detection-connected-component-pure.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2801978640471208343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2801978640471208343'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/12/blob-detection-connected-component-pure.html' title='Blob Detection, Connected Component (Pure Opencv)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6josbwuZdPJO9H5MyQxbNmFbohHiXy8yeW2yFlxIdASc6dXx9gFW4Zhrg-cdv3fQqBCvWAPU7UYLuspml9L4L46DGfKkTmD-YhMFa7ywX7ssxGYXr9D0-H-sBhLRrj_IObB4O8JD7rWsD/s72-c/result+Con+Comp.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-6807337234682957455</id><published>2011-12-28T02:43:00.000-08:00</published><updated>2011-12-31T03:15:27.660-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gini index"/><category scheme="http://www.blogger.com/atom/ns#" term="measure of impurity"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv C++"/><category scheme="http://www.blogger.com/atom/ns#" term="VS2010 Opencv"/><title type='text'>Computing Gini Index of an image (measure of Impurity)</title><content type='html'>Using my previous posts Class file and this reference:&lt;br /&gt;
&lt;a href=&quot;http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm&quot;&gt;http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;float computeGiniIndex(Mat r, Mat g, Mat b)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float giniIndex = 0.0;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float frequency = getFrequencyOfBin(r);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(r,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; giniIndex += Hc*Hc;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; frequency = getFrequencyOfBin(g);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(g,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; giniIndex += Hc*Hc;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; frequency = getFrequencyOfBin(b);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(b,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; giniIndex += Hc*Hc;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; giniIndex = 1 - (giniIndex);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; giniIndex &amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return giniIndex;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/6807337234682957455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/12/computing-gini-index-of-image-measure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6807337234682957455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6807337234682957455'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/12/computing-gini-index-of-image-measure.html' title='Computing Gini Index of an image (measure of Impurity)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-7398661532658763418</id><published>2011-12-23T21:04:00.000-08:00</published><updated>2020-06-12T06:55:32.956-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="entropy"/><category scheme="http://www.blogger.com/atom/ns#" term="OOP"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="shannon entropy"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio 2010"/><title type='text'>Computing Entropy of an image (CORRECTED)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot; target=&quot;_top&quot;&gt;
&lt;input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;_s-xclick&quot; /&gt;
&lt;input name=&quot;hosted_button_id&quot; type=&quot;hidden&quot; value=&quot;Y8KAE87HNCC88&quot; /&gt;
&lt;input alt=&quot;Donate with PayPal button&quot; border=&quot;0&quot; name=&quot;submit&quot; src=&quot;https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif&quot; title=&quot;PayPal - The safer, easier way to pay online!&quot; type=&quot;image&quot; /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;https://www.paypal.com/en_PH/i/scr/pixel.gif&quot; width=&quot;1&quot; /&gt;
&lt;/form&gt;
entropy is a measure of the uncertainty associated with a random variable.&lt;br /&gt;
basically i want to get a single value representing the entropy of an image.&lt;br /&gt;
&lt;br /&gt;
1. Assign 255 bins for the range of values between 0-255&lt;br /&gt;
2. separate the image into its 3 channels&lt;br /&gt;
3. compute histogram for each channel&lt;br /&gt;
4. normalize all 3 channels unifirmely&lt;br /&gt;
&lt;strike&gt;5. for each channel get the bin value (Hc) and use its absolute value (negative log is infinity)&lt;/strike&gt;&lt;br /&gt;
&lt;strike&gt;6. compute Hc*log10(Hc)&lt;/strike&gt;&lt;br /&gt;
&lt;strike&gt;7. add to entropy and continue with 5 until a single value converges&lt;/strike&gt;&lt;br /&gt;
5. get the frequency of each channel - add all the values of the bin&lt;br /&gt;
6. for each bin get a probability -&lt;br /&gt;
if bin 1 = 20&lt;br /&gt;
bin 2 = 30&lt;br /&gt;
then frequency is 50 and probability is 20/50 and 30/50&lt;br /&gt;
then compute using shannon formula&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;REFERENCE: &lt;a href=&quot;http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm&quot;&gt;http://people.revoledu.com/kardi/tutorial/DecisionTree/how-to-measure-impurity.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;class atsHistogram&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;{&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;public:&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat DrawHistogram(Mat src)&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /// Separate the image in 3 places ( R, G and B )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;vector&amp;lt;Mat&amp;gt; rgb_planes;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;split( src, rgb_planes );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Establish the number of bins&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int histSize = 255;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Set the ranges ( for R,G,B) )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float range[] = { 0, 255 } ;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;const float* histRange = { range };&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;bool uniform = true; bool accumulate = false;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Mat r_hist, g_hist, b_hist;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Compute the histograms:&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[0], 1, 0, Mat(), r_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[1], 1, 0, Mat(), g_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[2], 1, 0, Mat(), b_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Draw the histograms for R, G and B&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int hist_w = 400; int hist_h = 400;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int bin_w = cvRound( (double) hist_w/histSize );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Mat histImage( hist_w, hist_h, CV_8UC3, Scalar( 0,0,0) );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Normalize the result to [ 0, histImage.rows ]&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&lt;br /&gt;&lt;/strike&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Draw for each channel&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/*for( int i = 1; i &amp;lt; histSize; i++ )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(r_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(r_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 0, 0, 255), 2, 8, 0&amp;nbsp; );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(g_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(g_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 0, 255, 0), 2, 8, 0&amp;nbsp; );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(b_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 255, 0, 0), 2, 8, 0&amp;nbsp; );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }*/&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;double entropy = (double)computeShannon(r_hist,g_hist,b_hist);&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//printf(&quot;Entropy: %f&quot; , entropy );&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; entropy &amp;lt;&amp;lt; endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return histImage;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float getHistogramBinValue(Mat hist, int binNum)&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //return cvRound(hist.at&amp;lt;float&amp;gt;(binNum));&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return hist.at&amp;lt;float&amp;gt;(binNum);&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float computeShannon(Mat r, Mat g, Mat b)&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int histSize = 255; //number of bins&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float entropy = 0.0;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(r,i));&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; &quot;Red &quot; &amp;lt;&amp;lt; Hc &amp;lt;&amp;lt; endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += Hc * log10(Hc);&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; &quot;-&quot; &amp;lt;&amp;lt; Hc &amp;lt;&amp;lt; &quot; -n- &quot; &amp;lt;&amp;lt; entropy &amp;lt;&amp;lt; endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(g,i));&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; &quot;Green &quot; &amp;lt;&amp;lt; Hc &amp;lt;&amp;lt; endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += Hc * log10(Hc);&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(b,i));&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; &quot;Blue &quot; &amp;lt;&amp;lt; Hc &amp;lt;&amp;lt; endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += Hc * log10(Hc);&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy = entropy * -1;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; entropy &amp;lt;&amp;lt;endl;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return entropy;&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;private:&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;strike&gt;};&lt;/strike&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;background-color: #fff2cc; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; float getHistogramBinValue(Mat hist, int binNum)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return hist.at&amp;lt;float&amp;gt;(binNum);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;float getFrequencyOfBin(Mat channel)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float frequency = 0.0;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float Hc = abs(getHistogramBinValue(channel,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;frequency += Hc;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return frequency;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float computeShannonEntropy(Mat r, Mat g, Mat b)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float entropy = 0.0;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float frequency = getFrequencyOfBin(r);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(r,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += -(Hc/frequency) * log10((Hc/frequency));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; frequency = getFrequencyOfBin(g);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(g,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += -(Hc/frequency) * log10((Hc/frequency));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; frequency = getFrequencyOfBin(b);&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 1; i &amp;lt; histSize; i++ )&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float Hc = abs(getHistogramBinValue(b,i));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy += -(Hc/frequency) * log10((Hc/frequency));&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; entropy = entropy;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //cout &amp;lt;&amp;lt; entropy &amp;lt;&amp;lt;endl;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return entropy;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/7398661532658763418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/12/computing-entropy-of-image.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/7398661532658763418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/7398661532658763418'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/12/computing-entropy-of-image.html' title='Computing Entropy of an image (CORRECTED)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-129412347699350321</id><published>2011-10-08T01:14:00.000-07:00</published><updated>2011-10-08T01:15:49.963-07:00</updated><title type='text'>Opencv 2.3.1 Installation</title><content type='html'>alright it took me a while before posting this. for OPENCV 2.3.1 and  Visual studio 2010 Professional on a windows 7 64 bit environment&lt;br /&gt;
&lt;br /&gt;
Download The &quot;super pack&quot; and unzip to &quot;C:\OPENCV&quot;&lt;br /&gt;
it seems you can only get the source of opencv and need to compile it with CMAKE.&lt;br /&gt;
very straight forward.&lt;br /&gt;
download CMAKE and use the command prompt to enter CMAKE CMAKELIST.txt at the opencv directory&lt;br /&gt;
&lt;br /&gt;
Open&amp;nbsp; &quot;ALL_BUILD&quot; by double clicking - opens up visual studio&lt;br /&gt;
Compile it and wait. (took a minute)&lt;br /&gt;
go to properties and select the release version and compile again (took another minute)&lt;br /&gt;
&lt;br /&gt;
your all set with the opencv installation &quot;c:\opencv\build&quot;&lt;br /&gt;
&lt;br /&gt;
create an empty visual studio &quot;win32 console application&quot;&lt;br /&gt;
&lt;br /&gt;
Click on Configuration Properties-&amp;gt;VC++ Directories, and edit the Include Directories. Add:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;C:\opencv\build\common\tbb30_20110427oss\include&lt;/span&gt;&lt;/b&gt; &lt;span style=&quot;background-color: yellow; color: red;&quot;&gt;(UPDATE)&lt;/span&gt;&lt;br /&gt;
C:\opencv\build\include&lt;br /&gt;
&lt;br /&gt;
Click on Configuration Properties-&amp;gt;VC++ Directories, and edit the Library Directories. Add:&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;C:\opencv\build\common\tbb30_20110427oss\lib\ia32\vc10&lt;/span&gt; &lt;/b&gt;&lt;span style=&quot;background-color: yellow; color: red;&quot;&gt;(UPDATE)&lt;/span&gt;&lt;br /&gt;
C:\opencv\build\x86\vc10\lib&lt;br /&gt;
&lt;br /&gt;
Click on Configuration Properties-&amp;gt;Linker-&amp;gt;Input, and edit the Additional Dependencies. Add:&lt;br /&gt;
opencv_core231d.lib&lt;br /&gt;
opencv_imgproc231d.lib&lt;br /&gt;
opencv_highgui231d.lib&lt;br /&gt;
opencv_ml231d.lib&lt;br /&gt;
opencv_video231d.lib&lt;br /&gt;
opencv_features2d231d.lib&lt;br /&gt;
opencv_calib3d231d.lib&lt;br /&gt;
opencv_objdetect231d.lib&lt;br /&gt;
opencv_contrib231d.lib&lt;br /&gt;
opencv_legacy231d.lib&lt;br /&gt;
opencv_flann231d.lib&lt;br /&gt;
&lt;br /&gt;
Click on Configuration Properties-&amp;gt;Debugging, and edit the Environment.&lt;br /&gt;
&amp;nbsp;PATH=C:\opencv\build\x86\vc10\bin;&lt;b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;C:\opencv\build\common\tbb30_20110427oss\bin\ia32\vc10 &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipFtYFzj67dGS7u6gB9g-rtmsOgBBUxjPdQehljA5kSADotMBOdv12Y0kTJXfaBXXUAdAXbZS9TOwS7ScHSihW91WQqs0HYtz9XreO4yJAqoZ4oNOit_kzopJ6reovi9cjQNXyaXy358qM/s1600/opencv231_environment.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;201&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipFtYFzj67dGS7u6gB9g-rtmsOgBBUxjPdQehljA5kSADotMBOdv12Y0kTJXfaBXXUAdAXbZS9TOwS7ScHSihW91WQqs0HYtz9XreO4yJAqoZ4oNOit_kzopJ6reovi9cjQNXyaXy358qM/s320/opencv231_environment.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Your all set.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: yellow; color: red;&quot;&gt;(UPDATE)&lt;/span&gt;&lt;br /&gt;
i realized when trying to compile lkdemo.cpp an error:&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfaxEnR5_tSMtiKkVVuHTsFXYjv37KGFQVDOQ8xPkWvVTS1d3XffNeemKuF_SvEESihK-hcfeCdbRWUBlZKfUGb3VUILPWyw2oU0r1uk_fWmTbb37eIIg30ui-nWgq4YhVsnJprQ7xK61Z/s1600/opencv231_tbberror.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;165&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfaxEnR5_tSMtiKkVVuHTsFXYjv37KGFQVDOQ8xPkWvVTS1d3XffNeemKuF_SvEESihK-hcfeCdbRWUBlZKfUGb3VUILPWyw2oU0r1uk_fWmTbb37eIIg30ui-nWgq4YhVsnJprQ7xK61Z/s320/opencv231_tbberror.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
even  though opencv has a tbb folder in the build/common it does not include  the complete library so we need to download the whole version from &lt;u&gt;http://threadingbuildingblocks.org/ver.php?fid=171&lt;/u&gt;&lt;br /&gt;
and unzip it to &quot;c:\opencv\build\common&quot;. there is no need to compile it as its already ready for use.&lt;br /&gt;
&lt;br /&gt;
just make the additional changes to the library and include and bin files for this to work.</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/129412347699350321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/10/opencv-231-installation.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/129412347699350321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/129412347699350321'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/10/opencv-231-installation.html' title='Opencv 2.3.1 Installation'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipFtYFzj67dGS7u6gB9g-rtmsOgBBUxjPdQehljA5kSADotMBOdv12Y0kTJXfaBXXUAdAXbZS9TOwS7ScHSihW91WQqs0HYtz9XreO4yJAqoZ4oNOit_kzopJ6reovi9cjQNXyaXy358qM/s72-c/opencv231_environment.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-7317881040948073144</id><published>2011-09-19T02:10:00.001-07:00</published><updated>2020-07-27T17:51:26.172-07:00</updated><title type='text'>Condensation algorithm (particle filter) in Legacy opencv</title><content type='html'>you need to include the following include:&lt;br /&gt;
#include &amp;lt;opencv2/legacy/legacy.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create an instance &lt;br /&gt;
CvConDensation* ConDens = cvCreateConDensation( DP, MP, nSamples );&lt;br /&gt;
&lt;br /&gt;
for every X and Y coordinate&lt;br /&gt;
&lt;br /&gt;
initialize and update the condensation&lt;br /&gt;
&lt;br /&gt;
refracted Code to Follow</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/7317881040948073144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/condensation-algorithm-particle-filter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/7317881040948073144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/7317881040948073144'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/condensation-algorithm-particle-filter.html' title='Condensation algorithm (particle filter) in Legacy opencv'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-4638813467473233207</id><published>2011-09-17T07:49:00.000-07:00</published><updated>2020-06-12T06:55:53.589-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="drawcontours"/><category scheme="http://www.blogger.com/atom/ns#" term="findcontours"/><category scheme="http://www.blogger.com/atom/ns#" term="moments"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><title type='text'>Blobs with opencv (internal function)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;form action=&quot;https://www.paypal.com/cgi-bin/webscr&quot; method=&quot;post&quot; target=&quot;_top&quot;&gt;
&lt;input name=&quot;cmd&quot; type=&quot;hidden&quot; value=&quot;_s-xclick&quot; /&gt;
&lt;input name=&quot;hosted_button_id&quot; type=&quot;hidden&quot; value=&quot;Y8KAE87HNCC88&quot; /&gt;
&lt;input alt=&quot;Donate with PayPal button&quot; border=&quot;0&quot; name=&quot;submit&quot; src=&quot;https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif&quot; title=&quot;PayPal - The safer, easier way to pay online!&quot; type=&quot;image&quot; /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;1&quot; src=&quot;https://www.paypal.com/en_PH/i/scr/pixel.gif&quot; width=&quot;1&quot; /&gt;
&lt;/form&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAStmazbCYAA4ESLjfwOicuN4KZRls_wa82s9R2-afGESRZTuCEcA6qV8405KeuSIFzm7q90jv9UhXhfdOrbuGrDO9sNbeaBHBPHNi0abipRLBQ9UaQLTZXOliAy9RWEvQ-6HdaB7ApZWU/s1600/ScreenShot006.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAStmazbCYAA4ESLjfwOicuN4KZRls_wa82s9R2-afGESRZTuCEcA6qV8405KeuSIFzm7q90jv9UhXhfdOrbuGrDO9sNbeaBHBPHNi0abipRLBQ9UaQLTZXOliAy9RWEvQ-6HdaB7ApZWU/s400/ScreenShot006.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
There are many open source opencv BLOB libraries that you can use. i have tried several of these, however because of the 64 bit machine that im using recompiling these are very troublesome.&lt;br /&gt;
&lt;br /&gt;
If you have heard of these libraries:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&quot;cvBlobsLib&quot;: &lt;a href=&quot;http://opencv.willowgarage.com/wiki/cvBlobsLib&quot;&gt;http://opencv.willowgarage.com/wiki/cvBlobsLib&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&quot;cvBlob&quot;: &lt;a href=&quot;http://code.google.com/p/cvblob/&quot;&gt;http://code.google.com/p/cvblob/&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&quot;Bloblib&quot; by Dave Grossman (also referred to as &quot;Blob Analysis Package&quot;):   &lt;br /&gt;
Go to &lt;a href=&quot;http://tech.groups.yahoo.com/group/OpenCV/files/&quot;&gt;http://tech.groups.yahoo.com/group/OpenCV/files/&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;
&amp;nbsp;You will know that opencv also has a built in function that can help you find blobs using cv::findContour and see some statistics using the cv::moments.&lt;br /&gt;
eventually make these functions similar to regionprops Matlab function&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_9oyhYL8XdYFurzOzK3pEUcBg2XmjbRS2qQSyGm29925VYzzyJoyBfOT6o3loyRvHkb8IT6JQvKs-kv3dk8hUux3H48Y0OKwkP15xfQ085T-YcMJclmBYzJyxvfoUdq5BOV2PZNxS_3CI/s1600/ScreenShot005.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_9oyhYL8XdYFurzOzK3pEUcBg2XmjbRS2qQSyGm29925VYzzyJoyBfOT6o3loyRvHkb8IT6JQvKs-kv3dk8hUux3H48Y0OKwkP15xfQ085T-YcMJclmBYzJyxvfoUdq5BOV2PZNxS_3CI/s320/ScreenShot005.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The BLOB FINDER CLASS:&lt;br /&gt;
&lt;blockquote&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;class atsBlobFinder&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;public:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; atsBlobFinder(cv::Mat src)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; numBlobs = 0;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat img; //must create a temporary Matrix to hold the gray scale or wont work&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::cvtColor(src,img,CV_BGR2GRAY); //Convert image to GrayScale&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; img = img &amp;gt; 1; //create the binary image&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ////cv::adaptiveThreshold(src,src,64,ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,7,13); //create a binary image&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; findContours( img, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE ); //Find the Contour BLOBS&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Moments&amp;gt; _mu(contours.size() );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Point2f&amp;gt; _mc( contours.size() );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _mu[i] = moments( Mat(contours[i]), false );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _mc[i] = Point2f( _mu[i].m10/_mu[i].m00 , _mu[i].m01/_mu[i].m00);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mu = _mu;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mc = _mc;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; numBlobs = contours.size();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void Draw(cv::Mat &amp;amp;dst)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // iterate through all the top-level contours,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // draw each connected component with its own random color&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Scalar color(&amp;nbsp; rng.uniform(0,255),&amp;nbsp; rng.uniform(0,255),&amp;nbsp; rng.uniform(0,255) );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; drawContours( dst, contours, i, color, CV_FILLED, 8, hierarchy );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // drawCross(mc[i],Scalar(0,0,255), 5,dst); //put a cross&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; char buff[255];&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf(buff, &quot;%d&quot;, i);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; string text = std::string(buff);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::putText(dst,text,mc[i],0,0.5,Scalar(0,0,255),1,8,false);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int getNumBlobs()&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //need to create a buffer for output or wrong reference&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /*char buff[255];&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf(buff, &quot;%d&quot;, numBlobs);*/&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return numBlobs;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;private:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;vector&amp;lt;Point&amp;gt; &amp;gt; contours;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Vec4i&amp;gt; hierarchy;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Moments&amp;gt; mu;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Point2f&amp;gt; mc;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int numBlobs;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;};&lt;/span&gt;&lt;/span&gt; &lt;/blockquote&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0eQLfg-U1L6c2mk8PH3rXas02z3uZ5-OT2B1WeZ6ifiMbaAwjjGcWvSP2Y3rmTm22FVs1NER7jusdN9bbXkReERjChv7AY7IgTLj_mwbGV-7jPuLYTYS9FvLxc0HQOFSchH-tR8CbwShL/s1600/ScreenShot004.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;129&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0eQLfg-U1L6c2mk8PH3rXas02z3uZ5-OT2B1WeZ6ifiMbaAwjjGcWvSP2Y3rmTm22FVs1NER7jusdN9bbXkReERjChv7AY7IgTLj_mwbGV-7jPuLYTYS9FvLxc0HQOFSchH-tR8CbwShL/s320/ScreenShot004.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;// Include OpenCV&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;#include &amp;lt;opencv/cv.h&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;#include &amp;lt;opencv/highgui.h&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;using namespace cv;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;#define drawCross( center, color, d, drawing )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( drawing, Point( center.x - d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( drawing, Point( center.x + d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;RNG rng(12345);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;int main( int argc, char** argv )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat src;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // the first command line parameter must be file name of binary&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // (black-n-white) image&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!(src=imread(&quot;pic6.png&quot;, CV_LOAD_IMAGE_GRAYSCALE)).data)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;OOOPS&quot;);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; waitKey(0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return -1;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat dst = Mat::zeros(src.rows, src.cols, CV_8UC3);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; src = src &amp;gt; 1;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //cv::adaptiveThreshold(src,src,64,ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,7,13);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; namedWindow( &quot;Source&quot;, 1 );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; imshow( &quot;Source&quot;, src );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;vector&amp;lt;Point&amp;gt; &amp;gt; contours;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Vec4i&amp;gt; hierarchy;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; findContours( src, contours, hierarchy,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// Get the moments&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Moments&amp;gt; mu(contours.size() );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Point2f&amp;gt; mc( contours.size() );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mu[i] = moments( Mat(contours[i]), false ); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // iterate through all the top-level contours,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // draw each connected component with its own random color&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Scalar color(&amp;nbsp; rng.uniform(0,255),&amp;nbsp; rng.uniform(0,255),&amp;nbsp; rng.uniform(0,255) );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawContours( dst, contours, i, color, CV_FILLED, 8, hierarchy );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // drawCross(mc[i],Scalar(0,0,255), 5,dst); //put a cross&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;char buff[255];&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sprintf(buff, &quot;%d&quot;, i);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;string text = std::string(buff);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::putText(dst,text,mc[i],0,0.5,Scalar(0,0,255),1,8,false);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; namedWindow( &quot;Components&quot;, 1 );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; imshow( &quot;Components&quot;, dst );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitKey(0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;iostream&gt;&lt;opencv cv.h=&quot;&quot;&gt;&lt;opencv highgui.h=&quot;&quot;&gt;&lt;vector&gt;&lt;point&gt;&lt;vec4i&gt;&lt;moments&gt;&lt;point2f&gt;&lt;br /&gt;
&lt;/point2f&gt;&lt;/moments&gt;&lt;/vec4i&gt;&lt;/point&gt;&lt;/vector&gt;&lt;/opencv&gt;&lt;/opencv&gt;&lt;/iostream&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/4638813467473233207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/blobs-with-opencv-internal-function.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/4638813467473233207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/4638813467473233207'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/blobs-with-opencv-internal-function.html' title='Blobs with opencv (internal function)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAStmazbCYAA4ESLjfwOicuN4KZRls_wa82s9R2-afGESRZTuCEcA6qV8405KeuSIFzm7q90jv9UhXhfdOrbuGrDO9sNbeaBHBPHNi0abipRLBQ9UaQLTZXOliAy9RWEvQ-6HdaB7ApZWU/s72-c/ScreenShot006.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-6854727731334702691</id><published>2011-09-17T04:51:00.000-07:00</published><updated>2011-09-17T04:58:19.679-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="center"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="rectangle"/><category scheme="http://www.blogger.com/atom/ns#" term="shapes"/><title type='text'>finding the center of gravity in opencv</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsgTU7HucR_TbQIiVqTCoblnR_3tmGrVptUu087jmCfZpiKLFqjc1pz3O_BO0KZzBM2la1ghHMecHbDbHGk5o13r37hL4DAQ6ck30r0ldNsKzwKcQtTD1vBLWDxGU8qAp_0jIc9Fkaj-E/s1600/ScreenShot003.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsgTU7HucR_TbQIiVqTCoblnR_3tmGrVptUu087jmCfZpiKLFqjc1pz3O_BO0KZzBM2la1ghHMecHbDbHGk5o13r37hL4DAQ6ck30r0ldNsKzwKcQtTD1vBLWDxGU8qAp_0jIc9Fkaj-E/s400/ScreenShot003.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alot of feature detectors such as the Haar classifier will return rectangular shapes presented as a detected feature.&lt;br /&gt;
&lt;br /&gt;
one of the things to do in order to track these, is to find the center of the rectangle.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf_cp_VdUbk_EawzzKmnLsW2LWxk6hJuLI68A1M54UQ0k5jDMeyJ8gjCvGDzIRFCyqFOl_WByelnJ8wUvEqHtjCz8Ytdg3l1P8bMJ58x-bkl_J3e25yLJhr-4Z6IwnegQOZk1pfbP_C50n/s1600/ScreenShot001.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf_cp_VdUbk_EawzzKmnLsW2LWxk6hJuLI68A1M54UQ0k5jDMeyJ8gjCvGDzIRFCyqFOl_WByelnJ8wUvEqHtjCz8Ytdg3l1P8bMJ58x-bkl_J3e25yLJhr-4Z6IwnegQOZk1pfbP_C50n/s400/ScreenShot001.jpg&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int main( int argc, char** argv )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;atscameraCapture movie;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;char code = (char)-1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;for(;;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //get camera &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat imgs = movie.ats_getImage();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define drawCross( center, color, d, img )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x - d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x + d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point center;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //given 2 points representing the rectangle&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point topLeft(100,100);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point bottomRight(200,200);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::rectangle(imgs,topLeft,bottomRight,Scalar( 0, 255, 255 ),-1, 8 );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: red;&quot;&gt;//compute for center of triangle&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; center.x = (topLeft.x+bottomRight.x)/2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; center.y = (topLeft.y+bottomRight.y)/2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; drawCross(center,Scalar(0,0,255), 5,imgs);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; imshow(&quot;camera&quot;,&amp;nbsp; imgs);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; code = (char)waitKey(100);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if( code == 27 || code == &#39;q&#39; || code == &#39;Q&#39; )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
Another way of finding the center of gravity is using the internal function of OPENCV called cv::moments&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc2eOy9DC4Lg7oHM4FKsapDcjrsZATVClWYYmLOcYNQIj3EBsxYm64HWWVEyzl2wMN0DSY-MQN7EJWjpCWfD0NdvfH8FjngnEkmE965dp6Vq-YdG43_LeqXxNClIIWXUrQD1JCJSJlAv1M/s1600/ScreenShot002.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc2eOy9DC4Lg7oHM4FKsapDcjrsZATVClWYYmLOcYNQIj3EBsxYm64HWWVEyzl2wMN0DSY-MQN7EJWjpCWfD0NdvfH8FjngnEkmE965dp6Vq-YdG43_LeqXxNClIIWXUrQD1JCJSJlAv1M/s400/ScreenShot002.jpg&quot; width=&quot;368&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Mat canny_output;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; vector&amp;lt;vector&amp;lt;Point&amp;gt; &amp;gt; contours;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; vector&amp;lt;Vec4i&amp;gt; hierarchy;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; RNG rng(12345);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;/** @function main */&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int main( int argc, char** argv )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;atscameraCapture movie;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;char code = (char)-1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;for(;;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //get camera &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat src_gray;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat imgs = movie.ats_getImage();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#define drawCross( center, color, d, img )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x - d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x + d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Convert image to gray and blur it&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; cvtColor( imgs, src_gray, CV_BGR2GRAY );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; blur( src_gray, src_gray, Size(3,3) );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; /// Detect edges using canny&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Canny( src_gray, canny_output, 10, 50, 3 );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; /// Find contours&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; /// Get the moments&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; vector&amp;lt;Moments&amp;gt; mu(contours.size() );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{ mu[i] = moments( Mat(contours[i]), false ); }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; ///&amp;nbsp; Get the mass centers:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; vector&amp;lt;Point2f&amp;gt; mc( contours.size() );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; for( int i = 0; i &amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{ mc[i] = Point2f( mu[i].m10/mu[i].m00 , mu[i].m01/mu[i].m00 ); &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; for( int i = 0; i&amp;lt; contours.size(); i++ )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; drawContours( drawing, contours, i, color, 2, 8, hierarchy, 0, Point() );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; circle( drawing, mc[i], 4, color, -1, 8, 0 );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; * Contour[%d] - Area (M_00) = %.2f - Area OpenCV: %.2f - Length: %.2f \n&quot;, i, mu[i].m00, contourArea(Mat(contours[i])), arcLength( Mat(contours[i]), true ) );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; namedWindow( &quot;Contours&quot;, CV_WINDOW_AUTOSIZE );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; imshow( &quot;Contours&quot;, drawing );&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //imshow(&quot;camera&quot;,&amp;nbsp; src_gray);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; code = (char)waitKey(1000);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if( code == 27 || code == &#39;q&#39; || code == &#39;Q&#39; )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/6854727731334702691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/finding-center-of-gravity-in-opencv.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6854727731334702691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6854727731334702691'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/finding-center-of-gravity-in-opencv.html' title='finding the center of gravity in opencv'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsgTU7HucR_TbQIiVqTCoblnR_3tmGrVptUu087jmCfZpiKLFqjc1pz3O_BO0KZzBM2la1ghHMecHbDbHGk5o13r37hL4DAQ6ck30r0ldNsKzwKcQtTD1vBLWDxGU8qAp_0jIc9Fkaj-E/s72-c/ScreenShot003.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-104445995867475259</id><published>2011-09-12T22:02:00.000-07:00</published><updated>2011-09-12T22:02:56.956-07:00</updated><title type='text'>2D/3D estimation using solvePnP in opencv (NOT SOLVED)</title><content type='html'>In opencv &quot;solvePnP&quot; is used to find known points on a known 3D object. doing so the objects orientation relative to the camera coordinate system can be found.&lt;br /&gt;
the function is equivalent to finding the extrinsic camera parameters. &lt;u&gt;which makes me believe its more for planar objects.&lt;/u&gt; &lt;b&gt;need to do a few more experiments to find out why.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
im using code from:&lt;br /&gt;
&lt;a href=&quot;http://www.morethantechnical.com/2010/03/19/quick-and-easy-head-pose-estimation-with-opencv-w-code/&quot; rel=&quot;nofollow&quot; target=&quot;_top&quot;&gt;&lt;span&gt;http://www.morethantechnical.com/2010/03/19/quick-and-easy-head-pose-estimation-with-opencv-w-code/&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTGBr_RkkeTSrptm6_1KMmsrfrJA-kyo0V7RDd20zIBkFvHTJepVTVjA1TDOGfuMJ9f_F8hqw9bHOmXQgBCBMv-2UC_f5pAjR3Y3QgExc5Yubv-jmXAPwybGSVT733IDP-haS6zRsaGHud/s1600/ScreenShot380.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTGBr_RkkeTSrptm6_1KMmsrfrJA-kyo0V7RDd20zIBkFvHTJepVTVjA1TDOGfuMJ9f_F8hqw9bHOmXQgBCBMv-2UC_f5pAjR3Y3QgExc5Yubv-jmXAPwybGSVT733IDP-haS6zRsaGHud/s320/ScreenShot380.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;opencv2/core/core.hpp&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;opencv2/imgproc/imgproc.hpp&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;opencv2/calib3d/calib3d.hpp&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;string&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;using namespace cv;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;vector&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;GL/gl.h&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;GL/glu.h&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;glut.h&amp;gt;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void loadNext();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void loadWithPoints(Mat&amp;amp; ip, Mat&amp;amp; img);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat light_ambient[]&amp;nbsp; = { 0.0f, 0.0f, 0.0f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat light_diffuse[]&amp;nbsp; = { 1.0f, 1.0f, 1.0f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat mat_ambient[]&amp;nbsp;&amp;nbsp;&amp;nbsp; = { 0.7f, 0.7f, 0.7f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat mat_diffuse[]&amp;nbsp;&amp;nbsp;&amp;nbsp; = { 0.8f, 0.8f, 0.8f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat mat_specular[]&amp;nbsp;&amp;nbsp; = { 1.0f, 1.0f, 1.0f, 1.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;const GLfloat high_shininess[] = { 100.0f };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;double rot[9] = {0};&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Vec3d eav;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GLuint textureID;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Mat backPxls;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;vector&amp;lt;double&amp;gt; rv(3), tv(3);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Mat rvec(rv),tvec(tv);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Mat camMatrix;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void resize(int width, int height)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const float ar = (float) width / (float) height;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glViewport(0, 0, width, height);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMatrixMode(GL_PROJECTION);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLoadIdentity();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gluPerspective(40,1.0,0.01,1000.0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMatrixMode(GL_MODELVIEW);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLoadIdentity() ;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int __w=250,__h=250;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void key(unsigned char key, int x, int y)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //static int counter = 0;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (key)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 27 :&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &#39;Q&#39;:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &#39;q&#39;: &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; case &#39; &#39;:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; loadNext();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; glBindTexture(GL_TEXTURE_2D, textureID);//This binds the texture to a texture target&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);//set our filter&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);&amp;nbsp;&amp;nbsp;&amp;nbsp; //set our filter&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; glTexImage2D(GL_TEXTURE_2D, 0, 3, backPxls.cols, backPxls.rows, 0, GL_RGB, GL_UNSIGNED_BYTE, backPxls.data);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; default:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutPostRedisplay();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void idle(void)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutPostRedisplay();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void myGLinit() {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glClearColor(1,1,1,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glShadeModel(GL_SMOOTH);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnable(GL_DEPTH_TEST);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glDepthFunc(GL_LEQUAL);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnable(GL_LIGHT0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnable(GL_NORMALIZE);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnable(GL_COLOR_MATERIAL);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLightfv(GL_LIGHT0, GL_AMBIENT,&amp;nbsp; light_ambient);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLightfv(GL_LIGHT0, GL_DIFFUSE,&amp;nbsp; light_diffuse);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLightfv(GL_LIGHT0, GL_POSITION, light_position);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMaterialfv(GL_FRONT, GL_AMBIENT,&amp;nbsp;&amp;nbsp; mat_ambient);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMaterialfv(GL_FRONT, GL_DIFFUSE,&amp;nbsp;&amp;nbsp; mat_diffuse);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMaterialfv(GL_FRONT, GL_SPECULAR,&amp;nbsp; mat_specular);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnable(GL_LIGHTING);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glGenTextures(1, &amp;amp;textureID);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void display(void)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glClearColor(1.0f, 1.0f, 1.0f, 0.5f);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);&amp;nbsp;&amp;nbsp;&amp;nbsp; // Clear Screen And Depth Buffer&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMatrixMode(GL_MODELVIEW);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glLoadIdentity();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gluLookAt(0,0,0,0,0,1,0,1,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //----------Axes&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPushMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glTranslated(0,0,5);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPushMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double _d[16] = {&amp;nbsp;&amp;nbsp;&amp;nbsp; rot[0],rot[1],rot[2],0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rot[3],rot[4],rot[5],0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; rot[6],rot[7],rot[8],0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ,1};&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glMultMatrixd(_d);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glRotated(180,1,0,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Z = red&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPushMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glRotated(180,0,1,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glColor3d(1,0,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidCone(0.05,1,15,20);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glTranslated(0,0,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glScaled(.1,.1,.1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidTetrahedron();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPopMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Y = green&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPushMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glRotated(-90,1,0,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glColor3d(0,1,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidCone(0.05,1,15,20);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glTranslated(0,0,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glScaled(.1,.1,.1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidTetrahedron();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPopMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //X = blue&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPushMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glRotated(-90,0,1,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glColor3d(0,0,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidCone(0.05,1,15,20);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glTranslated(0,0,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glScaled(.1,.1,.1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSolidTetrahedron();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPopMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPopMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glPopMatrix();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //----------End axes&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutSwapBuffers();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int start_opengl_with_stereo(int argc,char** argv) {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitWindowSize(250,250);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitWindowPosition(40,40);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInit(&amp;amp;argc, argv);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutCreateWindow(&quot;3D points coordinate&quot;);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGLinit();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutReshapeFunc(resize);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutDisplayFunc(display);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutKeyboardFunc(key);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutIdleFunc(idle);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; glutMainLoop();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Mat op;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void loadNext() {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Point2f &amp;gt; points;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;float x,y;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=282;y=274;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=397;y=227;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=577;y=271;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=462;y=318;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=270;y=479;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=450;y=523;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=566;y=475;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; points.push_back(cv::Point2f(x,y));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat ip(points);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat img =&amp;nbsp; Mat::zeros( 800, 600, CV_8UC3 );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(unsigned int i = 0; i &amp;lt; points.size(); ++i)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::cout &amp;lt;&amp;lt; points[i] &amp;lt;&amp;lt; std::endl;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::circle(img,points[i],2,cv::Scalar(0, 0, 255, 0),1,8,0);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loadWithPoints(ip,img);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void loadWithPoints(Mat&amp;amp; ip, Mat&amp;amp; img) {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double _dc[] = {0,0,0,0};&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; solvePnP(op,ip,camMatrix,Mat(1,4,CV_64FC1,_dc),rvec,tvec,true);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat rotM(3,3,CV_64FC1,rot);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rodrigues(rvec,rotM);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double* _r = rotM.ptr&amp;lt;double&amp;gt;();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat tmp,tmp1,tmp2,tmp3,tmp4,tmp5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double _pm[12] = {_r[0],_r[1],_r[2],0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _r[3],_r[4],_r[5],0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _r[6],_r[7],_r[8],0};&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; decomposeProjectionMatrix(Mat(3,4,CV_64FC1,_pm),tmp,tmp1,tmp2,tmp3,tmp4,tmp5,eav);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; imshow(&quot;tmp&quot;,img);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int main(int argc, char** argv)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;Point3f &amp;gt; modelPoints;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float x,y,z;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=.5;y=.5;z=-.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=.5;y=.5;z=.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=-.5;y=.5;z=.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=-.5;y=.5;z=-.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=.5;y=-.5;z=-.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z)); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=-.5;y=-.5;z=-.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; x=-.5;y=-.5;z=.5;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; modelPoints.push_back(cv::Point3f(x,y,z));&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; op = Mat(modelPoints);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rvec = Mat(rv);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double _d[9] = {1,0,0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,-1,0,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,0,-1};&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rodrigues(Mat(3,3,CV_64FC1,_d),rvec);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tv[0]=0;tv[1]=0;tv[2]=1;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tvec = Mat(tv);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; double _cm[9] = { 40, 0, 400,&lt;/span&gt;&lt;br style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0, 40, 500,&lt;/span&gt;&lt;br style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp;&amp;nbsp; 40 }; //caliberation matrix PROBLEM!?&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; camMatrix = Mat(3,3,CV_64FC1,_cm);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; namedWindow(&quot;tmp&quot;,1);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loadNext();&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; start_opengl_with_stereo(argc,argv);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/104445995867475259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/2d3d-estimation-using-solvepnp-in.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/104445995867475259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/104445995867475259'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/2d3d-estimation-using-solvepnp-in.html' title='2D/3D estimation using solvePnP in opencv (NOT SOLVED)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTGBr_RkkeTSrptm6_1KMmsrfrJA-kyo0V7RDd20zIBkFvHTJepVTVjA1TDOGfuMJ9f_F8hqw9bHOmXQgBCBMv-2UC_f5pAjR3Y3QgExc5Yubv-jmXAPwybGSVT733IDP-haS6zRsaGHud/s72-c/ScreenShot380.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-3649842491208646087</id><published>2011-09-12T20:46:00.000-07:00</published><updated>2011-09-12T20:46:22.163-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opengl"/><title type='text'>Opencv with OpenGL (installation and trials)</title><content type='html'>so i needed to install opengl for a 2D/3D test using opencv&lt;br /&gt;
&lt;br /&gt;
since Opengl libraries come preinstalled just needed to download GLUT from:&lt;br /&gt;
http://www.xmission.com/~nate/glut.html&lt;br /&gt;
&lt;br /&gt;
since im running on a 64bit machine i need to place the GLUT32.dll in the &lt;u style=&quot;color: red;&quot;&gt;C:\Windows\SysWOW64&lt;/u&gt; instead of C:\Windows\System32&lt;br /&gt;
&lt;br /&gt;
i then place the GLUT.h in the:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
and the GLUT32.lib in the&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
in the visual studio dependencies i just add the following:&lt;br /&gt;
opengl32.lib&lt;br /&gt;
glut32.lib&lt;br /&gt;
glu32.lib&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1dE8VpX_-HJR_wIVg3vgn2mMt3ZF04DHxwFRElqjERZIOdHmQNN08AGDL0Sy6sKQoyfcaZKFK_H3Pf2VXgKFAjl2TuyOd5GWIisyk6449uZf2hrzvA4etEi1XGjOvdjsSSa45hJS9M3bZ/s1600/ScreenShot379.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;282&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1dE8VpX_-HJR_wIVg3vgn2mMt3ZF04DHxwFRElqjERZIOdHmQNN08AGDL0Sy6sKQoyfcaZKFK_H3Pf2VXgKFAjl2TuyOd5GWIisyk6449uZf2hrzvA4etEi1XGjOvdjsSSa45hJS9M3bZ/s400/ScreenShot379.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
and im all set and good to go with the test program&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;blockquote&gt;/**********************************&lt;br /&gt;
&amp;nbsp; Simple.cpp&lt;br /&gt;
&amp;nbsp; A simple GLUT program.&lt;br /&gt;
&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;glut.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void mydisplay( void )&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glClearColor (0.0, 0.0, 0.0, 0.0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glClear(GL_COLOR_BUFFER_BIT);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* set drawing/fill&amp;nbsp; color to white */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glColor3f(1.0, 1.0, 1.0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* set up standard orthogonal view with clipping */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* box as cube of side 2 centered at origin */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This is default view and these statement could be removed */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glMatrixMode (GL_PROJECTION);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glLoadIdentity ();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* define unit square polygon */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glBegin(GL_POLYGON);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glVertex2f(-0.5, -0.5);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glVertex2f(-0.5, 0.5);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glVertex2f(0.5, 0.5);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glVertex2f(0.5, -0.5);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glEnd();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* flush GL buffers */&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glFlush();}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**************************************** main() ********************/&lt;br /&gt;
void init()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glClearColor (0.0, 0.0, 0.0, 1.0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glColor3f(1.0, 1.0, 1.0); &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glMatrixMode (GL_PROJECTION);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glLoadIdentity ();&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);&amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInit(&amp;amp;argc,argv);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitWindowSize(500,500);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutInitWindowPosition(0,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutCreateWindow(&quot;simple&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutDisplayFunc(mydisplay);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; init(); &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; glutMainLoop();&lt;br /&gt;
&lt;br /&gt;
}&lt;/blockquote&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/3649842491208646087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/opencv-with-opengl-installation-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3649842491208646087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3649842491208646087'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/opencv-with-opengl-installation-and.html' title='Opencv with OpenGL (installation and trials)'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1dE8VpX_-HJR_wIVg3vgn2mMt3ZF04DHxwFRElqjERZIOdHmQNN08AGDL0Sy6sKQoyfcaZKFK_H3Pf2VXgKFAjl2TuyOd5GWIisyk6449uZf2hrzvA4etEi1XGjOvdjsSSa45hJS9M3bZ/s72-c/ScreenShot379.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-4269162758796143444</id><published>2011-09-04T17:40:00.000-07:00</published><updated>2011-09-04T17:40:06.363-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++"/><category scheme="http://www.blogger.com/atom/ns#" term="cpp"/><category scheme="http://www.blogger.com/atom/ns#" term="OOP"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="visual studio 2010"/><title type='text'>Histogram computation on a video</title><content type='html'>Histograms are collected &lt;i&gt;counts&lt;/i&gt; of data organized into a set of predefined &lt;i&gt;bins&lt;/i&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg3qfwABqyl_8J0VgBykb5t9km7SZ7MaeSAtKiYkSMb1lunGZ6G1OjLhQMKW8aOSLk-x8_O4gGWJdPY-yYGCOLMyro9kOIIGkYhad1pZZ1I93zJI1HWpohKJ0EL8-3bukoqwKZsne7eH4y/s1600/2+Histograms_videoComparison.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg3qfwABqyl_8J0VgBykb5t9km7SZ7MaeSAtKiYkSMb1lunGZ6G1OjLhQMKW8aOSLk-x8_O4gGWJdPY-yYGCOLMyro9kOIIGkYhad1pZZ1I93zJI1HWpohKJ0EL8-3bukoqwKZsne7eH4y/s400/2+Histograms_videoComparison.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&lt;/i&gt;refracted class for histogram: given an input image, output the histogram image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class atsHistogram&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat DrawHistogram(Mat src)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /// Separate the image in 3 places ( R, G and B )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;vector&amp;lt;Mat&amp;gt; rgb_planes;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;split( src, rgb_planes );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Establish the number of bins&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int histSize = 255;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Set the ranges ( for R,G,B) )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float range[] = { 0, 255 } ;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;const float* histRange = { range };&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;bool uniform = true; bool accumulate = false;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Mat r_hist, g_hist, b_hist;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Compute the histograms:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[0], 1, 0, Mat(), r_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[1], 1, 0, Mat(), g_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calcHist( &amp;amp;rgb_planes[2], 1, 0, Mat(), b_hist, 1, &amp;amp;histSize, &amp;amp;histRange, uniform, accumulate );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Draw the histograms for R, G and B&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int hist_w = 400; int hist_h = 400;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;int bin_w = cvRound( (double) hist_w/histSize );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Mat histImage( hist_w, hist_h, CV_8UC3, Scalar( 0,0,0) );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Normalize the result to [ 0, histImage.rows ]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/// Draw for each channel&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for( int i = 1; i &amp;lt; histSize; i++ )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(r_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(r_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 0, 0, 255), 2, 8, 0&amp;nbsp; );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(g_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(g_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 0, 255, 0), 2, 8, 0&amp;nbsp; );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at&amp;lt;float&amp;gt;(i-1)) ) ,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Point( bin_w*(i), hist_h - cvRound(b_hist.at&amp;lt;float&amp;gt;(i)) ),&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Scalar( 255, 0, 0), 2, 8, 0&amp;nbsp; );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return histImage;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
private:&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5a4sUJoekXg9UCSwzdFNyLYWykxRHxcc8mtGeyP_w4Ry4MmJjvxIv55UasA66IsVSuWxLfhfzbfQr7mHcQwv5BidmbAorA7aUixB7MoGuZj8mGFqIYCWn7rvfghHZ7_fDOPRQyT5p1I39/s1600/ScreenShot376.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5a4sUJoekXg9UCSwzdFNyLYWykxRHxcc8mtGeyP_w4Ry4MmJjvxIv55UasA66IsVSuWxLfhfzbfQr7mHcQwv5BidmbAorA7aUixB7MoGuZj8mGFqIYCWn7rvfghHZ7_fDOPRQyT5p1I39/s400/ScreenShot376.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpRXuRbxL9_Lh5EaMt5EKwgc6YMCDn1bHbxQLMlBZSwp8mY2OTxb6uuMBUA7aZC1J6ZR1yeH36WliVVs0eaf2DM1UzFUIevrJr74dNkM5uUqAWMVhYSuKMXs1tx-pity2FZqV2JfPpVvkD/s1600/ScreenShot375.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;197&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpRXuRbxL9_Lh5EaMt5EKwgc6YMCDn1bHbxQLMlBZSwp8mY2OTxb6uuMBUA7aZC1J6ZR1yeH36WliVVs0eaf2DM1UzFUIevrJr74dNkM5uUqAWMVhYSuKMXs1tx-pity2FZqV2JfPpVvkD/s400/ScreenShot375.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/4269162758796143444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/histogram-computation-on-video.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/4269162758796143444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/4269162758796143444'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/histogram-computation-on-video.html' title='Histogram computation on a video'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg3qfwABqyl_8J0VgBykb5t9km7SZ7MaeSAtKiYkSMb1lunGZ6G1OjLhQMKW8aOSLk-x8_O4gGWJdPY-yYGCOLMyro9kOIIGkYhad1pZZ1I93zJI1HWpohKJ0EL8-3bukoqwKZsne7eH4y/s72-c/2+Histograms_videoComparison.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-6635695628134803814</id><published>2011-09-02T01:24:00.000-07:00</published><updated>2011-12-31T03:17:37.445-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="classifier"/><category scheme="http://www.blogger.com/atom/ns#" term="haar"/><category scheme="http://www.blogger.com/atom/ns#" term="Kalman filter"/><category scheme="http://www.blogger.com/atom/ns#" term="tracking"/><category scheme="http://www.blogger.com/atom/ns#" term="Viola and jones"/><title type='text'>Nose Tracking using Kalman Filter and Viola and Jones Classifier</title><content type='html'>&lt;blockquote style=&quot;background-color: #fff2cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;class atsKalman&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atsKalman()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KalmanFilter KF(4, 2, 0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat_&amp;lt;float&amp;gt; state(4, 1); /* (x, y, Vx, Vy) */&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat processNoise(4, 1, CV_32F);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat_&amp;lt;float&amp;gt; measurement(2,1); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; measurement.setTo(Scalar(0));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs = KF;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; measurements = measurement;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; void setKalman(int x, int y)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs.statePre.at&amp;lt;float&amp;gt;(0) = x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs.statePre.at&amp;lt;float&amp;gt;(1) = y;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs.statePre.at&amp;lt;float&amp;gt;(2) = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs.statePre.at&amp;lt;float&amp;gt;(3) = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KFs.transitionMatrix = *(Mat_&amp;lt;float&amp;gt;(4, 4) &amp;lt;&amp;lt; 1,0,0,0,&amp;nbsp;&amp;nbsp; 0,1,0,0,&amp;nbsp; 0,0,1,0,&amp;nbsp; 0,0,0,1);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; setIdentity(KFs.measurementMatrix);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setIdentity(KFs.processNoiseCov, Scalar::all(1e-4));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setIdentity(KFs.measurementNoiseCov, Scalar::all(1e-1));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setIdentity(KFs.errorCovPost, Scalar::all(.1));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Point step1()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat prediction = KFs.predict();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point predictPt(prediction.at&amp;lt;float&amp;gt;(0),prediction.at&amp;lt;float&amp;gt;(1));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return predictPt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Point step2()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat estimated = KFs.correct(measurements);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point statePt(estimated.at&amp;lt;float&amp;gt;(0),estimated.at&amp;lt;float&amp;gt;(1));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return statePt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; void changeMeasure(int x,int y)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; measurements(0) = x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; measurements(1) = y;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; KalmanFilter KFs;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat_&amp;lt;float&amp;gt; measurements;&lt;br /&gt;
};&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRVNLI2bGe6i05B1DK4flgLbcXWfvJd5niZawiD5CKIcgRRJkuROzsYBfz4Jcj-4devxNRUKN9S_zSAxkrVRM-BQWNledgwfOmYfn2SD5om7H1knj97lPXzAozqSLwqp3zMe5KZhURJ6t5/s1600/ScreenShot374.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;241&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRVNLI2bGe6i05B1DK4flgLbcXWfvJd5niZawiD5CKIcgRRJkuROzsYBfz4Jcj-4devxNRUKN9S_zSAxkrVRM-BQWNledgwfOmYfn2SD5om7H1knj97lPXzAozqSLwqp3zMe5KZhURJ6t5/s320/ScreenShot374.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Viola and Jones Classifier is used to detect the nose. the X and Y coordinate of the found nose is sent to the first step of Kalman which is the prediction part. The second step of measurement correction completes the kalman filter.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;
&lt;strike&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;class atsViolaJones&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atsViolaJones()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; storage = cvCreateMemStorage( 0 );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cascade = ( CvHaarClassifierCascade* )cvLoad(&quot;haarcascade_mcs_nose.xml&quot;, 0, 0, 0 );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point Find(cv::Mat image )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage imgs =image;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* img = &amp;amp;imgs;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CvSeq *faces = cvHaarDetectObjects(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; img,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cascade,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; storage,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 1.1,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 3,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvSize( 40, 40 ) );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //get one image&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CvRect *r = ( CvRect* )cvGetSeqElem( faces, 0 );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point found;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; found.x = (r-&amp;gt;x + r-&amp;gt;width);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; found.y =&amp;nbsp; (r-&amp;gt;y + r-&amp;gt;height);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return found;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ~atsViolaJones()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvReleaseHaarClassifierCascade( &amp;amp;cascade );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvReleaseMemStorage( &amp;amp;storage );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CvHaarClassifierCascade *cascade;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CvMemStorage *storage;&lt;br /&gt;
};&lt;/span&gt;&lt;/strike&gt;&lt;/blockquote&gt;
UPDATED class to OPENCV 2.2:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;background-color: #fff2cc;&quot;&gt;
&lt;span style=&quot;background-color: white; color: red; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;class atsViolaJones&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;public:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; atsViolaJones(String filename)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (filename == &quot;&quot;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; filename = &quot;haarcascade_mcs_nose.xml&quot;;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if( !face_cascade.load( filename ) ){ printf(&quot;--(!)Error loading\n&quot;); };&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point Find(cv::Mat frame&amp;nbsp; )&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; std::vector&amp;lt;Rect&amp;gt; faces;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Mat frame_gray;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvtColor( frame, frame_gray, CV_BGR2GRAY );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; equalizeHist( frame_gray, frame_gray );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point found;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; found.x = faces[0].x; //Face[0] is the first face found&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; found.y =&amp;nbsp; faces[0].y;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return found;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;private:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CascadeClassifier face_cascade;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
This is the main function&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;background-color: #fff2cc;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;&quot;&gt;int main (int argc, char * const argv[]) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mat img(500, 500, CV_8UC3);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //init the stuff&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atsKalman ats;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atscameraCapture movie;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atsViolaJones haar;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; char code = (char)-1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //init kalman&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ats.setKalman(0,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mousev.clear();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; kalmanv.clear();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //get camera &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; img = movie.ats_getImage();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Step 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point predictPt = ats.step1();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //object X Y coordinte from another method&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Point found;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; found = haar.Find(img);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int x = found.x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int y = found.y;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ats.changeMeasure(x,y);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point measPt(x,y);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mousev.push_back(measPt);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Step 2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point statePt = ats.step2();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; kalmanv.push_back(statePt);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // plot points&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #define drawCross( center, color, d )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x - d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x + d, center.y + d ), color, 2, CV_AA, 0); \&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line( img, Point( center.x + d, center.y - d ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; \&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Point( center.x - d, center.y + d ), color, 2, CV_AA, 0 )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawCross( statePt, Scalar(0,255,255), 5 );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drawCross( measPt, Scalar(0,0,255), 5 );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; mousev.size()-1; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line(img, mousev[i], mousev[i+1], Scalar(255,255,0), 1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; kalmanv.size()-1; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; line(img, kalmanv[i], kalmanv[i+1], Scalar(0,255,0), 1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imshow( &quot;kalman&quot;, img );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //imshow(&quot;kalman&quot;,haar.Find(img));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; code = (char)waitKey(100);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( code &amp;gt; 0 )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( code == 27 || code == &#39;q&#39; || code == &#39;Q&#39; )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;/span&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/6635695628134803814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/09/nose-tracking-using-kalman-filter-and.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6635695628134803814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6635695628134803814'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/09/nose-tracking-using-kalman-filter-and.html' title='Nose Tracking using Kalman Filter and Viola and Jones Classifier'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRVNLI2bGe6i05B1DK4flgLbcXWfvJd5niZawiD5CKIcgRRJkuROzsYBfz4Jcj-4devxNRUKN9S_zSAxkrVRM-BQWNledgwfOmYfn2SD5om7H1knj97lPXzAozqSLwqp3zMe5KZhURJ6t5/s72-c/ScreenShot374.jpg" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-2250536161347304009</id><published>2011-07-19T18:38:00.000-07:00</published><updated>2011-07-19T18:38:48.142-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="k nearest neighbor"/><category scheme="http://www.blogger.com/atom/ns#" term="K NN"/><category scheme="http://www.blogger.com/atom/ns#" term="KNN"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>Artificial Intelligence (K Nearest Neighbor) in OPENCV</title><content type='html'>In &lt;a href=&quot;http://en.wikipedia.org/wiki/Pattern_recognition&quot; title=&quot;Pattern recognition&quot;&gt;pattern recognition&lt;/a&gt;, the &lt;b&gt;&lt;i&gt;k&lt;/i&gt;-nearest neighbor algorithm&lt;/b&gt; (&lt;i&gt;k&lt;/i&gt;-NN) is a method for &lt;a href=&quot;http://en.wikipedia.org/wiki/Statistical_classification&quot; title=&quot;Statistical classification&quot;&gt;classifying&lt;/a&gt; objects based on closest training examples in the &lt;a href=&quot;http://en.wikipedia.org/wiki/Feature_space&quot; title=&quot;Feature space&quot;&gt;feature space&lt;/a&gt;. &lt;i&gt;k&lt;/i&gt;-NN is a type of &lt;a href=&quot;http://en.wikipedia.org/wiki/Instance-based_learning&quot; title=&quot;Instance-based learning&quot;&gt;instance-based learning&lt;/a&gt;, or &lt;a href=&quot;http://en.wikipedia.org/wiki/Lazy_learning&quot; title=&quot;Lazy learning&quot;&gt;lazy learning&lt;/a&gt; where the function is only approximated locally and all computation is deferred until classification. The &lt;i&gt;k&lt;/i&gt;-nearest neighbor algorithm is amongst the simplest of all &lt;a href=&quot;http://en.wikipedia.org/wiki/Machine_learning&quot; title=&quot;Machine learning&quot;&gt;machine learning&lt;/a&gt;  algorithms: an object is classified by a majority vote of its  neighbors, with the object being assigned to the class most common  amongst its &lt;i&gt;k&lt;/i&gt; nearest neighbors (&lt;i&gt;k&lt;/i&gt; is a positive &lt;a href=&quot;http://en.wikipedia.org/wiki/Integer&quot; title=&quot;Integer&quot;&gt;integer&lt;/a&gt;, typically small). If &lt;i&gt;k&lt;/i&gt; = 1, then the object is simply assigned to the class of its nearest neighbor.&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;k&lt;/i&gt;-NN algorithm can also be adapted for use in estimating  continuous variables. One such implementation uses an inverse distance  weighted average of the &lt;i&gt;k&lt;/i&gt;-nearest multivariate neighbors. This algorithm functions as follows:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Compute Euclidean or &lt;a href=&quot;http://en.wikipedia.org/wiki/Mahalanobis_distance&quot; title=&quot;Mahalanobis distance&quot;&gt;Mahalanobis distance&lt;/a&gt; from target plot to those that were sampled.&lt;/li&gt;
&lt;li&gt;Order samples taking for account calculated distances.&lt;/li&gt;
&lt;li&gt;Choose heuristically optimal &lt;i&gt;k&lt;/i&gt; nearest neighbor based on &lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/RMSE&quot; title=&quot;RMSE&quot;&gt;RMSE&lt;/a&gt; done by cross validation technique.&lt;/li&gt;
&lt;li&gt;Calculate an inverse distance weighted average with the &lt;i&gt;k&lt;/i&gt;-nearest multivariate neighbors.&lt;/li&gt;
&lt;/ol&gt;Using a weighted k-NN also significantly improves the results: the  class (or value, in regression problems) of each of the k nearest points  is multiplied by a weight proportional to the inverse of the distance  between that point and the point for which the class is to be predicted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;class atsKNN{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;public :&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void knn(cv::Mat&amp;amp; trainingData, cv::Mat&amp;amp; trainingClasses, cv::Mat&amp;amp; testData, cv::Mat&amp;amp; testClasses, int K) &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::KNearest knn(trainingData, trainingClasses, cv::Mat(), false, K);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat predicted(testClasses.rows, 1, CV_32F);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i = 0; i &amp;lt; testData.rows; i++) {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; const cv::Mat sample = testData.row(i);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; predicted.at&amp;lt;float&amp;gt;(i,0) = knn.find_nearest(sample, K);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; float percentage = evaluate(predicted, testClasses) * 100;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; &quot;K Nearest Neighbor Evaluated Accuracy = &quot; &amp;lt;&amp;lt; percentage &amp;lt;&amp;lt; &quot;%&quot; &amp;lt;&amp;lt; endl;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; prediction = predicted;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void showplot(cv::Mat testData)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; plot_binary(testData, prediction, &quot;Predictions Backpropagation&quot;);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;private:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat prediction;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
the simplicity of the algorithm in classifying things requires you to provide alot of training samples to ensure lots of vectors are created within K. therefore it is not optimized for speed and space. in addition to consuming alot of memory it is really slow.</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/2250536161347304009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-k-nearest.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2250536161347304009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2250536161347304009'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-k-nearest.html' title='Artificial Intelligence (K Nearest Neighbor) in OPENCV'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-5971681042405083476</id><published>2011-07-12T19:39:00.000-07:00</published><updated>2011-07-12T19:39:51.867-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="support vector machine"/><category scheme="http://www.blogger.com/atom/ns#" term="support vector machine (SVM)"/><category scheme="http://www.blogger.com/atom/ns#" term="svm"/><title type='text'>Artificial Intelligence (support vector machine (SVM)) in OPENCV</title><content type='html'>A &lt;b&gt;support vector machine&lt;/b&gt; (&lt;b&gt;SVM&lt;/b&gt;) is a concept in &lt;a href=&quot;http://en.wikipedia.org/wiki/Computer_science&quot; title=&quot;Computer science&quot;&gt;computer science&lt;/a&gt; for a set of related &lt;a href=&quot;http://en.wikipedia.org/wiki/Supervised_learning&quot; title=&quot;Supervised learning&quot;&gt;supervised learning&lt;/a&gt; methods that analyze data and recognize patterns, used for &lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Classification_%28machine_learning%29&quot; title=&quot;Classification (machine learning)&quot;&gt;classification&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Regression_analysis&quot; title=&quot;Regression analysis&quot;&gt;regression analysis&lt;/a&gt;.  The standard SVM takes a set of input data and predicts, for each given  input, which of two possible classes the input is a member of, which  makes the SVM a non-&lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Probabilistic&quot; title=&quot;Probabilistic&quot;&gt;probabilistic&lt;/a&gt; &lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Binary_classifier&quot; title=&quot;Binary classifier&quot;&gt;binary&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Linear_classifier&quot; title=&quot;Linear classifier&quot;&gt;linear classifier&lt;/a&gt;.  Given a set of training examples, each marked as belonging to one of  two categories, an SVM training algorithm builds a model that assigns  new examples into one category or the other. An SVM model is a  representation of the examples as points in space, mapped so that the  examples of the separate categories are divided by a clear gap that is  as wide as possible. New examples are then mapped into that same space  and predicted to belong to a category based on which side of the gap  they fall on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzGHz3jyIsmXIgbN7ddYYMhnOPzQ5lmJ8NESZmpn_KpcNFXWIzDYn9EvrjbAGC12sglSK2XGNx0o1rBB3GeRvX2if8pabkXYJcaW1t4L-IgcY8c6QeJ6DOt96Zhzzoj381XYeJRhjay0M/s1600/ScreenShot311.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;156&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzGHz3jyIsmXIgbN7ddYYMhnOPzQ5lmJ8NESZmpn_KpcNFXWIzDYn9EvrjbAGC12sglSK2XGNx0o1rBB3GeRvX2if8pabkXYJcaW1t4L-IgcY8c6QeJ6DOt96Zhzzoj381XYeJRhjay0M/s320/ScreenShot311.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;standard14&quot;&gt;A Support Vector Machine (SVM) performs classification by constructing an &lt;i&gt;N&lt;/i&gt;-dimensional hyperplane that optimally separates the data into two categories. SVM models are closely related to neural networks. In fact, a SVM model using a sigmoid kernel function is equivalent to a two-layer, perceptron neural network.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;standard14&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;standard14&quot;&gt;The accuracy of an SVM model is largely dependent on the selection of the model parameters.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDiJRk5mkbZVRpAEXLPgfuB-ZfCoOWY8Csq9Ua0hi60rwIp8am9whqHXPW4jqtylseeikNDABJJ-K2XccEOw2HbLLA3yH9tbw5yiCi8tIOSJMWwQR0TJ0-LohyphenhyphenJacKHk1XF_szy-13FMWk/s1600/ScreenShot312.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;220&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDiJRk5mkbZVRpAEXLPgfuB-ZfCoOWY8Csq9Ua0hi60rwIp8am9whqHXPW4jqtylseeikNDABJJ-K2XccEOw2HbLLA3yH9tbw5yiCi8tIOSJMWwQR0TJ0-LohyphenhyphenJacKHk1XF_szy-13FMWk/s320/ScreenShot312.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;&lt;span class=&quot;standard14&quot;&gt;In the parlance of SVM literature, a predictor variable is called an &lt;i&gt;attribute&lt;/i&gt;, and a transformed attribute that is used to define the hyperplane is called a &lt;i&gt;feature&lt;/i&gt;.  The task of choosing the most suitable representation is known as &lt;i&gt;feature selection&lt;/i&gt;. A set of features that describes one case (i.e., a row of predictor values) is called a &lt;i&gt;vector&lt;/i&gt;. So the goal of SVM modeling is to find the optimal hyperplane that separates clusters of vector in such a way that cases with one category of the target variable are on one side of the plane and cases with the other category are on the other size of the plane. The vectors near the hyperplane are the &lt;i&gt;support vectors&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span class=&quot;standard14&quot; style=&quot;font-size: xx-small;&quot;&gt;#include&amp;lt;opencv2/ml/ml.hpp&amp;gt;&lt;br /&gt;
class atsSVM&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void svm(cv::Mat&amp;amp; trainingData, cv::Mat&amp;amp; trainingClasses, cv::Mat&amp;amp; testData, cv::Mat&amp;amp; testClasses) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //SVM Parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CvSVMParams param = CvSVMParams();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.svm_type = CvSVM::C_SVC;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.kernel_type = CvSVM::RBF; //CvSVM::RBF, CvSVM::LINEAR ...&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.degree = 0; // for poly&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.gamma = 20; // for poly/rbf/sigmoid&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.coef0 = 0; // for poly/sigmoid&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.C = 7; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.nu = 0.0; // for CV_SVM_NU_SVC, CV_SVM_ONE_CLASS, and CV_SVM_NU_SVR&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.p = 0.0; // for CV_SVM_EPS_SVR&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.class_weights = NULL; // for CV_SVM_C_SVC&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.term_crit.type = CV_TERMCRIT_ITER +CV_TERMCRIT_EPS;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.term_crit.max_iter = 1000;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;param.term_crit.epsilon = 1e-6;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// SVM training (use train auto for OpenCV&amp;gt;=2.0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvSVM svm(trainingData, trainingClasses, cv::Mat(), cv::Mat(), param);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat predicted(testClasses.rows, 1, CV_32F);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; testData.rows; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat sample = testData.row(i);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float x = sample.at&amp;lt;float&amp;gt;(0,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float y = sample.at&amp;lt;float&amp;gt;(0,1);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;predicted.at&amp;lt;float&amp;gt;(i, 0) = svm.predict(sample);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float percentage = evaluate(predicted, testClasses) * 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;Support Vector Machine Evaluated Accuracy = &quot; &amp;lt;&amp;lt; percentage &amp;lt;&amp;lt; &quot;%&quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void showplot(cv::Mat testData)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;plot_binary(testData, prediction, &quot;Predictions SVM&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat prediction;&lt;br /&gt;
};&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;standard14&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:WordDocument&gt;   &lt;w:View&gt;Normal&lt;/w:View&gt;   &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:TrackMoves/&gt;   &lt;w:TrackFormatting/&gt;   &lt;w:PunctuationKerning/&gt;   &lt;w:ValidateAgainstSchemas/&gt;   &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:DoNotPromoteQF/&gt;   &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;   &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:Compatibility&gt;    &lt;w:BreakWrappedTables/&gt;    &lt;w:SnapToGridInCell/&gt;    &lt;w:WrapTextWithPunct/&gt;    &lt;w:UseAsianBreakRules/&gt;    &lt;w:DontGrowAutofit/&gt;    &lt;w:SplitPgBreakAndParaMark/&gt;    &lt;w:DontVertAlignCellWithSp/&gt;    &lt;w:DontBreakConstrainedForcedTables/&gt;    &lt;w:DontVertAlignInTxbx/&gt;    &lt;w:Word11KerningPairs/&gt;    &lt;w:CachedColBalance/&gt;    &lt;w:UseFELayout/&gt;   &lt;/w:Compatibility&gt;   &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;   &lt;m:mathPr&gt;    &lt;m:mathFont m:val=&quot;Cambria Math&quot;/&gt;    &lt;m:brkBin m:val=&quot;before&quot;/&gt;    &lt;m:brkBinSub m:val=&quot;&amp;#45;-&quot;/&gt;    &lt;m:smallFrac m:val=&quot;off&quot;/&gt;    &lt;m:dispDef/&gt;    &lt;m:lMargin m:val=&quot;0&quot;/&gt;    &lt;m:rMargin m:val=&quot;0&quot;/&gt;    &lt;m:defJc m:val=&quot;centerGroup&quot;/&gt;    &lt;m:wrapIndent m:val=&quot;1440&quot;/&gt;    &lt;m:intLim m:val=&quot;subSup&quot;/&gt;    &lt;m:naryLim m:val=&quot;undOvr&quot;/&gt;   &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:LatentStyles DefLockedState=&quot;false&quot; DefUnhideWhenUsed=&quot;true&quot;
  DefSemiHidden=&quot;true&quot; DefQFormat=&quot;false&quot; DefPriority=&quot;99&quot;
  LatentStyleCount=&quot;267&quot;&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;0&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Normal&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;heading 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 7&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 8&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 9&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 7&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 8&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 9&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;35&quot; QFormat=&quot;true&quot; Name=&quot;caption&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;10&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Title&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; Name=&quot;Default Paragraph Font&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;11&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtitle&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;22&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Strong&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;20&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;59&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Table Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Placeholder Text&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;No Spacing&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Revision&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;34&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;List Paragraph&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;29&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Quote&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;30&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Quote&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;19&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;21&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;31&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Reference&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;32&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Reference&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;33&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Book Title&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;37&quot; Name=&quot;Bibliography&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; QFormat=&quot;true&quot; Name=&quot;TOC Heading&quot;/&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin:0in;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:&quot;Times New Roman&quot;;
 mso-fareast-theme-font:minor-fareast;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:&quot;Times New Roman&quot;;
 mso-bidi-theme-font:minor-bidi;}
&lt;/style&gt; &lt;![endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;The major strengths of SVM are the training is relatively easy. No local optimal, unlike in neural networks. It scales relatively well to high dimensional data and the trade-off between classifier complexity and error can be controlled explicitly. The weakness includes the need for a good kernel function &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/5971681042405083476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-support-vector.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/5971681042405083476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/5971681042405083476'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-support-vector.html' title='Artificial Intelligence (support vector machine (SVM)) in OPENCV'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzGHz3jyIsmXIgbN7ddYYMhnOPzQ5lmJ8NESZmpn_KpcNFXWIzDYn9EvrjbAGC12sglSK2XGNx0o1rBB3GeRvX2if8pabkXYJcaW1t4L-IgcY8c6QeJ6DOt96Zhzzoj381XYeJRhjay0M/s72-c/ScreenShot311.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-2922277638870485995</id><published>2011-07-11T19:05:00.000-07:00</published><updated>2011-07-11T19:05:38.685-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ann"/><category scheme="http://www.blogger.com/atom/ns#" term="artificial neural network"/><category scheme="http://www.blogger.com/atom/ns#" term="backpropagation"/><category scheme="http://www.blogger.com/atom/ns#" term="mlp"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>Artificial Intelligence (Multilayered perceptrons) in OPENCV</title><content type='html'>Neural networks are models of biological neural structures. The starting point for most neural networks is a model neuron. Each input is modified by a &lt;i&gt;weight&lt;/i&gt;, which multiplies with the input value.  The neuron will combine these weighted inputs and, with reference to a threshold value and activation function, use these to determine its output.  This behavior follows closely our understanding of how real neurons work.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Neural neworks are typically organized in layers. Layers are made up of a  number of interconnected &#39;nodes&#39; which contain an &#39;activation  function&#39;. Patterns are presented to the network via the &#39;input layer&#39;,  which communicates to one or more &#39;hidden layers&#39; where the actual processing is done via a system of weighted  &#39;connections&#39;.  The hidden layers then link to an &#39;output layer&#39; where  the answer is output as shown in the graphic below.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS-s0OJw1PDWfsnv7b8rbhaC3RgZ259r8nVqbrGx-ASb3PEQZ7VkVjukGNSrTdX9rQnWShtEM9sKrLp2U34xltdqxI5Vb-cegry7rxe5l62qaguw-la7TdA5-HiwYdo4SCM23G3_k-6c4Z/s1600/ScreenShot306.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS-s0OJw1PDWfsnv7b8rbhaC3RgZ259r8nVqbrGx-ASb3PEQZ7VkVjukGNSrTdX9rQnWShtEM9sKrLp2U34xltdqxI5Vb-cegry7rxe5l62qaguw-la7TdA5-HiwYdo4SCM23G3_k-6c4Z/s320/ScreenShot306.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&amp;nbsp;&lt;b&gt;Backpropagation&lt;/b&gt; is a common method of teaching &lt;a href=&quot;http://en.wikipedia.org/wiki/Artificial_neural_network&quot; title=&quot;Artificial neural network&quot;&gt;artificial neural networks&lt;/a&gt; how to perform a given task.&lt;br /&gt;
&amp;nbsp;It is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Supervised_learning&quot; title=&quot;Supervised learning&quot;&gt;supervised learning&lt;/a&gt; method, and is a generalization of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Delta_rule&quot; title=&quot;Delta rule&quot;&gt;delta rule&lt;/a&gt;.  It requires a teacher that knows, or can calculate, the desired output  for any input in the training set. It is most useful for feed-forward  networks (networks that have no feedback, or simply, that have no  connections that loop). The term is an abbreviation for &quot;backward  propagation of errors&quot;. Backpropagation requires that the &lt;a href=&quot;http://en.wikipedia.org/wiki/Activation_function&quot; title=&quot;Activation function&quot;&gt;activation function&lt;/a&gt; used by the &lt;a href=&quot;http://en.wikipedia.org/wiki/Artificial_neuron&quot; title=&quot;Artificial neuron&quot;&gt;artificial neurons&lt;/a&gt; (or &quot;nodes&quot;) be &lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/Differentiable&quot; title=&quot;Differentiable&quot;&gt;differentiable&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The Steps &lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;1. Initilaize weights with random values&lt;br /&gt;
2. Present the input vector to the network&lt;br /&gt;
3. Evaluate the output of the network after a forward propagation of the signal&lt;/div&gt;&lt;pre style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;4.Calculate error (T - O) at the output units&lt;/pre&gt;&lt;pre style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;5.Compute delta_wh for all weights from hidden layer to output layer ; backward pass&lt;/pre&gt;&lt;pre style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;6.Compute delta_wi for all weights from input layer to hidden layer ; backward pass continued&lt;/pre&gt;&lt;div style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;7. Update weights&amp;nbsp;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;&quot;&gt;8. Termination Criteria. Goto Step 2 for a  xed number of iterations or an error. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;#include&amp;lt;opencv2/ml/ml.hpp&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; class atsANN&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void atstraineval(cv::Mat trainingData, cv::Mat trainingClasses, cv::Mat testData, cv::Mat testClasses) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat layers = cv::Mat(4, 1, CV_32SC1); //create 4 layers&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(0) = cv::Scalar(2); //input layer accepts x and y&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(1) = cv::Scalar(10);//hidden layer&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(2) = cv::Scalar(15);//hidden layer&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(3) = cv::Scalar(1); //output layer returns 1 or -1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Create the ANN&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvANN_MLP ann;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//ANN criteria for termination&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvTermCriteria criter;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.max_iter = 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.epsilon = 0.00001f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.type = CV_TERMCRIT_ITER | CV_TERMCRIT_EPS;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//ANN parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvANN_MLP_TrainParams params;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.train_method = CvANN_MLP_TrainParams::BACKPROP;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.bp_dw_scale = 0.05f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.bp_moment_scale = 0.05f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.term_crit = criter; //termination criteria&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.create(layers);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// train&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.train(trainingData, trainingClasses, cv::Mat(), cv::Mat(), params);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat response(1, 1, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat predicted(testClasses.rows, 1, CV_32F);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; testData.rows; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat response(1, 1, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat sample = testData.row(i);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.predict(sample, response);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;predicted.at&amp;lt;float&amp;gt;(i,0) = response.at&amp;lt;float&amp;gt;(0,0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float percentage = evaluate(predicted, testClasses) * 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;Artificial Neural Network Evaluated Accuracy = &quot; &amp;lt;&amp;lt; percentage &amp;lt;&amp;lt; &quot;%&quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;prediction = predicted;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void showplot(cv::Mat testData)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;plot_binary(testData, prediction, &quot;Predictions Backpropagation&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat prediction;&lt;br /&gt;
};&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&amp;nbsp;There are many advantages and limitations to neural network analysis and  to discuss this subject properly we would have to look at each  individual type of network, which isn&#39;t necessary for this general  discussion.  In reference to backpropagational networks however, there  are some specific issues potential users should be aware of.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt; Backpropagational neural networks (and many other types of  networks) are in a sense the ultimate &#39;black boxes&#39;.  Apart from defining the general  archetecture of a network and perhaps initially seeding it with a random  numbers, the user has no other role than to feed it input and watch it  train and await the output.  In fact, it has been said that with  backpropagation, &quot;you almost don&#39;t know what you&#39;re doing&quot;.  Some  software freely available software packages (NevProp, bp, Mactivation)  do allow the user to sample the networks &#39;progress&#39; at regular time  intervals, but the learning itself progresses on its own.  The final  product of this activity is a trained network that provides no   equations or coefficients defining a relationship (as in regression)  beyond it&#39;s own internal mathematics.  The network &#39;IS&#39; the final  equation of the relationship.  &lt;/li&gt;
&lt;li&gt; Backpropagational networks also tend to be slower to train  than other types of networks and sometimes require thousands of epochs.   If run on a truly parallel computer system this issue is not really a  problem, but if the BPNN is being simulated on a standard serial machine  (i.e. a single SPARC, Mac or PC) training can take some time.  This is  because the machines CPU must compute the function of each node and  connection separately, which can be problematic in very large networks  with a large amount of data.  However, the speed of most current  machines is such that this is typically not much of an issue.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;opencv2/core/core.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//required for multilayer perceptrons&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;#include&amp;lt;opencv2/ml/ml.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
using namespace cv;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
#define numTrainingPoints 200&lt;br /&gt;
#define numTestPoints 2000&lt;br /&gt;
#define size 200&lt;br /&gt;
&lt;br /&gt;
// accuracy&lt;br /&gt;
float evaluate(cv::Mat&amp;amp; predicted, cv::Mat&amp;amp; actual) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;assert(predicted.rows == actual.rows);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int t = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;int f = 0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; actual.rows; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float p = predicted.at&amp;lt;float&amp;gt;(i,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float a = actual.at&amp;lt;float&amp;gt;(i,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if((p &amp;gt;= 0.0 &amp;amp;&amp;amp; a &amp;gt;= 0.0) || (p &amp;lt;= 0.0 &amp;amp;&amp;amp;&amp;nbsp; a &amp;lt;= 0.0)) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;t++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;} else {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;f++;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return (t * 1.0) / (t + f);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// plot data and class&lt;br /&gt;
void plot_binary(cv::Mat&amp;amp; data, cv::Mat&amp;amp; classes, string name) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat plot(size, size, CV_8UC3);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;plot.setTo(CV_RGB(255,255,255));&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; data.rows; i++) {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float x = data.at&amp;lt;float&amp;gt;(i,0) * size;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float y = data.at&amp;lt;float&amp;gt;(i,1) * size;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(classes.at&amp;lt;float&amp;gt;(i, 0) &amp;gt; 0) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::circle(plot, Point(x,y), 2, CV_RGB(255,0,0),1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;} else {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::circle(plot, Point(x,y), 2, CV_RGB(0,255,0),1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::imshow(name, plot);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// function to learn&lt;br /&gt;
int dataLearn(float x, float y) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return y &amp;gt; atan(y/x) ? -1 : 1;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// label data with equation&lt;br /&gt;
cv::Mat labelData(cv::Mat points) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat labels(points.rows, 1, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; points.rows; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; float x = points.at&amp;lt;float&amp;gt;(i,0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; float y = points.at&amp;lt;float&amp;gt;(i,1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; labels.at&amp;lt;float&amp;gt;(i, 0) = dataLearn(x, y);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return labels;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class atsANN&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void atstraineval(cv::Mat trainingData, cv::Mat trainingClasses, cv::Mat testData, cv::Mat testClasses) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat layers = cv::Mat(4, 1, CV_32SC1); //create 4 layers&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(0) = cv::Scalar(2); //input layer accepts x and y&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(1) = cv::Scalar(10);//hidden layer&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(2) = cv::Scalar(15);//hidden layer&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;layers.row(3) = cv::Scalar(1); //output layer returns 1 or -1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//Create the ANN&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvANN_MLP ann;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//ANN criteria for termination&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvTermCriteria criter;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.max_iter = 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.epsilon = 0.00001f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;criter.type = CV_TERMCRIT_ITER | CV_TERMCRIT_EPS;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//ANN parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;CvANN_MLP_TrainParams params;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.train_method = CvANN_MLP_TrainParams::BACKPROP;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.bp_dw_scale = 0.05f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.bp_moment_scale = 0.05f;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;params.term_crit = criter; //termination criteria&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.create(layers);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// train&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.train(trainingData, trainingClasses, cv::Mat(), cv::Mat(), params);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat response(1, 1, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat predicted(testClasses.rows, 1, CV_32F);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; testData.rows; i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat response(1, 1, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat sample = testData.row(i);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ann.predict(sample, response);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;predicted.at&amp;lt;float&amp;gt;(i,0) = response.at&amp;lt;float&amp;gt;(0,0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;float percentage = evaluate(predicted, testClasses) * 100;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; &quot;Artificial Neural Network Evaluated Accuracy = &quot; &amp;lt;&amp;lt; percentage &amp;lt;&amp;lt; &quot;%&quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;prediction = predicted;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;void showplot(cv::Mat testData)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;plot_binary(testData, prediction, &quot;Predictions Backpropagation&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat prediction;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat trainingData(numTrainingPoints, 2, CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat testData(numTestPoints, 2, CV_32FC1);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::randu(trainingData,0,1); //generate uniformly-distributed random numbers from the range [low, high)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::randu(testData,0,1);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat trainingClasses = labelData(trainingData);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::Mat testClasses = labelData(testData);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;plot_binary(trainingData, trainingClasses, &quot;Plot of Training Data&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;plot_binary(testData, testClasses, &quot;Plot ofTest Data&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;atsANN myANN;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;myANN.atstraineval(trainingData,trainingClasses,testData,testClasses);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;myANN.showplot(testData);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;cv::waitKey();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/2922277638870485995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-multilayered.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2922277638870485995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2922277638870485995'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/artificial-intelligence-multilayered.html' title='Artificial Intelligence (Multilayered perceptrons) in OPENCV'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS-s0OJw1PDWfsnv7b8rbhaC3RgZ259r8nVqbrGx-ASb3PEQZ7VkVjukGNSrTdX9rQnWShtEM9sKrLp2U34xltdqxI5Vb-cegry7rxe5l62qaguw-la7TdA5-HiwYdo4SCM23G3_k-6c4Z/s72-c/ScreenShot306.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-514015691353779302</id><published>2011-07-06T02:09:00.000-07:00</published><updated>2011-07-06T02:09:59.126-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="camera"/><category scheme="http://www.blogger.com/atom/ns#" term="live camera"/><category scheme="http://www.blogger.com/atom/ns#" term="logpolar transform"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>OPENCV2 C++ basics (OOP) old style vs new style</title><content type='html'>Version 2.2 of the opencv library has divided its library into modules.&lt;br /&gt;
These library modules have their own associated header files which is required therefore any code you see on the internet that looks like this:&lt;br /&gt;
#include &quot;cv.h&quot;&lt;br /&gt;
#include &amp;lt;cv.h&amp;gt; and so on&lt;br /&gt;
is done using the old style, C or C++. However after the restructuring of the opencv library into modules, not all functionality was ported to the new style:&lt;br /&gt;
#include &amp;lt;opencv2/core/core.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
one example of such method is the LOGPOLAR transform.&lt;br /&gt;
Another thing to take note here is, the old deprecated IplImage is changed to the matrix cv::Mat. therefore you should avoid using such unless your using the old style.&lt;br /&gt;
&lt;br /&gt;
For the Log-Polar Transform i will be using this header file:&lt;br /&gt;
#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to make things easy, ive created a class to convert between cv::Mat and IplImage&lt;br /&gt;
&lt;blockquote style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;class atsoldtonew&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage convertOld(cv::Mat MatImage)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage img =MatImage;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return img;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat convertNew(IplImage *iplImage)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat imgMat(iplImage);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return imgMat;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
private:&lt;br /&gt;
};&lt;/blockquote&gt;&lt;br /&gt;
So the Log-Polar Class is the following:&lt;br /&gt;
&lt;blockquote&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;class atslogPolar&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;public:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void convert(cv::Mat image)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage src;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage img =image;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* newsrc = &amp;amp;img;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* dst = cvCreateImage( cvGetSize(newsrc), 8, 3&amp;nbsp; );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* dst2 = cvCreateImage( cvGetSize(newsrc), 8, 3&amp;nbsp; );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvLogPolar( newsrc, dst, cvPoint2D32f(image.size().width/2,image.size().height/2), 40,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvLogPolar( dst, dst2, cvPoint2D32f(image.size().width/2,image.size().height/2), 40,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newIm = dst;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; newImage = dst2;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void view()&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvShowImage( &quot;inverse log-polar&quot;, newIm );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvShowImage( &quot;reinverse log-polar&quot;, newImage );&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* logpolar()&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return newIm; //return the local variable&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* Inverselogpolar()&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return newImage; //return the local variable&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;private:&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* newIm; //keep a local variable&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IplImage* newImage; //keep a local variable&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;};&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
This Class uses the old style however by converting to and from cv::Mat to IplImage your main function can be written as the following&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/core/core.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt; &lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;int main()&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; atscameraCapture mine; //initialize&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat image = mine.ats_getImage(); &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::imshow(&quot;image&quot;,image); //CAMERA IMAGE&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; atslogPolar pl;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pl.convert(image);&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pl.view();&amp;nbsp;&amp;nbsp; //show using the old style&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; atsoldtonew conv;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::imshow(&quot;image logpolar&quot;,conv.convertNew(pl.logpolar()));&amp;nbsp; //show using the new style&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(cv::waitKey(30) &amp;gt;= 0) break;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&lt;/span&gt;&lt;/blockquote&gt;You can easily add the class to my previous Post code to add the new added functionality</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/514015691353779302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/opencv2-c-basics-oop-old-style-vs-new.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/514015691353779302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/514015691353779302'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/opencv2-c-basics-oop-old-style-vs-new.html' title='OPENCV2 C++ basics (OOP) old style vs new style'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-853357492467080977</id><published>2011-07-05T19:46:00.000-07:00</published><updated>2011-07-05T19:46:53.238-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="camera"/><category scheme="http://www.blogger.com/atom/ns#" term="canny"/><category scheme="http://www.blogger.com/atom/ns#" term="edge detection"/><category scheme="http://www.blogger.com/atom/ns#" term="live camera"/><category scheme="http://www.blogger.com/atom/ns#" term="OOP"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>OPENCV2 C++ basics (OOP) edge detection using CANNY</title><content type='html'>if you have an OK background on C++ you can follow easily:&lt;br /&gt;
&lt;br /&gt;
ive seperated the camera capturing and the edge detection to separate classes.&lt;br /&gt;
the main entry point remains the same.&lt;br /&gt;
you can use the code to add a new class to process images using the atscameraCapture class.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/core/core.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//for atsEdges&lt;br /&gt;
#include &amp;lt;opencv2/imgproc/imgproc.hpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class atscameraCapture&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat ats_getImage()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //check if Camera is still open&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (!cap.isOpened())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; std::cout&amp;lt; &quot;Cant Capture&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exit(0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //camera is open so get a frame&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat frame;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cap&amp;gt;&amp;gt; frame;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //return the frame&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return frame;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atscameraCapture()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //create a camera capture and assign it to a local private variable&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::VideoCapture capture(0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cap = capture;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
private:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::VideoCapture cap;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class atsEdges&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat getEdges(cv::Mat image)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat edges;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cvtColor(image,edges,CV_BGR2GRAY); //convert from RGB color space to GRAY&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Canny(edges,edges,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; // double threshold1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 30,&amp;nbsp;&amp;nbsp;&amp;nbsp; //double threshold2&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 3); //int apertureSize=3, bool L2gradient=false)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return edges;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
private:&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; atscameraCapture mine; //initialize&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::Mat image = mine.ats_getImage();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::imshow(&quot;image&quot;,image);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; atsEdges pl;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cv::imshow(&quot;pl image&quot;,pl.getEdges(image));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(cv::waitKey(30) &amp;gt;= 0) break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/853357492467080977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/opencv2-c-basics-oop-edge-detection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/853357492467080977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/853357492467080977'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/opencv2-c-basics-oop-edge-detection.html' title='OPENCV2 C++ basics (OOP) edge detection using CANNY'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-2981841579791842249</id><published>2011-07-03T21:28:00.000-07:00</published><updated>2011-07-03T21:28:38.449-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="haar"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="Viola and jones"/><title type='text'>build a cascade of boosted classifiers based on Haar-like features</title><content type='html'>Step 1 -&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tools Needed:&lt;br /&gt;
You can find these executables as part of the opencv default installation. they are located in the BIN folder&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiafxrl4R_h-HxAoUgMhXR4rBkNv9Iqa05fAmlQg0gsdP9TP50A1Ir38mtpWM9J_NNMs4_XsmbdZywiBWz9MHmqFuPirVZcMCUxzhudKPIOBTVCWoDg65Rcq_ZMUhcnCH_yw2GgzLmC_5-s/s1600/ScreenShot302.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;118&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiafxrl4R_h-HxAoUgMhXR4rBkNv9Iqa05fAmlQg0gsdP9TP50A1Ir38mtpWM9J_NNMs4_XsmbdZywiBWz9MHmqFuPirVZcMCUxzhudKPIOBTVCWoDg65Rcq_ZMUhcnCH_yw2GgzLmC_5-s/s320/ScreenShot302.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Samples:&lt;br /&gt;
you should have alot of positive and negative images.&lt;br /&gt;
Take note that compressed images such as jpeg have certain issues therefore selecting a BMP image is recommended.&lt;br /&gt;
&lt;br /&gt;
Create folders for the Negative and Positive images and include an info file aswell&lt;br /&gt;
&lt;br /&gt;
Basically there should be four sets of images that you work on:&lt;br /&gt;
- a positive sample set representing your object that you want to train&lt;br /&gt;
- another positive sample set for testing purpose&lt;br /&gt;
- a negative sample set (or so-called backgrounds) for training&lt;br /&gt;
- and another negative sample set for testing, too&lt;br /&gt;
&lt;br /&gt;
so your 2 folders containing the images are:&lt;br /&gt;
/opencv/project/negative&lt;br /&gt;
/opencv/project/positive&lt;br /&gt;
as well as the info file:&lt;br /&gt;
-train.txt&lt;br /&gt;
-test.txt&lt;br /&gt;
&lt;br /&gt;
To work with these images in the utilities, a list of the files is needed. Using Win32 as host OS,&lt;br /&gt;
you can get the list via command promt. Move to the folder where the info file will be stored and&lt;br /&gt;
type “dir /b /s &amp;gt; infofile.txt”. Open “infofile.txt” and make the paths relative to the&lt;br /&gt;
info file (i.e. find “C:\Temp\negatives\” and replace with “”).&lt;br /&gt;
&lt;br /&gt;
Step 2 - Test Creation&lt;br /&gt;
Once your done preparing you need to create a vec-file in the data folder. This is done by createsamples.exe by calling:&lt;br /&gt;
&lt;blockquote style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;opencv_createsamples.exe -info positives/train.txt -vec data/positives.vec -num 1300 -w 20 –h 20&lt;/span&gt;&lt;/blockquote&gt;the numbers show 1300 samples with a width and height of 20&lt;br /&gt;
double check if the vec file really contains the desired images.&lt;br /&gt;
&lt;br /&gt;
Step 3 Training&lt;br /&gt;
Im assuming the following the default values of hitrate (0.995), maxfalsealarm (0.5), weighttrimming (0.95) and boosting type (GAB, “Gentle Ada Boost”) are good in most cases we use the following call:&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;haartraining.exe -data data/cascade -vec data/positives.vec -bg negatives/train.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;-npos 1300 -nneg 5000 -nstages 30 -mem 1300 -mode ALL -w 20 -h 20&lt;/span&gt;&lt;/blockquote&gt;&lt;div style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; &lt;/div&gt;- 1300 positive images&lt;br /&gt;
- 5000 negative images&lt;br /&gt;
- 30 stages&lt;br /&gt;
- 1300 MB of RAM&lt;br /&gt;
&lt;br /&gt;
Step 4 Testing&lt;br /&gt;
&lt;br /&gt;
the test of hitrate and falsealarm will be done by calling&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;performance.exe -data data/cascade -info positives/testing/testing.txt -w 20 -h 20 -rs 30&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
Thats it, tell me how it goes.,,,</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/2981841579791842249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2011/07/build-cascade-of-boosted-classifiers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2981841579791842249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/2981841579791842249'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2011/07/build-cascade-of-boosted-classifiers.html' title='build a cascade of boosted classifiers based on Haar-like features'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiafxrl4R_h-HxAoUgMhXR4rBkNv9Iqa05fAmlQg0gsdP9TP50A1Ir38mtpWM9J_NNMs4_XsmbdZywiBWz9MHmqFuPirVZcMCUxzhudKPIOBTVCWoDg65Rcq_ZMUhcnCH_yw2GgzLmC_5-s/s72-c/ScreenShot302.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-3455808738676715573</id><published>2010-12-29T18:37:00.000-08:00</published><updated>2010-12-29T19:56:57.515-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Affine Transform"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="Perspective transform"/><category scheme="http://www.blogger.com/atom/ns#" term="SURF"/><title type='text'>Affine VS Perspective Transformation using CAMERA</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh8JBA__0l-TCFHr-vqMK03KL5TajwcLoslny1GHMWeQCIJ-0w91N7znBwzL3336X3PF-kN7gNDeLrPvD5tBbKjJHV1MDnA7ylT1Ft4aUWokIRUmiWXNBYo5bVgwYJ26Y0-6wLPC7MDokH/s1600/perspectiveVSaffine.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;157&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh8JBA__0l-TCFHr-vqMK03KL5TajwcLoslny1GHMWeQCIJ-0w91N7znBwzL3336X3PF-kN7gNDeLrPvD5tBbKjJHV1MDnA7ylT1Ft4aUWokIRUmiWXNBYo5bVgwYJ26Y0-6wLPC7MDokH/s400/perspectiveVSaffine.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dxl7BIVEMatR7Aa1bMbjFAWAoBSXRY2GVI2uTmv1F5a-hWYsTjBr-cI5UbG1sFXFf7uWThkWs6p2zUAQKHapg&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;I have used OpenCV&#39;s AFFINE and PERSPECTIVE transform to WARP the images. &lt;br /&gt;
this same process can be done using HARRIS and RANSAC&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/objdetect/objdetect.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/features2d/features2d.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/calib3d/calib3d.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;&lt;br /&gt;
#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;void PrintMatrix ( CvMat *Matrix , char * name )&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;printf (&quot;%s\n&quot;, name );&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;for ( int i=0;i&amp;lt;Matrix -&amp;gt; rows ;i++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; for ( int j =0;j&amp;lt; Matrix -&amp;gt; cols ;j ++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;printf (&quot; %.3f\t&quot;,cvGet2D ( Matrix ,i,j).val [0]) ;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; printf (&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;printf (&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
// define whether to use approximate nearest-neighbor search&lt;br /&gt;
#define USE_FLANN&lt;br /&gt;
IplImage *image = 0;&lt;br /&gt;
double compareSURFDescriptors( const float* d1, const float* d2, double best, int length )&lt;br /&gt;
{&lt;br /&gt;
double total_cost = 0;&lt;br /&gt;
assert( length % 4 == 0 );&lt;br /&gt;
for( int i = 0; i &amp;lt; length; i += 4 )&lt;br /&gt;
{&lt;br /&gt;
double t0 = d1[i] - d2[i];&lt;br /&gt;
double t1 = d1[i+1] - d2[i+1];&lt;br /&gt;
double t2 = d1[i+2] - d2[i+2];&lt;br /&gt;
double t3 = d1[i+3] - d2[i+3];&lt;br /&gt;
total_cost += t0*t0 + t1*t1 + t2*t2 + t3*t3;&lt;br /&gt;
if( total_cost &amp;gt; best )&lt;br /&gt;
break;&lt;br /&gt;
}&lt;br /&gt;
return total_cost;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int naiveNearestNeighbor( const float* vec, int laplacian,&lt;br /&gt;
const CvSeq* model_keypoints,&lt;br /&gt;
const CvSeq* model_descriptors )&lt;br /&gt;
{&lt;br /&gt;
int length = (int)(model_descriptors-&amp;gt;elem_size/sizeof(float));&lt;br /&gt;
int i, neighbor = -1;&lt;br /&gt;
double d, dist1 = 1e6, dist2 = 1e6;&lt;br /&gt;
CvSeqReader reader, kreader;&lt;br /&gt;
cvStartReadSeq( model_keypoints, &amp;amp;kreader, 0 );&lt;br /&gt;
cvStartReadSeq( model_descriptors, &amp;amp;reader, 0 );&lt;br /&gt;
for( i = 0; i &amp;lt; model_descriptors-&amp;gt;total; i++ )&lt;br /&gt;
{&lt;br /&gt;
const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;&lt;br /&gt;
const float* mvec = (const float*)reader.ptr;&lt;br /&gt;
CV_NEXT_SEQ_ELEM( kreader.seq-&amp;gt;elem_size, kreader );&lt;br /&gt;
CV_NEXT_SEQ_ELEM( reader.seq-&amp;gt;elem_size, reader );&lt;br /&gt;
if( laplacian != kp-&amp;gt;laplacian )&lt;br /&gt;
continue;&lt;br /&gt;
d = compareSURFDescriptors( vec, mvec, dist2, length );&lt;br /&gt;
if( d &amp;lt; dist1 )&lt;br /&gt;
{&lt;br /&gt;
dist2 = dist1;&lt;br /&gt;
dist1 = d;&lt;br /&gt;
neighbor = i;&lt;br /&gt;
}&lt;br /&gt;
else if ( d &amp;lt; dist2 )&lt;br /&gt;
dist2 = d;&lt;br /&gt;
}&lt;br /&gt;
if ( dist1 &amp;lt; 0.6*dist2 )&lt;br /&gt;
return neighbor;&lt;br /&gt;
return -1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void findPairs( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors,&lt;br /&gt;
const CvSeq* imageKeypoints, const CvSeq* imageDescriptors, vector&amp;lt;int&amp;gt;&amp;amp; ptpairs )&lt;br /&gt;
{&lt;br /&gt;
int i;&lt;br /&gt;
CvSeqReader reader, kreader;&lt;br /&gt;
cvStartReadSeq( objectKeypoints, &amp;amp;kreader );&lt;br /&gt;
cvStartReadSeq( objectDescriptors, &amp;amp;reader );&lt;br /&gt;
ptpairs.clear();&lt;br /&gt;
&lt;br /&gt;
for( i = 0; i &amp;lt; objectDescriptors-&amp;gt;total; i++ )&lt;br /&gt;
{&lt;br /&gt;
const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;&lt;br /&gt;
const float* descriptor = (const float*)reader.ptr;&lt;br /&gt;
CV_NEXT_SEQ_ELEM( kreader.seq-&amp;gt;elem_size, kreader );&lt;br /&gt;
CV_NEXT_SEQ_ELEM( reader.seq-&amp;gt;elem_size, reader );&lt;br /&gt;
int nearest_neighbor = naiveNearestNeighbor( descriptor, kp-&amp;gt;laplacian, imageKeypoints, imageDescriptors );&lt;br /&gt;
&lt;br /&gt;
if( nearest_neighbor &amp;gt;= 0 )&lt;br /&gt;
{&lt;br /&gt;
ptpairs.push_back(i);&lt;br /&gt;
ptpairs.push_back(nearest_neighbor);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,&lt;br /&gt;
const CvSeq*, const CvSeq* imageDescriptors, vector&amp;lt;int&amp;gt;&amp;amp; ptpairs )&lt;br /&gt;
{&lt;br /&gt;
int length = (int)(objectDescriptors-&amp;gt;elem_size/sizeof(float));&lt;br /&gt;
cv::Mat m_object(objectDescriptors-&amp;gt;total, length, CV_32F);&lt;br /&gt;
cv::Mat m_image(imageDescriptors-&amp;gt;total, length, CV_32F);&lt;br /&gt;
&lt;br /&gt;
// copy descriptors&lt;br /&gt;
CvSeqReader obj_reader;&lt;br /&gt;
float* obj_ptr = m_object.ptr&amp;lt;float&amp;gt;(0);&lt;br /&gt;
cvStartReadSeq( objectDescriptors, &amp;amp;obj_reader );&lt;br /&gt;
for(int i = 0; i &amp;lt; objectDescriptors-&amp;gt;total; i++ )&lt;br /&gt;
{&lt;br /&gt;
const float* descriptor = (const float*)obj_reader.ptr;&lt;br /&gt;
CV_NEXT_SEQ_ELEM( obj_reader.seq-&amp;gt;elem_size, obj_reader );&lt;br /&gt;
memcpy(obj_ptr, descriptor, length*sizeof(float));&lt;br /&gt;
obj_ptr += length;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
CvSeqReader img_reader;&lt;br /&gt;
float* img_ptr = m_image.ptr&amp;lt;float&amp;gt;(0);&lt;br /&gt;
cvStartReadSeq( imageDescriptors, &amp;amp;img_reader );&lt;br /&gt;
for(int i = 0; i &amp;lt; imageDescriptors-&amp;gt;total; i++ )&lt;br /&gt;
{&lt;br /&gt;
const float* descriptor = (const float*)img_reader.ptr;&lt;br /&gt;
CV_NEXT_SEQ_ELEM( img_reader.seq-&amp;gt;elem_size, img_reader );&lt;br /&gt;
memcpy(img_ptr, descriptor, length*sizeof(float));&lt;br /&gt;
img_ptr += length;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// find nearest neighbors using FLANN&lt;br /&gt;
cv::Mat m_indices(objectDescriptors-&amp;gt;total, 2, CV_32S);&lt;br /&gt;
cv::Mat m_dists(objectDescriptors-&amp;gt;total, 2, CV_32F);&lt;br /&gt;
cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4)); // using 4 randomized kdtrees&lt;br /&gt;
&lt;br /&gt;
flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64) ); // maximum number of leafs checked&lt;br /&gt;
&lt;br /&gt;
int* indices_ptr = m_indices.ptr&amp;lt;int&amp;gt;(0);&lt;br /&gt;
float* dists_ptr = m_dists.ptr&amp;lt;float&amp;gt;(0);&lt;br /&gt;
for (int i=0;i&amp;lt;m_indices.rows;++i) {&lt;br /&gt;
if (dists_ptr[2*i]&amp;lt;0.6*dists_ptr[2*i+1]) {&lt;br /&gt;
ptpairs.push_back(i);&lt;br /&gt;
ptpairs.push_back(indices_ptr[2*i]);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* a rough implementation for object location */&lt;br /&gt;
int locatePlanarObject( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors,&lt;br /&gt;
const CvSeq* imageKeypoints, const CvSeq* imageDescriptors,&lt;br /&gt;
const CvPoint src_corners[4], CvPoint dst_corners[4] )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
double h[9];&lt;br /&gt;
CvMat _h = cvMat(3, 3, CV_64F, h);&lt;br /&gt;
vector&amp;lt;int&amp;gt; ptpairs;&lt;br /&gt;
vector&amp;lt;CvPoint2D32f&amp;gt; pt1, pt2;&lt;br /&gt;
CvMat _pt1, _pt2;&lt;br /&gt;
int i, n;&lt;br /&gt;
#ifdef USE_FLANN&lt;br /&gt;
flannFindPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );&lt;br /&gt;
#else&lt;br /&gt;
findPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
n = (int)(ptpairs.size()/2);&lt;br /&gt;
if( n &amp;lt; 4 )&lt;br /&gt;
return 0;&lt;br /&gt;
pt1.resize(n);&lt;br /&gt;
pt2.resize(n);&lt;br /&gt;
for( i = 0; i &amp;lt; n; i++ )&lt;br /&gt;
{&lt;br /&gt;
pt1[i] = ((CvSURFPoint*)cvGetSeqElem(objectKeypoints,ptpairs[i*2]))-&amp;gt;pt;&lt;br /&gt;
pt2[i] = ((CvSURFPoint*)cvGetSeqElem(imageKeypoints,ptpairs[i*2+1]))-&amp;gt;pt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
_pt1 = cvMat(1, n, CV_32FC2, &amp;amp;pt1[0] );&lt;br /&gt;
_pt2 = cvMat(1, n, CV_32FC2, &amp;amp;pt2[0] );&lt;br /&gt;
if( !cvFindHomography( &amp;amp;_pt1, &amp;amp;_pt2, &amp;amp;_h, CV_RANSAC, 5 ))&lt;br /&gt;
return 0;&lt;br /&gt;
&lt;br /&gt;
for( i = 0; i &amp;lt; 4; i++ )&lt;br /&gt;
{&lt;br /&gt;
double x = src_corners[i].x, y = src_corners[i].y;&lt;br /&gt;
double Z = 1./(h[6]*x + h[7]*y + h[8]);&lt;br /&gt;
double X = (h[0]*x + h[1]*y + h[2])*Z;&lt;br /&gt;
double Y = (h[3]*x + h[4]*y + h[5])*Z;&lt;br /&gt;
dst_corners[i] = cvPoint(cvRound(X), cvRound(Y));&lt;br /&gt;
}&lt;br /&gt;
return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char** argv)&lt;br /&gt;
{&lt;br /&gt;
CvCapture* capture = cvCreateCameraCapture(0);&lt;br /&gt;
CvMat* image = 0, *object = 0;&lt;br /&gt;
CvSeq *imageKeypoints = 0, *imageDescriptors = 0,*objectKeypoints = 0, *objectDescriptors = 0;&lt;br /&gt;
CvMemStorage* storage = cvCreateMemStorage(0);&lt;br /&gt;
int i;&lt;br /&gt;
static CvScalar colors[] =&lt;br /&gt;
{&lt;br /&gt;
{{0,0,255}},&lt;br /&gt;
{{0,128,255}},&lt;br /&gt;
{{0,255,255}},&lt;br /&gt;
{{0,255,0}},&lt;br /&gt;
{{255,128,0}},&lt;br /&gt;
{{255,255,0}},&lt;br /&gt;
{{255,0,0}},&lt;br /&gt;
{{255,0,255}},&lt;br /&gt;
{{255,255,255}}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
if( !capture )&lt;br /&gt;
return -1;&lt;br /&gt;
&lt;br /&gt;
for(;;)&lt;br /&gt;
{&lt;br /&gt;
int firstFrame = object == 0;&lt;br /&gt;
int percent = 50;&lt;br /&gt;
IplImage* source = cvQueryFrame(capture);&lt;br /&gt;
// declare a destination IplImage object with correct size, depth and channels&lt;br /&gt;
IplImage *frame = cvCreateImage&lt;br /&gt;
( cvSize((int)((source-&amp;gt;width*percent)/100) , (int)((source-&amp;gt;height*percent)/100) ),&lt;br /&gt;
source-&amp;gt;depth, source-&amp;gt;nChannels );&lt;br /&gt;
&lt;br /&gt;
//use cvResize to resize source to a destination image&lt;br /&gt;
cvResize(source, frame);&lt;br /&gt;
if(!frame)&lt;br /&gt;
break;&lt;br /&gt;
if(!object)&lt;br /&gt;
{&lt;br /&gt;
object = cvCreateMat(frame-&amp;gt;height, frame-&amp;gt;width, CV_8UC1);&lt;br /&gt;
image = cvCreateMat(object-&amp;gt;rows, object-&amp;gt;cols, object-&amp;gt;type);&lt;br /&gt;
}&lt;br /&gt;
cvCvtColor(frame, object, CV_BGR2GRAY);&lt;br /&gt;
&lt;br /&gt;
if( !firstFrame )&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
//Extract SURF points by initializing parameters&lt;br /&gt;
CvSURFParams params = cvSURFParams(500, 1);&lt;br /&gt;
cvExtractSURF( image, 0, &amp;amp;imageKeypoints, &amp;amp;imageDescriptors, storage, params );&lt;br /&gt;
cvExtractSURF( object, 0, &amp;amp;objectKeypoints, &amp;amp;objectDescriptors, storage, params );&lt;br /&gt;
CvPoint src_corners[4] = {{0,0}, {object-&amp;gt;width,0}, {object-&amp;gt;width, object-&amp;gt;height}, {0, object-&amp;gt;height}};&lt;br /&gt;
CvPoint dst_corners[4];&lt;br /&gt;
IplImage* correspond = cvCreateImage( cvSize(image-&amp;gt;width, object-&amp;gt;height+image-&amp;gt;height), 8, 1 );&lt;br /&gt;
cvSetImageROI( correspond, cvRect( 0, 0, object-&amp;gt;width, object-&amp;gt;height ) );&lt;br /&gt;
cvCopy( object, correspond );&lt;br /&gt;
cvSetImageROI( correspond, cvRect( 0, object-&amp;gt;height, correspond-&amp;gt;width, correspond-&amp;gt;height ) );&lt;br /&gt;
cvCopy( image, correspond );&lt;br /&gt;
cvResetImageROI( correspond );&lt;br /&gt;
&lt;br /&gt;
if( locatePlanarObject( objectKeypoints, objectDescriptors, imageKeypoints,&lt;br /&gt;
imageDescriptors, src_corners, dst_corners ))&lt;br /&gt;
{&lt;br /&gt;
for( i = 0; i &amp;lt; 4; i++ )&lt;br /&gt;
{&lt;br /&gt;
CvPoint r1 = dst_corners[i%4];&lt;br /&gt;
CvPoint r2 = dst_corners[(i+1)%4];&lt;br /&gt;
cvLine( correspond, cvPoint(r1.x, r1.y+object-&amp;gt;height ),&lt;br /&gt;
cvPoint(r2.x, r2.y+object-&amp;gt;height ), colors[8] );&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
vector&amp;lt;int&amp;gt; ptpairs;&lt;br /&gt;
#ifdef USE_FLANN&lt;br /&gt;
flannFindPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );&lt;br /&gt;
#else&lt;br /&gt;
findPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );&lt;br /&gt;
#endif&lt;br /&gt;
CvPoint2D32f srcTri[4], dstTri[4];&lt;br /&gt;
&lt;br /&gt;
IplImage *dst = cvCloneImage( frame );&lt;br /&gt;
IplImage *dst1 = cvCloneImage( frame );&lt;br /&gt;
int jk=0;&lt;br /&gt;
for( i = 0; i &amp;lt; (int)ptpairs.size(); i += 2 )&lt;br /&gt;
{&lt;br /&gt;
CvSURFPoint* r1 = (CvSURFPoint*)cvGetSeqElem( objectKeypoints, ptpairs[i] );&lt;br /&gt;
CvSURFPoint* r2 = (CvSURFPoint*)cvGetSeqElem( imageKeypoints, ptpairs[i+1] );&lt;br /&gt;
if (i&amp;lt;8)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;srcTri[jk] = r1-&amp;gt;pt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;dstTri[jk] = r2-&amp;gt;pt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;jk++;&lt;br /&gt;
}&lt;br /&gt;
cvLine( correspond, cvPointFrom32f(r1-&amp;gt;pt),&lt;br /&gt;
cvPoint(cvRound(r2-&amp;gt;pt.x), cvRound(r2-&amp;gt;pt.y+object-&amp;gt;height)), colors[8] );&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;CvMat* warp_mat = cvCreateMat(3,3,CV_32FC1);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1);&lt;br /&gt;
&lt;br /&gt;
cvGetAffineTransform( srcTri, dstTri, rot_mat );&lt;br /&gt;
cvWarpAffine( frame, dst1, rot_mat );&lt;br /&gt;
&lt;br /&gt;
cvGetPerspectiveTransform( srcTri, dstTri, warp_mat );&lt;br /&gt;
cvWarpPerspective( frame, dst, warp_mat );&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;PrintMatrix(warp_mat,&quot;Perspective Matrix&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;PrintMatrix(rot_mat,&quot;Affine Rotation Matrix&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//show the image&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cvShowImage(&quot;output Perspective Transform&quot;, dst);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cvShowImage(&quot;output Affine Transform&quot;, dst1);&lt;br /&gt;
&lt;br /&gt;
cvShowImage( &quot;Object Correspond&quot;, correspond );&lt;br /&gt;
for( i = 0; i &amp;lt; objectKeypoints-&amp;gt;total; i++ )&lt;br /&gt;
{&lt;br /&gt;
CvSURFPoint* r = (CvSURFPoint*)cvGetSeqElem( objectKeypoints, i );&lt;br /&gt;
CvPoint center;&lt;br /&gt;
int radius;&lt;br /&gt;
center.x = cvRound(r-&amp;gt;pt.x);&lt;br /&gt;
center.y = cvRound(r-&amp;gt;pt.y);&lt;br /&gt;
radius = cvRound(r-&amp;gt;size*1.2/9.*2);&lt;br /&gt;
cvCircle( frame, center, radius, colors[0], 1, 8, 0 );&lt;br /&gt;
}&lt;br /&gt;
cvShowImage( &quot;Object&quot;, frame );&lt;br /&gt;
}&lt;br /&gt;
cvWaitKey(250);&lt;br /&gt;
{&lt;br /&gt;
CvMat* temp;&lt;br /&gt;
CV_SWAP(image, object, temp);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
cvReleaseCapture(&amp;amp;capture);&lt;br /&gt;
return 0;&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/3455808738676715573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2010/12/affine-vs-perspective-transformation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3455808738676715573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3455808738676715573'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2010/12/affine-vs-perspective-transformation.html' title='Affine VS Perspective Transformation using CAMERA'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh8JBA__0l-TCFHr-vqMK03KL5TajwcLoslny1GHMWeQCIJ-0w91N7znBwzL3336X3PF-kN7gNDeLrPvD5tBbKjJHV1MDnA7ylT1Ft4aUWokIRUmiWXNBYo5bVgwYJ26Y0-6wLPC7MDokH/s72-c/perspectiveVSaffine.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-3149961869411681237</id><published>2010-12-27T00:54:00.000-08:00</published><updated>2010-12-27T01:05:40.021-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="live camera"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><category scheme="http://www.blogger.com/atom/ns#" term="SURF"/><category scheme="http://www.blogger.com/atom/ns#" term="trials"/><category scheme="http://www.blogger.com/atom/ns#" term="video"/><category scheme="http://www.blogger.com/atom/ns#" term="video stabilization"/><title type='text'>Live video stabilization Trials</title><content type='html'>&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dw90-6_iuPtMgfjkMfOq7zaX4d8SwyxWRA29ijurFSPn6fQWbS1kSQ0JvYpa6p-aIjDsIpdfQQKCGXz-knY8g&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;the angle of rotation and scaling is not yet done. need to find these in the previous image and after warping transform</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/3149961869411681237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2010/12/live-video-stabilization-trials.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3149961869411681237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/3149961869411681237'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2010/12/live-video-stabilization-trials.html' title='Live video stabilization Trials'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-6617042921871626911</id><published>2010-12-26T17:37:00.000-08:00</published><updated>2010-12-26T18:38:01.331-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="camera"/><category scheme="http://www.blogger.com/atom/ns#" term="livec"/><category scheme="http://www.blogger.com/atom/ns#" term="logpolar transform"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>logpolar transform using Camera</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghyWtf9MiroPkEVBds2ZBoGxewPgV_t4at35DHTKeihqUT_igGNNfAAzd-2KvR9mAPO_wM7Do2T6k4blYqyHYMFP4Fw1SaNUp_Zpc3Ckl7t5WEZG6rOx5kMaMXvZY9G-KWe3rZVgRZfucF/s1600/logpolar.jpg&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 177px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghyWtf9MiroPkEVBds2ZBoGxewPgV_t4at35DHTKeihqUT_igGNNfAAzd-2KvR9mAPO_wM7Do2T6k4blYqyHYMFP4Fw1SaNUp_Zpc3Ckl7t5WEZG6rOx5kMaMXvZY9G-KWe3rZVgRZfucF/s320/logpolar.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5555170237679674786&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;The logpolar transform function emulates the human “foveal” vision and can be used for fast  &lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;scale and rotation-invariant template matching&lt;/span&gt;, for object tracking and  so forth. The function can not operate in-place.&lt;br /&gt;&quot;The &lt;b&gt;foveal system&lt;/b&gt; of the human eye is the only part of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Retina&quot; title=&quot;Retina&quot;&gt;retina&lt;/a&gt; that permits 100% visual acuity. The &lt;a href=&quot;http://en.wikipedia.org/w/index.php?title=Line-of-sight_%28trigonometry%29&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Line-of-sight (trigonometry) (page does not exist)&quot;&gt;line-of-sight&lt;/a&gt; is a virtual line connecting the &lt;a href=&quot;http://en.wikipedia.org/wiki/Fovea&quot; title=&quot;Fovea&quot; class=&quot;mw-redirect&quot;&gt;fovea&lt;/a&gt; with a &lt;a href=&quot;http://en.wikipedia.org/wiki/Fixation&quot; title=&quot;Fixation&quot;&gt;fixation&lt;/a&gt; point in the outside world.&quot; Wikipedia;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEaFbTARfJJlhjjKAFy7VJgwnrmI1wxjjELUkB1HB3SymxB4PuyPPZ7FWw8l8Y0bQtuno-uy0KVnge3d_BOTmNmG1EKot-WhZYy90haddpH6LZItIHbAExdb-VY2H0MtmCC1zjW05bFgCk/s1600/logSift.jpg&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 181px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEaFbTARfJJlhjjKAFy7VJgwnrmI1wxjjELUkB1HB3SymxB4PuyPPZ7FWw8l8Y0bQtuno-uy0KVnge3d_BOTmNmG1EKot-WhZYy90haddpH6LZItIHbAExdb-VY2H0MtmCC1zjW05bFgCk/s400/logSift.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5555185667954618210&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/objdetect/objdetect.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/features2d/features2d.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/calib3d/calib3d.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;int main(int argc, char** argv)&lt;br /&gt;{&lt;br /&gt;      CvCapture *capture = 0;&lt;br /&gt;  IplImage  *src = 0;&lt;br /&gt;/* initialize camera */&lt;br /&gt;  capture = cvCaptureFromCAM( 0 );&lt;br /&gt;      for(;;) {&lt;br /&gt;      /* get a frame */&lt;br /&gt;      src = cvQueryFrame( capture );&lt;br /&gt;      /* always check */&lt;br /&gt;&lt;br /&gt;      if( !src ) break;&lt;br /&gt;      IplImage* dst = cvCreateImage( cvSize(256,256), 8, 3 );&lt;br /&gt;      IplImage* src2 = cvCreateImage( cvGetSize(src), 8, 3 );&lt;br /&gt;      cvLogPolar( src, dst, cvPoint2D32f(src-&amp;gt;width/2,src-&amp;gt;height/2), 40,&lt;br /&gt;      CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );&lt;br /&gt;      cvLogPolar( dst, src2, cvPoint2D32f(src-&amp;gt;width/2,src-&amp;gt;height/2), 40,&lt;br /&gt;      CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP );&lt;br /&gt;      cvNamedWindow( &quot;log-polar&quot;, 1 );&lt;br /&gt;      cvShowImage( &quot;log-polar&quot;, dst );&lt;br /&gt;      cvNamedWindow( &quot;inverse log-polar&quot;, 1 );&lt;br /&gt;      cvShowImage( &quot;inverse log-polar&quot;, src2 );&lt;br /&gt;      cvWaitKey(10);&lt;br /&gt;      }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/6617042921871626911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2010/12/logpolar-transform-using-camera.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6617042921871626911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/6617042921871626911'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2010/12/logpolar-transform-using-camera.html' title='logpolar transform using Camera'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghyWtf9MiroPkEVBds2ZBoGxewPgV_t4at35DHTKeihqUT_igGNNfAAzd-2KvR9mAPO_wM7Do2T6k4blYqyHYMFP4Fw1SaNUp_Zpc3Ckl7t5WEZG6rOx5kMaMXvZY9G-KWe3rZVgRZfucF/s72-c/logpolar.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-95295597041874472.post-1264389938827917846</id><published>2010-12-25T18:48:00.000-08:00</published><updated>2010-12-25T18:52:23.924-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Affine Transform"/><category scheme="http://www.blogger.com/atom/ns#" term="camera"/><category scheme="http://www.blogger.com/atom/ns#" term="live camera"/><category scheme="http://www.blogger.com/atom/ns#" term="load video"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv 2.2"/><title type='text'>Camera Affine Transformation</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh6K1RtFmefnmQn8hcuGfEauURskEtRYriieYoQEAdhZzq7A8EH05998CS4ccvDnRt94NQttVBo-JQvqOd7iixeiZozShJgBBzJD8vPXm7TAeS2eu9LTt9LQFVdv96tSPthGYvVauV9NYf/s1600/affine.jpg&quot;&gt;&lt;img style=&quot;display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 298px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh6K1RtFmefnmQn8hcuGfEauURskEtRYriieYoQEAdhZzq7A8EH05998CS4ccvDnRt94NQttVBo-JQvqOd7iixeiZozShJgBBzJD8vPXm7TAeS2eu9LTt9LQFVdv96tSPthGYvVauV9NYf/s320/affine.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5554818160413762274&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;An affine transform allows the user to warp, stretch, rotate and resize  an image or a footage from a camera.  Essentially the image is multiplied by 2x3 matrix to perform  the transformation.  An affine transform produces parallelograms (which  includes standard rectangles).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/objdetect/objdetect.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/features2d/features2d.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/highgui/highgui.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/calib3d/calib3d.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;&lt;br /&gt;#include &amp;lt;opencv2/video/tracking.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int angle_switch_value = 0;&lt;br /&gt;int angleInt = 0;&lt;br /&gt;int scale_switch_value = 0;&lt;br /&gt;int scaleInt = 0;&lt;br /&gt;&lt;br /&gt;void switch_callback_a( int position ){&lt;br /&gt;    angleInt = position;&lt;br /&gt;}&lt;br /&gt;void switch_callback_s( int position ){&lt;br /&gt;    scaleInt = position;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv)&lt;br /&gt;{&lt;br /&gt;    // Set up variables&lt;br /&gt;    CvPoint2D32f srcTri[3], dstTri[3];&lt;br /&gt;    CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1);&lt;br /&gt;    CvMat* warp_mat = cvCreateMat(2,3,CV_32FC1);&lt;br /&gt;    IplImage *src, *dst;&lt;br /&gt;    const char* name = &quot;Affine_Transform&quot;;&lt;br /&gt;&lt;br /&gt;    //create capture&lt;br /&gt;CvCapture* capture = cvCreateCameraCapture(0);&lt;br /&gt;for(;;)&lt;br /&gt;{&lt;br /&gt;    IplImage* src = cvQueryFrame(capture);&lt;br /&gt;    dst = cvCloneImage( src );&lt;br /&gt;    dst-&amp;gt;origin = src-&amp;gt;origin;&lt;br /&gt;    cvZero( dst );&lt;br /&gt;    cvNamedWindow( name, 1 );&lt;br /&gt;&lt;br /&gt;    // Create angle and scale&lt;br /&gt;    double angle = 0.0;&lt;br /&gt;    double scale = 1.0;&lt;br /&gt;&lt;br /&gt;    // Create trackbars&lt;br /&gt;    cvCreateTrackbar( &quot;Angle&quot;, name, &amp;amp;angle_switch_value, 4, switch_callback_a );&lt;br /&gt;    cvCreateTrackbar( &quot;Scale&quot;, name, &amp;amp;scale_switch_value, 4, switch_callback_s );&lt;br /&gt;&lt;br /&gt;    // Compute warp matrix&lt;br /&gt;    srcTri[0].x = 0;&lt;br /&gt;    srcTri[0].y = 0;&lt;br /&gt;    srcTri[1].x = src-&amp;gt;width - 1;&lt;br /&gt;    srcTri[1].y = 0;&lt;br /&gt;    srcTri[2].x = 0;&lt;br /&gt;    srcTri[2].y = src-&amp;gt;height - 1;&lt;br /&gt;&lt;br /&gt;    dstTri[0].x = src-&amp;gt;width*0.0;&lt;br /&gt;    dstTri[0].y = src-&amp;gt;height*0.25;&lt;br /&gt;    dstTri[1].x = src-&amp;gt;width*0.90;&lt;br /&gt;    dstTri[1].y = src-&amp;gt;height*0.15;&lt;br /&gt;    dstTri[2].x = src-&amp;gt;width*0.10;&lt;br /&gt;    dstTri[2].y = src-&amp;gt;height*0.75;&lt;br /&gt;&lt;br /&gt;    cvGetAffineTransform( srcTri, dstTri, warp_mat );&lt;br /&gt;    cvWarpAffine( src, dst, warp_mat );&lt;br /&gt;    cvCopy ( dst, src );&lt;br /&gt;&lt;br /&gt;        switch( angleInt ){&lt;br /&gt;            case 0:&lt;br /&gt;                angle = 0.0;&lt;br /&gt;                break;&lt;br /&gt;            case 1:&lt;br /&gt;                angle = 20.0;&lt;br /&gt;                break;&lt;br /&gt;            case 2:&lt;br /&gt;                angle = 40.0;&lt;br /&gt;                break;&lt;br /&gt;            case 3:&lt;br /&gt;                angle = 60.0;&lt;br /&gt;                break;&lt;br /&gt;            case 4:&lt;br /&gt;                angle = 90.0;&lt;br /&gt;                break;&lt;br /&gt;        }&lt;br /&gt;        switch( scaleInt ){&lt;br /&gt;            case 0:&lt;br /&gt;                scale = 1.0;&lt;br /&gt;                break;&lt;br /&gt;            case 1:&lt;br /&gt;                scale = 0.8;&lt;br /&gt;                break;&lt;br /&gt;            case 2:&lt;br /&gt;                scale = 0.6;&lt;br /&gt;                break;&lt;br /&gt;            case 3:&lt;br /&gt;                scale = 0.4;&lt;br /&gt;                break;&lt;br /&gt;            case 4:&lt;br /&gt;                scale = 0.2;&lt;br /&gt;                break;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Compute rotation matrix&lt;br /&gt;        CvPoint2D32f center = cvPoint2D32f( src-&amp;gt;width/2, src-&amp;gt;height/2 );&lt;br /&gt;        cv2DRotationMatrix( center, angle, scale, rot_mat );&lt;br /&gt;&lt;br /&gt;        // Do the transformation&lt;br /&gt;        cvWarpAffine( src, dst, rot_mat );&lt;br /&gt;&lt;br /&gt;        cvShowImage( name, dst );&lt;br /&gt;        cvWaitKey( 15 );&lt;br /&gt;    }&lt;br /&gt;    cvReleaseImage( &amp;amp;dst );&lt;br /&gt;    cvReleaseMat( &amp;amp;rot_mat );&lt;br /&gt;    cvReleaseMat( &amp;amp;warp_mat );&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://areshopencv.blogspot.com/feeds/1264389938827917846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://areshopencv.blogspot.com/2010/12/camera-affine-transformation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/1264389938827917846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/95295597041874472/posts/default/1264389938827917846'/><link rel='alternate' type='text/html' href='http://areshopencv.blogspot.com/2010/12/camera-affine-transformation.html' title='Camera Affine Transformation'/><author><name>Aresh.Saharkhiz</name><uri>http://www.blogger.com/profile/07959081897702084177</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh6K1RtFmefnmQn8hcuGfEauURskEtRYriieYoQEAdhZzq7A8EH05998CS4ccvDnRt94NQttVBo-JQvqOd7iixeiZozShJgBBzJD8vPXm7TAeS2eu9LTt9LQFVdv96tSPthGYvVauV9NYf/s72-c/affine.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>