Ask Your Question

Revision history [back]

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy.image descriptionimage descriptionimage descriptionimage description

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy.Enjoy. I don't ask about solving it or color detection. It is regarded just as a box.image descriptionimage descriptionimage descriptionimage description

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy. I don't ask about solving it or color detection. It is regarded just as a box.image descriptionimage descriptionimage descriptionimage descriptionAs computer vision practitioners have already guessed, the pictures presented are the best. Just turn it 40 degrees and the perfect result goes bust. Detecting contours works better, but it is rather time-consuming. It produces many duplicates. I tried Canny only.image description You see that many squares are lost because their contours were rejected. If I replace

approx.size()==4&&fabs(contourArea(Mat(approx)))>100&&isContourConvex(Mat(approx)))

by

fabs(contourArea(Mat(approx)))> 100)

they appear and the central knot may be detected.image description

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy. I don't ask about solving it or color detection. It is regarded just as a box.image descriptionimage descriptionimage descriptionimage descriptionAs computer vision practitioners have already guessed, the pictures presented are the best. Just turn it 40 degrees and the perfect result goes bust. Detecting contours works better, but it is rather time-consuming. It produces many duplicates. I tried Canny only.image description You see that many squares are lost because their contours were rejected. If I replace

approx.size()==4&&fabs(contourArea(Mat(approx)))>100&&isContourConvex(Mat(approx)))

by

fabs(contourArea(Mat(approx)))> 100)

they appear and the central knot may be detected.image descriptionNot only the functions used, but also their sequence matters. Initially, I converted color image to gray, then fed it to Canny. squares.cpp hints another approach. We can extract separate channels, apply Canny,image description then mix results.image description Almost perfect edges make it possible to reconstruct 3 necessary lines.image description

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy. I don't ask about solving it or color detection. It is regarded just as a box.image descriptionimage descriptionimage descriptionimage descriptionAs computer vision practitioners have already guessed, the pictures presented are the best. Just turn it 40 degrees and the perfect result goes bust. Detecting contours works better, but it is rather time-consuming. It produces many duplicates. I tried Canny only.image description You see that many squares are lost because their contours were rejected. If I replace

approx.size()==4&&fabs(contourArea(Mat(approx)))>100&&isContourConvex(Mat(approx)))

by

fabs(contourArea(Mat(approx)))> 100)

they appear and the central knot may be detected.image descriptionAnother shortcoming of contours. Probably they are the best for this concrete task, but I hope that my program will work for other boxes too. They have no squares. The typical pattern is lines of text intermingled with some pictures. I still believe that line detection has perspectives. Not only the functions used, but also their sequence matters. Initially, I converted color image to gray, then fed it to Canny. squares.cpp hints another approach. We can extract separate channels, apply Canny,image description then mix results.image description Almost perfect edges make it possible to reconstruct 3 necessary lines.image description

3D reconstruction of Rubik's cube. Did you try it?

The task seems elementary at first glance, but try and it turns out to be tricky. Meanwhile this is just a geometric puzzle and a perfect application for various OpenCV methods. Enjoy. I don't ask about solving it or color detection. It is regarded just as a box.image descriptionimage descriptionimage descriptionimage descriptionAs computer vision practitioners have already guessed, the pictures presented are the best. Just turn it 40 degrees and the perfect result goes bust. Detecting contours works better, but it is rather time-consuming. It produces many duplicates. I tried Canny only.image description You see that many squares are lost because their contours were rejected. If I replace

approx.size()==4&&fabs(contourArea(Mat(approx)))>100&&isContourConvex(Mat(approx)))

by

fabs(contourArea(Mat(approx)))> 100)

they appear and the central knot may be detected.image descriptionAnother shortcoming of contours. Probably they are the best for this concrete task, but I hope that my program will work for other boxes too. They have no squares. The typical pattern is lines of text intermingled with some pictures. I still believe that line detection has perspectives. Not only the functions used, but also their sequence matters. Initially, I converted color image to gray, then fed it to Canny. squares.cpp hints another approach. We can extract separate channels, apply Canny,image description then mix results.image description Almost perfect edges make it possible to reconstruct 3 necessary lines.image description