ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
-1

bgr2hsv oddity

asked 2011-05-09 22:52:22 -0600

sneiman gravatar image

updated 2011-05-13 04:50:07 -0600

mjcarroll gravatar image

Usinge OpenCV cvCvtColor to convert BGR images to HSV. Seems to work fine, but the channel order is not what I expect. Assumed I would see HSV ordering, but using COI or cvSplit, looking visually at the results, it seems that order is VHS. Is this a known bug? Indicative of some error on my part? Or perhaps I am just wrong?

The application is Mac OS X based, and includes a subsystem that performs real time gaze estimation. Coded in Objective C, and OpenCV 2.2 using C interfaces. Current effort is to speed up the adaptive tuning process by using Zheng, Yang and Yang's published methods for pupil detection in HSV space. Basically, mask pupils using H space based mask to reduce number of contours for later processing.

The critical piece of code is dead simple. Convert BGRA image to BGR, BGR to HSV, then split that image into channels. I've tried this using COI access instead of cvSplit with the same result, and with CV_BGR2HSV rather than CV_BGR2HSV_FULL with the same result. H channel on a previously Haar detected CvRect surrounding the eyes should show the pupils as significantly brighter than background - which the second channel does! If this is not a known bug, then I have to assume I am misinterpreting the results. I have been using IPL_DEPTH_8U as it is faster, but of course saturates H. I am going to try it with 32 bit channels to avoid H saturation and see if the visual results are different.

BTW, I am new to the OpenCV/PCL/ROS world and am simply dumbfounded by the quality of work here. Congrats to you all ...

edit retag flag offensive close merge delete

Comments

It's been a long time, but when I did that it worked fine. Maybe you could post more detail (e.g. an minimal code example, images)
Felix Endres gravatar image Felix Endres  ( 2011-05-09 22:53:50 -0600 )edit
I am using cv::cvtColor() and cv::split() with cv::BGR2HSV using OpenCV's C++ API and get the correct channel ordering (i.e. HSV).
mkoval gravatar image mkoval  ( 2011-05-12 04:52:36 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-05-14 09:56:25 -0600

sneiman gravatar image

This is not a bug in OpenCV. It's a bug in my lighting setup. Too much light on the subject, combined with an intermittent spot of light in an otherwise dark background caused the camera to cycle auto-white balance to the point where the pupil representation was frequently dominated by corneal reflection - and the same thing caused the S channel to look like the H channel should have. Sorry for the confusion.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-05-09 22:52:22 -0600

Seen: 1,674 times

Last updated: May 14 '11