Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

HSV range for Rubik's cube color

Hello everyone ! I'm currently doing an algorithm that allow me to detect the color from a Rubik's cube.

For that, I use OpenCV like this :

    cap.read(frame_RGB);
    bilateralFilter(frame_RGB, filter, 9, 75, 75);
    cvtColor(filter, frame_HSV, cv::COLOR_BGR2HSV); // Change from RGB to HSV

    // For each color, detect if there is the color in the frame
    for (int i = 0; i < this->minColor.size(); i++){
        inRange(frame_HSV, this->minColor[i], this->maxColor[i], frame_threshed);
        threshold(frame_threshed, result, 127, 255, 0);
        findContours(result, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
    }

with

/*White - Green - Red - Blue - Orange - Yellow */
this->minColor = { Scalar(70, 10, 130), Scalar(60, 110, 110), Scalar(120, 120, 140), Scalar(100, 100, 100), Scalar(5, 150, 150), Scalar(20, 100, 100) };
this->maxColor = { Scalar(180, 110, 255), Scalar(100, 220, 250), Scalar(180, 250, 200), Scalar(130, 255, 255), Scalar(15, 235, 250), Scalar(40, 255, 255) };

My problem is that I'm not sure for the choose of colors (Scalar structure). So I would like to know if someone know how to determine the range of color for each rubik's color accurately..

Thanks a lot!