Reputation:
I am trying to filter out a traffic light from the camera feed of my autonomous robot. I convert the captured frames into HSV colourspace, threshold them until I can get to detect all red objects that are roughly as "red" as the traffic light, then I apply Hough transform to find out the red light among them( which is obviously a circle).
Now the problem here is that I found that Hough transform only works with single channel images, and I seem to be working with three, so I tried converting the HSV thresholded image to Grayscale using the following code-
imgFinal = thresholded #initialising the variable with the thresholded image.
framenew = cv2.cvtColor(threshNew, cv2.COLOR_HSV2GRAY)
However during runtime I get an error saying 'module' object has no attribute 'COLOR_HSV2GRAY'. I found several questions regarding this topic but none were the answer to my problem. I only have to detect the red traffic light, I tried seperating the channels but I don't have any idea how to proceed with that approach. I am also open to any other approaches.
Thank you!
P.S- This might be off topic, but which language you all suggest for this project? C++ or Python? I've written the code for both, I'm just confused about which one to use. I'm currently developing it on my Windows 8.1 PC but it needs to run on the Raspberry Pi 3 for the final project.
Upvotes: 0
Views: 5041
Reputation: 20130
HSV's V channel is something like a grayscale image, but it is not identical to a BGR2GRAY grascale image.
This is a grayscale image computed from BGR2GRAY:
while this is the V channel of the HSV image:
If you need something "better", you can always convert your HSV image back to BGR and convert the BGR to GRAY with openCV codes.
Upvotes: 1