2016-06-11 5 views
0

일련 번호가있는 비디오가 있습니다. 사진 에서처럼. openCV가이 수호자의 위치를 ​​어떻게 감지 할 수 있습니까? 내가 필요한 건이 후원자의 위치를 ​​알아내는 것 뿐이야. 항상이 후원자는 12 개의 숫자를 가지며 흰색 일 것입니다.openCV로 일련 번호 검색

example

+0

흰색 문자. –

+0

그림의 오른쪽 구석에있는 12 개의 숫자를 찾아야합니다. 숫자는 0에서 9까지입니다. – user3373406

+0

텍스트가 항상 흰색이고 같은 위치에 표시되면 OpenCV를 사용할 필요가 없을 것입니다. 이미지의이 섹션을 잘라내어 검정색 바탕에 흰색 텍스트를 얻기위한 임계 값을 지정하고 tesseract와 같은 OCR 소프트웨어를 사용하여 문자를 식별하십시오. –

답변

0

당신은 숫자의 위치를 ​​찾을 수 있습니다 Morphological Transformations를 사용하여.

은 (, 그냥 명령입니다없는 완벽한 코드) 아래의 코드를 시도 당신은 또한 (12)이있는 문자 "카타르 항공"을 구별해야한다 무엇 이건

#include <opencv2/opencv.hpp> 

using namespace cv; 
using namespace std; 

int main(int argc, char** argv) 
{ 
    Mat src=imread("dnpaP.jpg"); 
    Mat thresh = src.clone(); 

    dilate(thresh,thresh,Mat(),Point(-1,-1), 5); 
    erode(thresh,thresh,Mat(),Point(-1,-1), 5); 
    cvtColor(thresh, thresh, COLOR_BGR2GRAY); 
    threshold(thresh, thresh, 200, 255, THRESH_BINARY); 
    erode(thresh,thresh,Mat(),Point(-1,-1), 3); 
    dilate(thresh,thresh,Mat(),Point(-1,-1), 3); 

    vector<vector<Point> > contours; 

    findContours(thresh.clone(), contours, RETR_LIST, CHAIN_APPROX_SIMPLE); 

    for(size_t i = 0; i< contours.size(); i++) 
    { 
     Rect boundingRect_ = boundingRect(contours[i]); 
     if(boundingRect_.width > boundingRect_.height * 12) 
     rectangle(src,boundingRect_,Scalar(0,0,255),2); 
    } 
    imshow("thresh",thresh); 
    imshow("src",src); 
    waitKey(); 
} 

enter image description here enter image description here

+0

감사합니다. 아주 좋습니다. – user3373406