Ask Your Question

Revision history [back]

How to convert Mono Image to HSV?

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 "", 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