Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvtColor RGB to HSV, different look???

Hello, I would like to convert a stream from my webcam to HSV colorspace.

Therefore I used cvtColor in the following code:

int main()
{
VideoCapture cap(0);
if(!cap.isOpened())
{
cout << "Capture could not be opened succesfully" << endl;
return -1;
}
namedWindow("RGB");
namedWindow("HSV");

while(char(waitKey(1)) != 'q' && cap.isOpened())
{
Mat frame, frame_hsv;
cap >> frame;
cvtColor(frame, frame_hsv, CV_RGB2HSV);

imshow("RGB", frame);
imshow("HSV", frame_hsv);

}
return 0;
}

First I am wondering because if I change CV_RGB2HSV to CV_BGR2HSV there is no difference in the shown images.

In the attached file you can see the output.

Why are the colors in the new "HSV-image" wrong? And what can I do to solve this?

I thougt cvtColor would calculate the matching colors for the new color space.

Thank you :-)

RGBtoHSV.PNG