tag:blogger.com,1999:blog-69405496602779543792024-02-07T10:54:25.744-08:00This Old HackJoshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6940549660277954379.post-90478151241608221122011-11-04T11:28:00.000-07:002011-11-04T11:36:26.338-07:00Maintaining Aspect Ratio in OpenGL with glFrustum While Resizing Windows<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Maintaining aspect ratio in OpenGL can be tricky with glFrustum calls. I searched the web for some good code to do this, but I found nothing really satisfying. Let me set up the scenario. Let's say you have a texture that you want to display (an image). Let's also say it has some aspect ratio. Whenever you resize you window you want to set the viewport to be the same size as the window, but still maintain aspect ratio and not have the texture spill out of window bounds. The correct way to do this is with some glFrustum calls to set up your projection matrix correctly. First let's draw the texture centered at (0,0). Here is the code for that:</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Assuming you have already created a texture, bound it and enabled GL_TEXTURE...</span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;">glBegin(GL_QUADS);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;">{</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glTexCoord2f(0.0f, 0.0f);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glVertex2f(-aspectRatio * 0.5f, 0.5f); </span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glTexCoord2f(0.0f, 1.0f);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glVertex2f(-aspectRatio * 0.5f, -0.5f); </span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glTexCoord2f(1.0f, 1.0f);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glVertex2f(aspectRatio * 0.5f, -0.5f); </span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glTexCoord2f(1.0f, 0.0f);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;"> glVertex2f(aspectRatio * 0.5f, 0.5f);</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;">}</span></span><br />
<span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; white-space: pre;">glEnd();</span></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; white-space: pre;">Notice that our x-coordinates are all half of the aspect ratio and the y-coordinates are half of one. Every time you resize your window you need to then snap your texture to the top and bottom with some space on the sides or to the left and right with some space on the sides. This is assuming that your window aspect ratio is not the same as your texture aspect ratio. If they are the same, then all is well and there will be no space on either side. So, what magic will get you the right aspect ratio on every resize without the texture spilling out of bounds? Here it is:</span><br />
<pre><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">// get the window aspect ratio</span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">float windowAspectRatio = this->width() / (float) this->height();</span></span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">float halfWindowAspectRatio = windowAspectRatio * 0.5f;</span></span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">// aspectRatio is the aspect ratio of your frame or texture</span></span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">float halfAspectRatio = aspectRatio * 0.5f;</span></span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">float left, right, top, bottom;</span></span></pre><pre><span class="Apple-style-span" style="font-size: xx-small;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">if (aspectRatio < windowAspectRatio) {</span></span></pre><pre><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"> // top and bottom should be flush with window
top = 0.5f; // remember this is the top of the texture
left = -halfWindowAspectRatio;
} else {
// left and right should be flush with window
left = -halfAspectRatio;
// we are keeping top relative to the windowAspectRatio (normalizing here)
top = halfAspectRatio / windowAspectRatio;
}</span></pre><pre><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">right = -left;</span></pre><pre><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">bottom = -top;</span></pre><pre><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">There it is. Notice that the two cases rely on the fact that the aspect ratio of the texture is either less than or greater than the aspect ratio of the window. There it is though, in all its glory. Once you have that you just need to set those values into your glFrustum call and you're done.</span></pre><pre><pre><pre><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;">
</span></pre></pre></pre>Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com0tag:blogger.com,1999:blog-6940549660277954379.post-29258638088447431482011-11-02T07:38:00.000-07:002011-11-02T07:38:10.335-07:00OpenCV on Windows Debug ModeFor some reason (I am not clear as to why), OpenCV seemingly did not work in debug mode with QT on Windows 7. I am running Windows 7 64-bit and I built the OpenCV libraries myself (in Visual Studio 2010). Unfortunately, it took me an unreasonable amount of time to discover that in Windows, if I want to run some of the OpenCV libraries in debug mode without everything blowing up in my face, I need not only the .dlls and the .libs, but also the .pdb files. Apparently, Windows uses these to run the libraries in debug mode. Once I figured this little piece of magic out (and Google did not offer a solution immediately), I just placed the libs, the dlls, and the pdbs in the same folder and told my program where this directory was when linking. Then, viola---it worked perfectly. Wish I had found out sooner.Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com0tag:blogger.com,1999:blog-6940549660277954379.post-54407635572141132432011-03-05T16:10:00.000-08:002011-03-05T16:10:25.689-08:00Cocos2d and Opencv on iPhoneGood night! It has taken me all day to get cocos2d and opencv to play nice on the iphone. First I couldn't link the files with the iphone project from opencv (static libraries). Finally, I found this beautiful <a href="http://computer-vision-talks.com/2011/02/building-opencv-for-iphone-in-one-click/">post</a>. It helped me compile opencv for iphone really quick. Once that was done, I had to remove a few of the problems that cocos2d has with opencv. Anything that XCode complained about, I stripped out of the opencv source. Most of it was highgui calls. Once that was done, I was able to link the libraries. However, I then could not include the opencv headers in my project!!<br />
<br />
I fixed this by realizing opencv has a problem with .mm files. So, once I changed the class I am using opencv in to a .m file, cocos2d played nice with it.Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com0tag:blogger.com,1999:blog-6940549660277954379.post-42957256233036120592010-11-01T07:32:00.000-07:002010-11-01T07:36:03.797-07:00OpenCV SURF and Qt<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif; white-space: pre;"></span><br />
<pre style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><a href="http://dl.dropbox.com/u/7985337/ImageStitcher.zip">Download Source</a></span></span></pre><br />
Due to the fact that I could find no real tutorial on how to use OpenCV's implementation of SURF (Speeded Up Robust Features) online, I decided to write one after I figured out how to use it. SURF is a feature detection algorithm that finds the correspondence between two images. This is useful for image stitching (creating wide panorama shots with multiple images) or just finding an object in an image. The basic algorithm for SURF is as follows:<br />
<br />
<div style="text-align: center;"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">"First, 'interest points' are selected at distinctive locations in the image, such as corners, </span></span><a href="http://en.wikipedia.org/wiki/Blob_detection"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">blobs</span></span></a><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">, and T-junctions. The most valuable property of an interest point </span></span><i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">detector</span></span></i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;"> is its repeatability, i.e. whether it reliably finds the same interest points under different viewing conditions. Next, the neighbourhood of every interest point is represented by a </span></span><a href="http://en.wikipedia.org/wiki/Feature_vector"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">feature vector</span></span></a><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">. This </span></span><i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">descriptor</span></span></i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;"> has to be distinctive and, at the same time, robust to noise, detection errors, and geometric and photometric deformations. Finally, the descriptor vectors are </span></span><i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">matched</span></span></i><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;"> between the vectors, e.g. the </span></span><a href="http://en.wikipedia.org/wiki/Mahalanobis_distance"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">Mahalanobis</span></span></a><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;"> or </span></span><a href="http://en.wikipedia.org/wiki/Euclidean_distance"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">Euclidean</span></span></a><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;"> distance. The dimension of this vector has a direct impact on the time this takes, and a lower number of dimensions is therefore desirable." (</span></span><a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.85.2512&rep=rep1&type=pdf"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">Bay, Herbert et al. 2006. SURF: Speeded Up Robust Features</span></span></a><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;">Got that students? Basically, we find some key points in the images that will uniquely identify them. Once those key points are found we look at the neighboring pixels and put it in a feature collection. Then we match the two vectors (match being the operative word here) by comparing their distance (Euiclidean or Mahalanobis). That's the idea. Simple but complex. Well, you don't have to implement any of that goodness because OpenCV has done it for you. Although it is a little complex to follow their sample code without someone helping you understand what is going on. In this tutorial I will show you how to use OpenCV to extract the SURF key points and descriptors, compare them, and then stitch two images together based on those key points and descriptors. My code is based directly on OpenCV's sample code find_obj.cpp where they use the SURF algorithm for feature detection. </span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;"><br />
</span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;">Before we start I wanted to talk about homographies. A homography (for our purposes today) is a little 3x3 matrix that tells us how to map one image (a set of pixel) onto another image. OpenCV has a function for finding this matrix once we have the key points and descriptors. I won't focus on how this is found as that is not the scope of this tutorial. Just know that we need it to stitch the two images together. If you want to study what a homography is, check out this </span><a href="http://en.wikipedia.org/wiki/Homography"><span class="Apple-style-span" style="font-size: small;">page</span></a><span class="Apple-style-span" style="font-size: small;">.</span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;"><br />
</span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;">Here is the basic algorithm:</span></div><div style="text-align: left;"></div><ol><li><span class="Apple-style-span" style="font-size: small;">Use cvExtractSURF to get key points and descriptors from both images.</span></li>
<li><span class="Apple-style-span" style="font-size: small;">Find matching key points by comparing the distance between the key points. We will use a naive nearest neighbor approach.</span></li>
<li><span class="Apple-style-span" style="font-size: small;">Once the pairs of key points are found, stick them into cvFindHomography to get the homography matrix.</span></li>
<li><span class="Apple-style-span" style="font-size: small;">Use the homography to warp one image to the other.</span></li>
</ol><span class="Apple-style-span" style="font-size: small;">We'll do this in chronological order (makes sense that way to me, anyway). </span><br />
<div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;"><br />
</span></div><div style="text-align: left;"><b><span class="Apple-style-span" style="font-size: small;">Using cvExtractSURF</span></b></div><div style="text-align: left;"><span class="Apple-style-span" style="font-size: small;">Given two QImages, I create two grayscale IplImages to work with OpenCV's methods. Don't worry about how to convert between QImage and IplImage. I will post that code, but for general purposes you can just use an IplImage.</span></div><div style="text-align: left;"><br />
</div><div style="text-align: left;"></div><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"> </span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"> </span><span class="Apple-style-span" style="font-size: x-small;">IplImage</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">ipl1</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">ImageStitcher</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">::</span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QImage2GrayscaleIplImage</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">scaledImage1</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">IplImage</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">ipl2</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">ImageStitcher</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">::</span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QImage2GrayscaleIplImage</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">scaledImage2</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvMemStorage</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">memoryBlock</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvCreateMemStorage</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">();</span></span></pre><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">//</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">Only</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">values</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">with</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">a</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">hessian</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">greater</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">than</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">500</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">are</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">considered</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">for</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">keypoints</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFParams</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">params</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvSURFParams</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">500</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvExtractSURF</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">ipl1</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">memoryBlock</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">params</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvExtractSURF</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">ipl2</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">memoryBlock</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">params</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="color: silver;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Notice the basic idea here is pretty straightforward. Get a couple of grayscale (has to be grayscale) IplImages. Create a memory block to store your key points and descriptors. Throw it into cvExtractSURF and it will populate the key points and the descriptors for you. Don't worry about cvSURFParams or what a Hessian value is, just know that 300 to 500 is a good first parameter. If that doesn't satisfy you, look up the documentation on the function and then go find out what a Hessian matrix is. After you do this, you have got your key points and descriptors from both images. We are now ready to compare them.</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><b><span class="Apple-style-span" style="font-size: small;">Matching Key Points in Both Images</span></b></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">Here we are going to match the image key points into pairs using a QVector. The first item in the QVector is the list of the first image's matched key points and the second item is the second image's matched key points. </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"> </span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">//</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">Find</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">matching</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">keypoints</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">in</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">both</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">images</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span class="Apple-style-span" style="font-size: x-small;">CvPoint2D32f</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">keyPointMatches</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">keyPointMatches</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">append</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span class="Apple-style-span" style="font-size: x-small;">CvPoint2D32f</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">>());</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">keyPointMatches</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">append</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span class="Apple-style-span" style="font-size: x-small;">CvPoint2D32f</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">>());</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">for</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">total</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">++)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoint</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">nearestNeighbor</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">this</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">findNaiveNearestNeighbor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">nearestNeighbor</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">==</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">NO_NEIGHBOR</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">continue</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">keyPointMatches</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">].</span></span><span class="Apple-style-span" style="font-size: x-small;">append</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(((</span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">))-></span></span><span class="Apple-style-span" style="font-size: x-small;">pt</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">keyPointMatches</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">].</span></span><span class="Apple-style-span" style="font-size: x-small;">append</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(((</span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">nearestNeighbor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">))-></span></span><span class="Apple-style-span" style="font-size: x-small;">pt</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">So, loop over one of the image's descriptors and extract each of its key points and descriptors. Now what you're actually extracting is a key point and a feature vector for that key point--its descriptor (the vector will be a good old C array). Find the nearest neighbor, don't worry we'll get to that, and then match them up in our QVector.</span></span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">
</span></span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">OK, finding the nearest neighbor has several implementations. This one is taken basically from OpenCV's sample code.</span></span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int </span></span><span class="Apple-style-span" style="font-size: x-small;">findNaiveNearestNeighbor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;"> const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;"> const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> CvSeq</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptorsCount</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)(</span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">elem_size</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">/</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">sizeof</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">));</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">minSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">std</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">::</span></span><span class="Apple-style-span" style="font-size: x-small;">numeric_limits</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">>::</span></span><span class="Apple-style-span" style="font-size: x-small;">max</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">();</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">std</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">::</span></span><span class="Apple-style-span" style="font-size: x-small;">numeric_limits</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">>::</span></span><span class="Apple-style-span" style="font-size: x-small;">max</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">();</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">neighbor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">for</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">total</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">++)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoint</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvSURFPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvGetSeqElem</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image1KeyPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">laplacian</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">!=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2KeyPoint</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">laplacian</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">continue</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">//</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">Don't</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">worry</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">about</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">key</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">points</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">unless</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">laplacian</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">signs</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">are</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: green;"><span class="Apple-style-span" style="font-size: x-small;">equal</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">squaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;"> this</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-></span></span><span class="Apple-style-span" style="font-size: x-small;">compareSURFDescriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> descriptorsCount</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span class="Apple-style-span" style="font-size: x-small;"> lastMinSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">squaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">minSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">neighbor</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">minSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">minSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">squaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">else</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">squaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">squaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">minSquaredDistance</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0.7</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">return</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">neighbor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">return</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">NO_NEIGHBOR</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">So, there is a lot to cover here but we'll do our best to get through it--stick with me. Remember we are passing into this function an array of features from the first image, the key point associated with that array and then the second image's key points and associated feature vectors. Now we loop through the second image's descriptors and extract each key point and feature vector. The descriptorCount there at the top is important. It tells us how long each feature vector array is. Don't miss it. The line about the laplacian is unimportant to grasp for our purposes, just know that key points don't really match if the sign of their laplacian doesn't match. If your asking yourself, "What the heck is a laplacian?" then you are no different than many of us that first study computer vision. It represents a spatial change in images and is used for edge detection. It is a second order derivative for you math nerds that tells us how much a pixel sticks out from the average of its neighbors. I myself am still trying to grasp the mathematics behind this little guy. If anyone can correct me here, please do.</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">Once we are past that step, we get to the juicy goodness of comparing feature vectors. We are going to compare the descriptors by finding the minimum squared distance between the first image's feature vector and all of the second image's and descriptors. (Notice I use feature vector and descriptor interchangeably--they're the same thing). We will do this by using the Euclidean squared distance (squared because it is faster than taking the square root of the thing). We keep track of the last minimum we found so that we can tie some threshold to how "close" the descriptors in the two images really are. I use 0.7--its a magic number. Once you implement it you can play around with this threshold and find one that works best for your images. Here is the method for comparing descriptors:</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double </span></span><span class="Apple-style-span" style="font-size: x-small;">compareSURFDescriptors</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;"> const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">const</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">*</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptorsCount</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">float</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">totalCost</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">for</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">int</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;"><</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptorsCount</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">4</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">{</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector4D</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptor1</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">2</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">3</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">]);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: purple;"><span class="Apple-style-span" style="font-size: x-small;">QVector4D</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptor2</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">0</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">2</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">],</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Descriptor</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span class="Apple-style-span" style="font-size: x-small;">i</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">3</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">]);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">totalCost</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">+=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">descriptor2</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">-</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">descriptor1</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">).</span></span><span class="Apple-style-span" style="font-size: x-small;">lengthSquared</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">();</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">if</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span class="Apple-style-span" style="font-size: x-small;">totalCost</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">></span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">lastMinSquaredDistance</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">)</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">break</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><span class="Apple-style-span" style="font-size: x-small;">
</span><pre style="-qt-block-indent: 0; -qt-paragraph-type: empty; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">return</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">totalCost</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">;</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">}</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">Here we speed things up if our total cost gets higher than the best value we have seen so far. Basically that is it for comparing and matching descriptors. Once we have done that we can move on to finding the homography.</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><b><span class="Apple-style-span" style="font-size: small;">Finding the Homography</span></b></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">It's pretty simple folks--at least OpenCV has made it that way. Declare a 1D array of floats and OpenCV will use the matched key points to populate the homography. Here it is:</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span class="Apple-style-span" style="font-size: x-small;">CvMat</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image1Points</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvMat</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">matchingKeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">first</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">().</span></span><span class="Apple-style-span" style="font-size: x-small;">count</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(),</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CV_32FC2</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">matchingKeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">first</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">().</span></span><span class="Apple-style-span" style="font-size: x-small;">data</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">());</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvMat</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">image2Points</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvMat</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">1</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">matchingKeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">last</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">().</span></span><span class="Apple-style-span" style="font-size: x-small;">count</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(),</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CV_32FC2</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">matchingKeyPoints</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">.</span></span><span class="Apple-style-span" style="font-size: x-small;">last</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">().</span></span><span class="Apple-style-span" style="font-size: x-small;">data</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">());</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: olive;"><span class="Apple-style-span" style="font-size: x-small;">double</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">h</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">[</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">9</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">];</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CvMat</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">H</span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">=</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvMat</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(</span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">3</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">3</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CV_64F</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">h</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">cvFindHomography</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">(&</span></span><span class="Apple-style-span" style="font-size: x-small;">image1Points</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">image2Points</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">&</span></span><span class="Apple-style-span" style="font-size: x-small;">H</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span class="Apple-style-span" style="font-size: x-small;">CV_RANSAC</span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">,</span></span><span style="color: silver;"><span class="Apple-style-span" style="font-size: x-small;"> </span></span><span style="color: navy;"><span class="Apple-style-span" style="font-size: x-small;">9</span></span><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">);</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-size: x-small;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">That little h[9] will now have the homography stored in row major order. Once we have that we will apply the homography to every pixel in one of the images and this will essentially warp one of the images and then we can stick them on top of each other. I won't go over the stitching here, but I will post the library that does this magic. I called it ImageStitcher. Feel free to take a look at it.</span></span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">
</span></span></pre><pre style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"><span style="color: black;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><a href="http://dl.dropbox.com/u/7985337/ImageStitcher.zip">Download Source</a></span></span></pre></span></pre></span></pre></span></span></pre></span></pre>Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com12tag:blogger.com,1999:blog-6940549660277954379.post-84217423358579493042010-05-15T15:32:00.000-07:002010-05-17T11:54:24.771-07:00Biplane Homework<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dyCj_hNaaB3DNLC-rBrNFeFA4P27EMoBs8ZvRt9fVWxflO9TyOCvMq8NpR6QEbOTXdvBsAuqtEYaFbbMebZcQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe><div><span class="Apple-style-span" style=" ;font-family:Helvetica;font-size:medium;"><div>I only transformed the normals when I did rotations, thus I kept a separate rotation matrix that had all of the rotations. I applied the rotations to the vertices as well as to the normals. However, the normals did not receive translations or scaling operations.</div><div><br /></div><div>I took swipes to the left and right to be a call to rotate in the y direction (the amount swiped is proportional to the angle). A tap on the left or right of the screen translates in the x directions. The tap on bottom or top of the screen is translate in the z direction. I used swipes up and down to translate in the y direction. Lastly a double tap in the center of the screen scaled it up by 1.5 and a triple tap scaled it down by .5. </div></span></div>Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com0tag:blogger.com,1999:blog-6940549660277954379.post-14374788434981641042009-05-01T12:44:00.000-07:002009-05-01T13:16:15.015-07:00Apple's iPhoto or Google's Picasa?Many of my readers probably have never even heard of Picasa. If you have, you probably didn't know it was a photo suite very similar to iPhoto. In fact, it is so good I thought I would do a side by side comparison for you people, thus letting you decide what piece is best for you. Let me first just list the pros and cons.<br /><br /><br /><span style="font-weight: bold;">Beloved iPhoto:</span><br /><ul><li>Price: $79 (iLife Suite) unless you just bought a mac.</li><li>Editing Tools: Auto/manual red-eye correction, retouch tool, contrast and color options.</li><li>Organizational Tools: iPhoto allows you organize your photos with face recognition. Thus, you can assign a name to someone's photo and then find all photos with that person (pretty cool). You can also organize your photos by event and place (also very handy).<br /></li><li>Online sharing: iPhoto allows you to upload to three places: facebook, mobileme, and flickr.</li><li>Operating Systems: Mac OS X only<br /></li></ul><span style="font-weight: bold;">Google's Picasa:</span><br /><ul><li>Price: Free.</li><li>Editing Tools: Auto/manual red-eye correction, retouch tool, contrast and color options, B&W focal point, soft focus point, and much more.</li><li>Organizational Tools: Picasa automagically finds all photos on your system when you first start it. You can organize by album or by folder. Either way, you have to assign new folders to photos that you import. Picasa does have face recognition, but it doesn't allow you to assign faces to names like iPhoto.<br /> </li><li>Online sharing: You can blog right from Picasa. Thus, you just click on the images you want to upload to your blog and you click Blog This. You can also upload to your gmail Picasa account online. In addition, when you click on the Shop button, you can upload your photos to a whole bundle of different printing shops (this feature is extremely easy to use). Some of them include winkflash.com, shutterfly.com, walmart.com, and snapfish.com.<br /></li><li>Operating Systems: Linux, Mac, Windows</li></ul><br />So, who takes the cake? That's for you to decide. I love the fact Picasa is free. I also love its ease of use when ordering prints. It is much easier to upload photos from Picasa than from any other web interface. In addition, when blogging with photos, Picasa is a must-have. It makes blogging extremely easy. Will I use Picasa on my mac? Maybe, for now I will still use iPhoto. However, most of my photos are on my Linux machine anyhow and that is where I use Picasa. If you don't use a mac, Picasa takes the cake, obviously.<br /><br />Good luck deciding. If you are curious about Picasa, give it a try. It's free and it won't hurt to try it.<br /><a href="http://picasa.google.com/"><br />Try Google's Picasa!</a>Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com4tag:blogger.com,1999:blog-6940549660277954379.post-91263245440512059732009-05-01T12:04:00.000-07:002009-05-01T12:40:34.537-07:00Hack This!<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFJrqla9TH7_YmV2lo50O1qFaskqXA74AJg0lujSorfHphXg-byZ4RQQ4K1XsvCkkVTT5YRf4SEu9GRw0NfThDQKWpeKkP2tzkT0w8mMyjT69V34ERFROdPxGLcbZUEoKcQGpt7sjq9Jg/s1600-h/cracked_window.png"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 100px; height: 105px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFJrqla9TH7_YmV2lo50O1qFaskqXA74AJg0lujSorfHphXg-byZ4RQQ4K1XsvCkkVTT5YRf4SEu9GRw0NfThDQKWpeKkP2tzkT0w8mMyjT69V34ERFROdPxGLcbZUEoKcQGpt7sjq9Jg/s320/cracked_window.png" alt="" id="BLOGGER_PHOTO_ID_5330942724565404930" border="0" /></a>Just recently, I realized that I wanted a place that I could share my thoughts and opinions about computers. I am not an expert computer scientist nor will I ever become one. Let's just say I am well-informed. I thought it would be useful to post my thoughts about software, hardware, computer malfunctions, design, and just plain old programming. And in the spirit of <a href="http://illbehonest.blogspot.com/">illbehonest</a> I wanted to allow people to ask any computer related questions they wished to, whether that be how to fix something up or how to break it. Not that I will be able to fully answer every computer-related question, but I will be an attempt to give it my best shot. If I don't know the answer, I am 99% sure I can find it for you. The 1% is my intelligencia fallback net.<br /><br />Now, getting down to business, let's talk about software for your mac. You don't like spending money on software. No one does. Sometimes you can get lucky and find a good piece of software that really does what you need and the price is $0. This is nice. A good website to explore for these kinds of goodies is <a href="http://www.thriftmac.com/">thriftmac.com</a>. This site is a library of links that will allow you to find several different pieces of freeware. For example, <a href="http://www.coconut-flavour.com/coconutbattery/">Coconut Battery</a>, which can be found at <a href="http://www.thriftmac.com/coconut-battery">thriftmac.com</a>, is a great utility that will tell you how long you have until that battery inside that beautiful macbook of yours will die. <a href="http://www.ambientdesign.com/artrage.html">Art Rage</a> is another program listed on the site that is fun for kids. It's a suped-up drawing program with lots of different brushes. The free version is limited in its tools, however. If you're looking save a grip of cash and don't want to search the web for freeware, head to <a href="http://www.thriftmac.com/">thriftmac.com</a>.Joshhttp://www.blogger.com/profile/17690977078547294583noreply@blogger.com3