Ask Your Question
0

How to convert Mono Image to HSV?

asked 2016-12-02 18:36:39 -0600

Hello everyone I am getting frame captures from a Point Grey Chameleon a monochromatic camera. Everything is done in python. I am getting a video capture using cap = cv2.VideoCapture(0) [This only works after I installed libdc1394 drivers as it is a 1394 camera].

Anyways when I do print cap.shape it only returns a matrix of two elements, i.e. [480, 640] however when I do hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) it errors out and gives me

 " OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /home/pi/opencv-3.1.0/modules/imgproc/src/color.cpp, line 8141
Traceback (most recent call last):
  File "NormCapt.py", line 14, in <module>
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
cv2.error: /home/pi/opencv-3.1.0/modules/imgproc/src/color.cpp:8141: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor"

From what I understand this is because the cvtColor function expects an image with a matrices of 3 elements instead of my 2 element matrix. How can I fix this problem as I would like to take my mono image and get an HSV image out of it so I can perform better object detection? Thanks

edit retag flag offensive close merge delete

Comments

wait, you do not reallly expect to get a valid hsv image from a grayscale one, do you ?

if your camera outputs monochromatic images, all you have is luminance / intensity. no way ever to get the color/hue back.

berak gravatar imageberak ( 2016-12-02 22:10:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-02 19:01:22 -0600

Tetragramm gravatar image

You do two cvtColor transforms. First you do COLOR_GRAY2BGR, then the COLOR_BGR2HSV.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-02 18:36:39 -0600

Seen: 5,655 times

Last updated: Dec 02 '16