We're participating in a contest with our robot, and one of the challenges is to scan a pattern and see which pattern it is. There are 2 possible images(attached below), and for each of them the robot should place a cube in a specific place. We were thinking of using a colour sensor but that's not precise enough. The robot is wired to a smartphone, so we also thought of taking a picture of the pattern and making a java program to interpret it(that's what we've programmed the robot in), but we couldn't find any tutorials about that on the internet. So we will have 2 separate programs, and the only thing we can't work out is how to process an image so we can see which image we got and tell the robot to run the corresponding program. How could actually do this?

The images of the only 2 possible patterns: Pattern 1

Pattern 2


1 Answer 1


A way to tackle this problem (which is very broad in essence) is to use OpenCV to detect the hexagonal shapes in the picture taken by your smartphone. Then, once you know the locations of the figures in the image, extract the color with OpenCV as well and check if certain cell is orange/black to identify one pattern or another (you must know the existent patterns in advance).

The first link I provide is for shape detection with OpenCV in Python: https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/

This one is for object detection in Java: http://opencv-java-tutorials.readthedocs.io/en/latest/08-object-detection.html

Hope this helps.

  • $\begingroup$ @Semetg If you think this is the correct answer to your question, please mark it as the correct one. If you need more information, let us know. $\endgroup$
    – daniglezad
    Mar 5, 2018 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.