1 | initial version |
First, debug your algorithm. Display the number of detected lines, eventually the coordinates.
You'll see that your algorithm detects thousands of lines, which is not good. Draw all of them to see what's happening.
First, all the black lines and points are detected. So it's the best to filter them out. Detecting only a colored line will spare you from further problems.
If you already work with lines, doing a Canny filtering will add parasite lines (one line will become two - at both sides of the original line). So you can work with the original binarized image.
You'll also see that reducing the image size will ameliorate the results of the algorithm: the irregularities of the line will be less visible and less partial lines will be detected.
Then, fine tune the parameters of the Hough transform (theta, rho, threshold etc.) until you get the desired results.
To detect the points of the board, you can use the Harris detector. Than, it's easy to get the central point.
Glad to have saved your life.