Recognize black patterns appearing at the four corners of an ios image using opencv or some other technique

I am stuck with a problem that is how to recognize some patterns in the image.

the image is an image of paper that is pure white, and drawings in the four corners are black. I want to recognize black patterns in the image?

I surf the net a lot and find opencv as the answer. but there is nothing that describes how to use opencv to achieve the required function.

Please help me with some coding point of view, or provide some link that I should follow, or any name of any open source library that I should use to achieve this function. Image for the picture below: - enter image description here

The image consists of a pure white background and four black patterns in the corner. I need to recognize these black patterns in all four corners, and then process the image. One corner shown in an oval to highlight it.

Any suggestions would be highly appreciated.

Thanks in advance!

+4
source share
2 answers

Perhaps this question will help you, especially the Tennis Ball link. Recognizing the textbook seems to be pretty much what you are looking for.

Regarding the use of OpenCV on iOS, you can take a look at OpenCV-iOS and Computer Vision with iOS .

+1
source

I really don't understand your problem - if you say:

The image is an image of paper that is pure white, and the drawings are in the four corners of black.

Then what is the task of masking only these four contours from the image? Having made a 4-square mask with a length of 40 pixels, I got the following:

enter image description here

To remove small areas, you can use morphological operations. I got it:

enter image description here

And just draw them (optional) on the input image. Result:

enter image description here

To implement this algorithm, I use the OpenCV library. I am 100% sure that it works on iOS - the OpenCV team has finally published the version of iOS . Therefore, if you say:

I tried to launch the OpenCV-iOS link, but the project does not start, it shows errors.

Then we cannot help you with this, because we are not telepastes to see your problem. Just a small suggestion - try to solve your problem. I am 99% sure that it should help.

And so I don't forget - here is the C ++ code:

Mat src = imread("input.png"), tmp; //convert image to 1bit cvtColor(src, tmp, CV_BGR2GRAY); threshold(tmp, tmp, 200, 255, THRESH_OTSU); //do masking #define DELTA 40 for (size_t i=0; i<tmp.rows; i++) { for (size_t j=0; j<tmp.cols; j++) { if(!((i < DELTA && j < DELTA) || (i < DELTA && j > tmp.cols - DELTA) || (i > tmp.rows - DELTA && j < DELTA) || (i > tmp.rows - DELTA && j > tmp.cols - DELTA))) { //set color to black tmp.at<uchar>(i, j) = 255; } } } bitwise_not(tmp,tmp); //erosion and dilatation: Mat element = getStructuringElement(MORPH_RECT, Size(2, 2), Point(1, 1)); erode(tmp, tmp, element); dilate(tmp, tmp, element); //(Optional) find contours and draw them: vector<Vec4i> hierarchy; vector<vector<Point2i> > contours; findContours(tmp, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); for (size_t i=0; i<contours.size(); i++) { drawContours(src, contours, i, Scalar(0, 0, 255), 1); } 
+3
source

All Articles