error when trying to convert rgb to hsv...

asked 2015-12-12 18:10:56 -0600

215 gravatar image

updated 2015-12-12 18:13:30 -0600

I am the moment trying to convert a rgb to hsv, which seems impossible.. I thought i might have been due the Mat being empty.. but thats not the case...

I get this error message.

/build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp:3642: error: (-215) depth == CV_8U || depth == CV_16U || depth == CV_32F in function cvtColor

for these lines of code..

Point find(Mat frame)
{

    Mat imgOriginal = frame.clone();
    Mat imgHSV = frame.clone();

    if (frame.empty())
    {
        cout << "Empty...';
        exit -1;
    }


    cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV

what could be going wrong here???

edit retag flag offensive close merge delete

Comments

1

Check the type of frame (frame.type()), it seems to be unsupported for the function. Also, cloning frame to imgHSV is a waste of time. Apart from that, and maybe unrelated, what version of OpenCV are you using? Because COLOR_BGR2HSV is for 3.0.0, but your error says you're using an installation folder called 2.4.8, and that's weird...

LorenaGdL gravatar imageLorenaGdL ( 2015-12-12 18:34:09 -0600 )edit

oh... yeah.. it looks like i have multiple versions.. but yeah, i need to use the one for 2.4.8...

What types does is support?

215 gravatar image215 ( 2015-12-13 01:43:53 -0600 )edit

The ones indicated in the error message. And I correct myself, I've just discovered that the flag COLOR_BGR2HSV is valid for 2.4 tree too (I though it should be CV_BGR2HSV).

LorenaGdL gravatar imageLorenaGdL ( 2015-12-13 01:50:37 -0600 )edit

but again.. what type am i looking for.. couldn't i just convert it to certain type or something like that?

215 gravatar image215 ( 2015-12-13 01:54:32 -0600 )edit
1

I told you, the needed type is one of the mentioned in the error message: CV_8U or CV_16U or CV_32F. Start by checking which type is your image, to then choose the better convertion.

LorenaGdL gravatar imageLorenaGdL ( 2015-12-13 01:57:38 -0600 )edit