• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            千張筆記

            Email:rain_qian830@163.com
            posts - 28, comments - 42, trackbacks - 0, articles - 0
              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
            這周是實(shí)習(xí)的第一周,天天要早起,天天擠地鐵,沒(méi)想到,自己就這樣成為上班一族了。第一周比較累,每天到公司就像夢(mèng)游似的,晚睡的習(xí)慣一下也改不過(guò)來(lái),嚴(yán)重睡眠不足,在公司中午也睡不了覺(jué),所以到下午兩點(diǎn)左右的時(shí)候特別困,好幾天我都坐在電腦前打瞌睡。

            公司在做一個(gè)地面互動(dòng)系統(tǒng)的項(xiàng)目,我的任務(wù)是從圖像中提取出腳印的輪廓,拼接相近的腳印,當(dāng)做一個(gè)腳印處理,并返回拼接后每個(gè)腳印的位置,我返回的是包含腳印的矩形,采用OpenCV實(shí)現(xiàn)的。我們采用了是紅外線裝置,所以拍攝出來(lái)的圖像噪聲比較少,二值化時(shí)采用合適的閾值,效果就比較好。

            OpenCV文檔中有輪廓提取的例程,這里就詳細(xì)不介紹了,我的步驟包括預(yù)處理(濾波處理)->灰度化->二值化->Canny邊緣檢測(cè)->輪廓提取,可以將二值化這一步省略,二值化很依賴閾值,光照對(duì)其影響較大。

            下面就貼下拼接的代碼:(若兩矩形相交或中心比較接近,就拼接這兩個(gè)矩形)
            在CSDN上看到一個(gè)測(cè)試兩矩形是否相交的特簡(jiǎn)單的方法:
            /****************************************************************************/
            矩形A和B
            矩形   A   (x1,y1),(x2,y2);      //矩形的左上角和右下角坐標(biāo)   
            矩形   B   (x3,y3),(x4,y4);   
            設(shè)   m =   (x1>x4) | (x2<x3)  
                    n  =   (y2<y3) | (y1>y4)   
            if(m | n)   
            {  
               //不相交   
            }   
            else   
            {   
               //相交   
            }  
            /****************************************************************************/
            我就把它寫成代碼了,如下:
            .
            //在二值圖像上查找contour
                cvFindContours( m_pTempImg,storage,&cont,sizeof(CvContour),
                                       CV_RETR_LIST,CV_CHAIN_APPROX_NONE, cvPoint(
            0,0) );


            /**********************************將位置相近的輪廓合并***************************************/    
                BOOL                       m,n;
                
            int                        mark = 0,diffX,diffY;
                CvRect                     temp;
                vector
            < CvRect >::iterator iter ;
                
                
            for( ;cont;cont = cont->h_next )    
                
            {
                    rect 
            = ( (CvContour*)cont ) -> rect;
                    
            if( rect.height * rect.width > AREASMALL && ( rect.height * rect.width ) < (m_pContourImg->width * m_pContourImg->height-AREALARGE )) 
                    
            {
                        
            if0 == mark ) 
                        
            {
                            FootSeq.push_back( rect );
                            mark 
            = 1;
                                
                        }

                        
            else                 
                        
            {
                            
            for( iter= FootSeq.begin();iter != FootSeq.end();iter++ )    //for1
                            {
                                m 
            = (rect.x > ((*iter).x + (*iter).width)) || ((rect.x + rect.width) < (*iter).x);
                                n 
            = ((rect.y+rect.height) < (*iter).y) || (rect.y > ((*iter).y + (*iter).height));
                                
                                
            if( m || n )   //兩矩形不相交
                                {
                                    diffX 
            = ( rect.x+rect.width/2)-((*iter).x+(*iter).width/2 );
                                    diffY 
            = ( rect.y+rect.height/2)-((*iter).y+(*iter).height/2 );
                                    
            if ( (int)( diffX*diffX + diffY*diffY ) < DISTANCE )
                                    
            {
                                        
            //保存原值
                                        temp.x      = ( *iter ).x;
                                        temp.y      
            = ( *iter ).y;
                                        temp.width  
            = ( *iter ).width;
                                        temp.height 
            = ( *iter ).height;    

                                        
            //合并新的矩形,覆蓋原矩形
                                        (*iter).x      = ( rect.x > (*iter).x) ? (*iter).x : rect.x;
                                        (
            *iter).y      = ( rect.y > (*iter).y) ? (*iter).y : rect.y;
                                        (
            *iter).width  = ( (rect.x + rect.width) > (temp.x + temp.width)) ? (rect.x + rect.width - (*iter).x) : ((temp.x + temp.width)-(*iter).x );
                                        (
            *iter).height = ( (rect.y + rect.height) > (temp.y + temp.height)) ? (rect.y + rect.height - (*iter).y) : ((temp.y + temp.height)-(*iter).y );
                                        
            break;
                                      }

                                }
            //不相交,若不合并,則繼續(xù)與下一個(gè)輪廓比較
                                       
                                
            else          //相交則合并
                                {
                                    
            //保存原值
                                    temp.x      = ( *iter ).x;
                                    temp.y      
            = ( *iter ).y;
                                    temp.width  
            = ( *iter ).width;
                                    temp.height 
            = ( *iter ).height;

                                    
            //合并新的矩形,覆蓋原矩形
                                    (*iter).x      = ( rect.x > (*iter).x) ? (*iter).x : rect.x;
                                    (
            *iter).y      = ( rect.y > (*iter).y) ? (*iter).y : rect.y;
                                    (
            *iter).width  = ( (rect.x + rect.width) > (temp.x + temp.width)) ? (rect.x + rect.width - (*iter).x) : ((temp.x + temp.width)-(*iter).x );
                                    (
            *iter).height = ( (rect.y + rect.height) > (temp.y + temp.height)) ? (rect.y + rect.height - (*iter).y) : ((temp.y + temp.height)-(*iter).y );
                                    
            break;
                                }
            //相交
                            }


                            
            if( iter == FootSeq.end() )    
                                FootSeq.push_back( rect );    
            //如果FootSeq中沒(méi)有與cont可合并的矩形,就將該矩形存儲(chǔ),作為新的矩形。
                        }
            //end else  (mark == 1)
                    }
              //end if   (面積符合要求)
                }
            //end for (cont == NULL)

            Feedback

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2009-07-28 11:57 by SW
            "二值化很依賴閾值" 可以使用自動(dòng)閾值,一般效果不錯(cuò)

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2009-07-28 15:14 by 99讀書人
            很好啊!

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2009-08-01 13:29 by 千張
            恩 我用迭代法試了下,效果還可以。@SW

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2009-10-27 21:45 by leremy
            不錯(cuò),我也正在找這樣一個(gè)方法

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2012-03-15 09:51 by 雷子深藍(lán)
            博主,寫的很好。?!,F(xiàn)在正好感興趣你這一塊,由于新手有點(diǎn)疑惑,想問(wèn)一下foodseq怎么定義的????

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)[未登錄](méi)  回復(fù)  更多評(píng)論   

            2012-05-29 15:54 by feng
            footSeq是怎么定義的

            # re: 【原】OpenCV輪廓提取(7月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2013-08-27 10:15 by 一二一
            樓主,能解釋一下FootSeq是什么么

            # re: 【原】OpenCV輪廓提?。?月13日~7月17日工作小記)  回復(fù)  更多評(píng)論   

            2014-03-08 00:28 by l2468y
            請(qǐng)問(wèn)footseq是什么啊?是findcontours保存的所有輪廓的外接矩形vector嗎?

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            国内精品久久人妻互换| 国产亚洲色婷婷久久99精品91| 漂亮人妻被中出中文字幕久久| 国产精品免费福利久久| 国产精品免费久久久久久久久 | 无码乱码观看精品久久| 婷婷伊人久久大香线蕉AV| 91精品国产91久久久久久| 久久亚洲AV成人无码| 国産精品久久久久久久| 久久水蜜桃亚洲av无码精品麻豆 | 中文国产成人精品久久不卡| AV狠狠色丁香婷婷综合久久| 亚洲精品无码久久久久| 国产综合成人久久大片91| 成人a毛片久久免费播放| 国产美女亚洲精品久久久综合| 无码任你躁久久久久久| 香港aa三级久久三级| 久久精品国产亚洲av影院| 无码国内精品久久人妻| 亚洲AV无码久久精品狠狠爱浪潮| 久久久久久精品免费免费自慰| 亚洲?V乱码久久精品蜜桃 | 久久久无码精品亚洲日韩软件| 伊人久久大香线蕉精品| 国产午夜精品久久久久免费视| 久久精品99久久香蕉国产色戒| 亚洲国产另类久久久精品黑人| 少妇精品久久久一区二区三区 | 久久男人中文字幕资源站| 久久精品国产91久久综合麻豆自制 | 亚洲欧美精品一区久久中文字幕 | 亚洲国产另类久久久精品小说| 中文字幕乱码久久午夜| 亚洲国产香蕉人人爽成AV片久久| 久久精品国产AV一区二区三区| 亚洲中文字幕无码一久久区| 亚洲va中文字幕无码久久不卡| 99久久99这里只有免费的精品| 久久国产精品99久久久久久老狼|