My current project is to use OpenCV and a webcam to follow a line with the Lego Mindstorm EV3. That would be black tape on a light background. I have a test image (white left, black right) that I can process. The idea is to use moments to find the x location of the vertical line. I can process my test image with cvtColor, GaussianBlur, threshold, erode, dilate, findContours and drawContour. The white region is seen as a block bounded by the edges of the frame. I can create a black border on the contour image to remove the frame edges. Then I am left with a vertical line. FindContours should find the line. But, findContours is area based and I am trying something that is line based. If I findContours of the vertical line, I go back to the edges. What is the contour of a line? I get three contours. 1 left edge and line. 2 line. 3 right edge and line. I could just use the second contour, but that will not expand to a real image with an unknown number of contours. My idea is to find the x location of the vertical line with moments. I can get the average x location of all the moments, but that is misleading and inaccurate. Or, will I have to use BondingRect.
My problem is with OpenCV. Does anyone know OpenCV well enough to suggest a valid approach to solve this problem?
↧