Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's quite easy to find all markers using code similar to yours - you just have to convert image to HSV colour space and than use inRange function - HSV color space is better for such tasks, because it 'focuses' on colours, not on brightness. This code:</p> <pre><code>Mat m = imread("D:\\face.jpg"), m2, m3; cvtColor(m, m, CV_RGB2HSV); resize(m, m, Size(m.cols/2, m.rows/2)); inRange(m, Scalar(0, 90, 50), Scalar(15, 175, 190), m2); imshow("qwe", m); imshow("qwe2", m2); dilate(m2, m3, Mat()); imshow("qwe", m); imshow("qwe2", m2); imshow("qwe3", m3); waitKey(-1); return 0; </code></pre> <p>Few things about this code:<br> - of course you have to change path to file<br> - resize is not important - i have used it only, because image is to big for my screen<br> - values of inRange scalar can be easily found by looking at displayed image in HSV (OpenCV shows each image with 3 channels as RGB image, so it will look a bit weird) - just read the values from bottom of a window(probably you have to build OpenCV with QT for this, otherwise the window won't have this informations): <img src="https://i.stack.imgur.com/zEehG.png" alt="enter image description here"> Note - values are in other order than usually(HSV), so if you read for example colour (a, b, c) from the bottom of the screen, you should use Scalar(c, a, b). </p> <p>Result after inRange:<br> <img src="https://i.stack.imgur.com/8wCaL.png" alt="enter image description here"> Final result:<br> <img src="https://i.stack.imgur.com/xWSfn.png" alt="enter image description here"><br> As you can see, there are others objects on images, but there should be easy to detect and erase - just look for markers only in region with face(use face detection) or simply for each contours find it bounding rect and check what percentage of bounding rect area is contour area - if this value is small than drop this contours(because it's not similar to circle).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload