国产一区二区精品在线_午夜精品视频_亚洲国产高清高潮精品美女_久久久91_午夜精品视频_久久久久亚洲一区二区三区

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

來源:網絡

點擊:2505

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的運算部分用上這些手機的專用運算指令,這樣可以大大提高運算速度。

    (審核編輯: 智匯小新)

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

    主站蜘蛛池模板: 春色资源中文在线 | 日韩中文在线 | 一区在线观看视频 | 大rb狠狠地给你这y荡的视频 | 99精品免费观看 | 国产女无套免费网站 | 一级毛片免费完整版 | 欧美成在线视频 | 日韩在线观看一区二区三区 | 中文字幕亚洲精品日韩一区 | 国产大片网站 | 国产一级做a爰片久久毛片男男 | 中文字幕一区二区三区四区不卡 | 91精品一线二线三线精华液 | 91久久精品日日躁夜夜躁国产 | 亚洲黄色影院 | 精品人伦一区二区三区四区蜜桃牛 | h在线播放 | 黄色av电影网站 | 欧美午夜aaaaaa免费视频 | xxx在线播放 | 中国美女一级毛片 | 毛片免费看 | 亚洲视频入口 | 日韩精品一区三区 | 九九热99视频 | 日本亚洲一区二区三区 | 成人国产一区二区 | 欧美精品v国产精品v日韩精品 | 亚洲97 | 狠狠操中文字幕 | 黄页嫩草 | 精品孕妇一区二区三区 | 香蕉视频国产 | 欧美日韩中文国产一区发布 | 日韩高清影片在线观看 | 激情在线网站 | 亚洲色图在线视频 | 免费黄看片 | 色五月在线视频 | 国产免费一级淫片a级中文 国产免费一区 |