中文字幕视频在线免费_日韩在线精品_日韩视频免费看_中文字幕在线三区_午夜免费视频_日韩在线大片

移動設備上使用opencv 1.10做圖像識別的例子

來源:網絡

點擊:2495

A+ A-

所屬頻道:新聞中心

關鍵詞: Windows-Mobile,移動設備

        上次說到了如何在WINCE/WM移植Opencv1.10,這次就說說如何在WM手機上使用裁剪移植后的Open1.10的例子,在opencv上使用OpenSURF(OpenSURF在GoogleCode的地址:http://code.google.com/p/opensurf1/),先來看看本文程序運行的截圖: 

    左圖為SURF算法找出的特征點,右圖為兩個圖像相似特征點的匹配。

        本文的代碼可以到http://www.rayfile.com/zh-cn/files/da4d4edc-8af5-11df-9dac-0015c55db73d/這里下載,代碼里包含了自己實現的MyHighGUI類,用于轉換/繪制/保存IplImage圖像,也包含了同時支持WINCE/WIN32的第三方BMP操作類庫----DIBSectionCE類(詳見http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3),接下來就貼出部分操作代碼:

    view plaincopy to clipboardprint?
    //*****************************************************************  
    //取得程序當前文件夾路徑  
    //****************************************************************  
    CString GetCurrentDirectory()    
    {    
        wchar_t pBuf[256];    
        GetModuleFileName(NULL,pBuf,sizeof(pBuf)/sizeof(wchar_t));    
        CString strPath(pBuf);    
        strPath = strPath.Left(strPath.ReverseFind('\\') + 1);    
        delete pBuf;  
        return strPath;  
    }  
     
    void CtestDlg::OnBnClickedButton1()  
    {  
        //自定義的HighGUI,詳見MyHighGUI.h  
        MyHighGUI gui;  
        //網上的BMP操作類,支持WINCE/WIN32,地址:http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3   
        CDIBSectionCE ce;  
        //step1:讀取BMP,并轉換為IplImage格式  
        CString bmpPath=GetCurrentDirectory()+L"car1.bmp";  
        ce.Load(bmpPath);  
        int nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ;      
        IplImage* img = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);  
        ce.DeleteObject();  
     
        //step2:提取圖片中的特征點  
        IpVec ipts;  
        surfDetDes(img, ipts, false, 3, 4, 2, 0.0004f);  
     
        // step3:畫出特征點    
        drawIpoints(img, ipts);  
        gui.Show(img,::GetDC(this->m_hWnd),0,0,img->width,img->height);  
        //gui.WriteBmp(L"img33.bmp",(BYTE *)img->imageData,img->imageSize,img->width,img->height);  
         img=NULL;  
    }  
     
    void CtestDlg::OnBnClickedButton2()  
    {  
        //自定義的HighGUI,詳見MyHighGUI.h  
        MyHighGUI gui;  
        //網上的BMP操作類,支持WINCE/WIN32,地址:http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3   
        CDIBSectionCE ce;  
        //step1:讀取BMP,并轉換為IplImage格式  
        CString bmpPath=GetCurrentDirectory()+L"car1.bmp";  
        ce.Load(bmpPath);  
        int nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ;      
        IplImage* img1 = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);  
        ce.DeleteObject();  
     
        bmpPath=GetCurrentDirectory()+L"car2.bmp";  
        ce.Load(bmpPath);  
        nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ;  
        IplImage* img2 = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);  
        ce.DeleteObject();  
     
        //step2:提取圖片中的特征點  
        IpVec ipts1, ipts2;  
        surfDetDes(img1,ipts1,false,4,4,2,0.0002f);  
        surfDetDes(img2,ipts2,false,4,4,2,0.0002f);  
     
        //step3:特征點匹配  
        IpPairVec matches;  
        getMatches(ipts1,ipts2,matches);  
     
        //step4:畫出匹配的特征點,并且連線  
        for (unsigned int i = 0; i < matches.size(); ++i)  
        {  
            drawPoint(img1,matches[i].first);  
            drawPoint(img2,matches[i].second);  
            
            int w = img1->width;  
            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);  
            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);    
        }  
     
        //畫到屏幕上  
        if(img1->height>img2->height)  
        {     
            gui.Show(img1,::GetDC(this->m_hWnd),0,0,img1->width,img1->height);  
            gui.Show(img2,::GetDC(this->m_hWnd),img1->width,img1->height-img2->height,img2->width,img2->height);  
        }  
        else 
        {  
            gui.Show(img1,::GetDC(this->m_hWnd),0,img2->height-img1->height,img1->width,img1->height);  
            gui.Show(img2,::GetDC(this->m_hWnd),img1->width,0,img2->width,img2->height);  
        }  
     

    //*****************************************************************
    //取得程序當前文件夾路徑
    //****************************************************************
    CString GetCurrentDirectory() 

     wchar_t pBuf[256]; 
     GetModuleFileName(NULL,pBuf,sizeof(pBuf)/sizeof(wchar_t)); 
     CString strPath(pBuf); 
     strPath = strPath.Left(strPath.ReverseFind('\\') + 1); 
     delete pBuf;
     return strPath;
    }

    void CtestDlg::OnBnClickedButton1()
    {
     //自定義的HighGUI,詳見MyHighGUI.h
     MyHighGUI gui;
     //網上的BMP操作類,支持WINCE/WIN32,地址:http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3
     CDIBSectionCE ce;
     //step1:讀取BMP,并轉換為IplImage格式
     CString bmpPath=GetCurrentDirectory()+L"car1.bmp";
     ce.Load(bmpPath);
     int nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ; 
     IplImage* img = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);
        ce.DeleteObject();

     //step2:提取圖片中的特征點
     IpVec ipts;
     surfDetDes(img, ipts, false, 3, 4, 2, 0.0004f);

     // step3:畫出特征點 
     drawIpoints(img, ipts);
     gui.Show(img,::GetDC(this->m_hWnd),0,0,img->width,img->height);
     //gui.WriteBmp(L"img33.bmp",(BYTE *)img->imageData,img->imageSize,img->width,img->height);
      img=NULL;
    }

    void CtestDlg::OnBnClickedButton2()
    {
     //自定義的HighGUI,詳見MyHighGUI.h
     MyHighGUI gui;
     //網上的BMP操作類,支持WINCE/WIN32,地址:http://www.codeguru.com/cpp/w-p/ce/bitmapsandthegdi/article.php/c3
     CDIBSectionCE ce;
     //step1:讀取BMP,并轉換為IplImage格式
     CString bmpPath=GetCurrentDirectory()+L"car1.bmp";
     ce.Load(bmpPath);
     int nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ; 
     IplImage* img1 = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);
     ce.DeleteObject();

     bmpPath=GetCurrentDirectory()+L"car2.bmp";
     ce.Load(bmpPath);
     nChannels = ce.GetBitmapInfo()->bmiHeader.biBitCount /8 ;
     IplImage* img2 = gui.BMP2Ipl((BYTE*)ce.GetDIBits(),ce.GetWidth(),ce.GetHeight(),nChannels);
     ce.DeleteObject();

     //step2:提取圖片中的特征點
        IpVec ipts1, ipts2;
        surfDetDes(img1,ipts1,false,4,4,2,0.0002f);
        surfDetDes(img2,ipts2,false,4,4,2,0.0002f);

     //step3:特征點匹配
        IpPairVec matches;
        getMatches(ipts1,ipts2,matches);

     //step4:畫出匹配的特征點,并且連線
     for (unsigned int i = 0; i < matches.size(); ++i)
     {
      drawPoint(img1,matches[i].first);
      drawPoint(img2,matches[i].second);
      
      int w = img1->width;
      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);
      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); 
     }

     //畫到屏幕上
     if(img1->height>img2->height)
     { 
      gui.Show(img1,::GetDC(this->m_hWnd),0,0,img1->width,img1->height);
      gui.Show(img2,::GetDC(this->m_hWnd),img1->width,img1->height-img2->height,img2->width,img2->height);
     }
     else
     {
      gui.Show(img1,::GetDC(this->m_hWnd),0,img2->height-img1->height,img1->width,img1->height);
      gui.Show(img2,::GetDC(this->m_hWnd),img1->width,0,img2->width,img2->height);
     }

    }
     

    用戶可以根據本文的操作代碼,在WINCE/WM平臺上實現更多Opencv例子,不過,本文程序跑起來很慢(我用的是460MHz的K3方案 WM手機),因為只用標準C的Math做運算處理。在ARM9+DSP或者ARM11等手機上使用Opencv,建議在Opencv的運算部分用上這些手機的專用運算指令,這樣可以大大提高運算速度。

    (審核編輯: 智匯小新)

    聲明:除特別說明之外,新聞內容及圖片均來自網絡及各大主流媒體。版權歸原作者所有。如認為內容侵權,請聯系我們刪除。

    主站蜘蛛池模板: 久久久久久久 | 亚洲精品久久久久久国产 | 午夜男人 | 国产亚洲精品久久久久动 | 国产精品福利一区二区三区 | 在线一二三区 | 日韩av中文在线 | 欧美日韩久 | 一区二区免费在线观看 | 成人午夜在线播放 | 国产日产精品一区二区三区四区 | 免费啪啪网站 | 日本精品一区二区三区视频 | 特级黄一级播放 | 日本中文在线 | 欧美高清一区 | 国产三级一区二区三区 | 成人欧美一区二区三区在线观看 | 国产理论在线 | 国产精品成av人在线视午夜片 | 国偷自产一区二区免费视频 | 日韩欧美国产一区二区 | 欧美在线一区二区 | 久操色 | 免费国产视频 | 亚洲伦理一区二区 | 91久久精品日日躁夜夜躁国产 | 午夜看片 | 午夜国产视频 | 久久久久久亚洲av毛片大全 | 色视在线 | 亚洲在线视频一区二区 | 中文字幕av网 | 国产精品久久久久久福利一牛影视 | 久久精品亚洲精品 | 午夜剧场免费在线观看 | 午夜免费视频网站 | 99久久精品免费看国产一区二区三区 | 日韩欧美在线免费观看 | 中国女人真人一级毛片 | 视频一区在线播放 |