Examples of using opencv 1.10 for image recognition on mobile devices

Source: Internet
Author: User

This article from http://blog.csdn.net/hellogv/, reference must indicate the source!

The last time I talked about how to port opencv1.10 on WinCE/Wm, this time I will talk about how to use open1.10 after cropping and porting on WM mobile phones, and use opensurf on opencv (the address of opensurf in googlecode: http://code.google.com/p/opensurf1/), let's take a look at the program running this article:

The left is the feature points found by the surf algorithm, and the right is the matching of the two similar feature points of the image.

The code in this article can go to the pipeline (see the http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3), and then paste part of the operation code:

//************************************** ************************* <Br/> // obtain the current folder path of the Program <br /> //************************************ * ************************** <br/> cstring getcurrentdirectory () <br/>{< br/> wchar_t pbuf [256]; <br/> getmodulefilename (null, pbuf, sizeof (pbuf)/sizeof (wchar_t )); <br/> cstring strpath (pbuf); <br/> strpath = strpath. left (strpath. reversefind ('//') + 1); <br/> Delete pbuf; <br/> return strpath; <br/>}</P> <p> void ctestdlg:: onbnclickedbutton1 () <br/>{< br/> // custom highgui. For details, see myhighgui. h <br/> myhighgui GUI; <br/> // BMP operation class on the internet, supporting wince/Win32, address: http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3 <br/> cdibsectionce; <br/> // Step 1: Read BMP and convert it to iplimage format <br/> cstring BMP Path = getcurrentdirectory () + L "car1.bmp"; <br/> ce. load (BMP path); <br/> int nchannels = ce. getbitmapinfo ()-> bmiheader. bibitcount/8; <br/> iplimage * IMG = GUI. BMP 2ipl (byte *) CE. getdibits (), ce. getwidth (), ce. getheight (), nchannels); <br/> ce. deleteobject (); </P> <p> // Step 2: extract feature points from the image <br/> ipvec IPTS; <br/> surfdetdes (IMG, IPTS, false, 3, 4, 2, 0.0004f); </P> <p> // Step 3: Draw a feature <br/> drawipoints (IMG, IPTS); <br/> GUI. show (IMG,: getdc (this-> m_hwnd), 0, IMG-> width, IMG-> height); <br/> // GUI. writebmp (L "img33.bmp", (byte *) IMG-> imagedata, IMG-> imagesize, IMG-> width, IMG-> height); <br/> IMG = NULL; <br/>}</P> <p> void ctestdlg: onbnclickedbutton2 () <br/>{< br/> // custom highgui. For details, see myhighgui. h <br/> myhighgui GUI; <br/> // BMP operation class on the internet, supporting wince/Win32, address: http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3 <br/> cdibsectionce; <br/> // Step 1: Read BMP and convert it to iplimage format <br/> cstring BMP Path = getcurrentdirectory () + L "car1.bmp"; <br/> ce. load (BMP path); <br/> int nchannels = ce. getbitmapinfo ()-> bmiheader. bibitcount/8; <br/> iplimage * img1 = GUI. BMP 2ipl (byte *) CE. getdibits (), ce. getwidth (), ce. getheight (), nchannels); <br/> ce. deleteobject (); </P> <p> BMP Path = getcurrentdirectory () + L "car2.bmp"; <br/> ce. load (BMP path); <br/> nchannels = ce. getbitmapinfo ()-> bmiheader. bibitcount/8; <br/> iplimage * img2 = GUI. BMP 2ipl (byte *) CE. getdibits (), ce. getwidth (), ce. getheight (), nchannels); <br/> ce. deleteobject (); </P> <p> // Step 2: extract feature points from the image <br/> ipvec ipts1, ipts2; <br/> surfdetdes (img1, ipts1, false, 4,4, 2, 0.0002f); <br/> surfdetdes (img2, ipts2, false, 4,4, 2, 0.0002f); </P> <p> // Step3: feature Point Matching <br/> ippairvec matches; <br/> getmatches (ipts1, ipts2, matches); </P> <p> // Step 4: Draw matched feature points, and connected <br/> for (unsigned int I = 0; I <matches. size (); ++ I) <br/>{< br/> drawpoint (img1, matches [I]. first); <br/> drawpoint (img2, matches [I]. second); </P> <p> int W = img1-> width; <br/> cvline (img1, cvpoint (matches [I]. first. x, matches [I]. first. y), cvpoint (matches [I]. second. X + W, matches [I]. second. y), cvscalar (123,123,123), 1); <br/> cvline (img2, cvpoint (matches [I]. first. x-W, matches [I]. first. y), cvpoint (matches [I]. second. x, matches [I]. second. y), cvscalar (123,123,123), 1 ); <br/>}</P> <p> // draw to the screen <br/> If (img1-> height> img2-> height) <br/> {<br/> GUI. show (img1,: getdc (this-> m_hwnd), 0, img1-> width, img1-> height); <br/> GUI. show (img2,: getdc (this-> m_hwnd), img1-> width, img1-> height-img2-> height, img2-> width, img2-> height ); <br/>}< br/> else <br/>{< br/> GUI. show (img1,: getdc (this-> m_hwnd), 0, img2-> height-img1-> height, img1-> width, img1-> height ); <br/> GUI. show (img2,: getdc (this-> m_hwnd), img1-> width, 0, img2-> width, img2-> height ); <br/>}</P> <p >}< br/>

You can implement more opencv examples on the wince/Wm Platform Based on the operation code in this article. However, the program in this article runs very slowly (I use the MHz K3 solution WM mobile phone ), because only math of Standard C is used for computation. If you use opencv on mobile phones such as arm9+ DSP or arm11, we recommend that you use the dedicated computing commands of these mobile phones in the Calculation Section of opencv to greatly increase the computing speed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.