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

移動設備上使用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在线 | 午夜av影院 | 天天色天天色 | 91亚洲国产成人久久精品网站 | 久久精品亚洲精品国产欧美kt∨ | 亚洲久草 | 欧美国产视频 | 黄色成人影视 | 亚洲激情一区二区三区 | 色中色综合 | 亚洲二区在线观看 | 亚洲av毛片| ririsao久久精品一区 | 啵啵羞羞影院 | 精品国产免费人成在线观看 | 亚洲免费视频观看 | 日韩在线电影 | 亚洲视屏| 欧美日韩精品一区二区三区蜜桃 | 亚洲人免费视频 | 亚洲天堂免费在线 | 久久a视频| 中文字幕免费看 | 天堂中文视频在线观看 | 真实国产露脸乱 | 伊人伊人| 亚洲一页| 国产天天操 | 国产在线一区不卡 | 人人澡人人爽 | 涩涩一区| 日韩中文字幕在线视频 | 亚洲不卡视频在线 | 福利网在线 | 久久久国产一区二区三区 |