Ask Your Question

Shunpo's profile - activity

2020-02-12 16:12:10 -0600 received badge  Famous Question (source)
2018-04-23 10:25:34 -0600 received badge  Notable Question (source)
2017-10-23 04:16:48 -0600 received badge  Popular Question (source)
2016-04-28 10:40:13 -0600 received badge  Scholar (source)
2016-04-27 23:50:25 -0600 asked a question 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!