We're trying to make game called PaperSoccer using C++ and OpenCV.
Original board looks like this :
And picture with one move looks like this :
We're using perspective transform to remove the perspective in the second picture and we're able to find coordinates of points (dots).SOURCE CODE
We want to detect the place where the move was made and move it to the original board. We tried to use
absdiff(img1,img2,result)
to find the difference between the board and the photo, and then use
int DetectLines(Mat src, const char* sourceName, const char* destName){
Mat dst, cdst;
Mat zapisz;
zapisz = imread("plansza3.jpg",0);
Canny(src, dst, 50, 200, 3);
cvtColor(dst, cdst, COLOR_GRAY2BGR);
vector<Vec4i> lines;
HoughLinesP(dst, lines, 1, CV_PI / 180, 20, 10, 5);
for (size_t i = 0; i < 1; i++){
Vec4i l = lines[i];
line(zapisz, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, 2);
}
imshow(destName, zapisz);
return 0;
}
to find line and draw it on the board, but it's not working.
The most important is the fact that we need coordinates of the line (move) for the logic of the game, ie two points. We do not necessarily have to transfer it to the original board, but we must in some way convey that the center point in the picture corresponds to the center point on the original board etc.
Please, help us, it's a matter of life and death;)