2

Well this is the problem. I should make graphic display of video where someone is playing tic tac toe. I detected lines on frame using HoughLinesP, but now I should make 9 ROI for nine cells in grid to detect what is where drawn.How should I do ti, I have onlu video and lines. One of the problems is that HoughLinesP gives me more than 4 lines , some are shorter than I need so how to automaticly choose and make ROI?It is this part of code:

vector<Vec4i> lines;
    HoughLinesP(dst, lines, 1, CV_PI / 220, 50, 50, 30);
    for (size_t i = 0; i < lines.size(); i++)
    {
        Vec4i l = lines[i];
        line(cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA);

        imshow("detected lines", cdst);

    }

This is a sample image:

tictactoe grid

Dan Mašek
  • 17,852
  • 6
  • 57
  • 85
Kristina Vakarov
  • 181
  • 3
  • 12
  • Any Samples to show ? – Humam Helfawi May 20 '16 at 13:23
  • You can try to use `cv::partition` based on the lines angle and horizontal/vertical position to group them into clusters for each of the actual lines. Reduce each cluster into a single best fit line. Then find intersections. I've got some code here, but it will take some time to write a comprehensive answer to this. – Dan Mašek May 20 '16 at 13:24
  • Can you maybe give me an example, I am looking on google for that but I cant find anything that is clear to me. I found this [link](http://stackoverflow.com/questions/30746327/get-a-single-line-representation-for-multiple-close-by-lines-clustered-together) but I dont understand how to merge it dependig of angle and to draw it? – Kristina Vakarov May 20 '16 at 13:44
  • I have few weeks to make so I will wait if you could answer it :) – Kristina Vakarov May 20 '16 at 16:58
  • If your grid is not moving, you can assign very specific ROI's for each cell instead of going for line detection. – Saransh Kejriwal May 24 '16 at 05:22
  • Its moving but not much, I have rule that I must scan for grid in each frame – Kristina Vakarov May 24 '16 at 10:09
  • I would suggest that you perform color thresholding to binarize the image and extract the grid, then erode the image a few times so that the lines get really really thin. Performing HoughLinesP after that will reduce your noisy lines – Saransh Kejriwal Sep 28 '16 at 15:31

0 Answers0