cvtColor and inRange in single pass? [closed]

asked 2017-06-26 11:03:58 -0500

Hi, I am new to OpenCV, but have plenty of programming experience. I have played around with image detection based on color. Everyone's code does something like:

hsvFrame = cv2.cvtColor( frame, cv2.COLOR_BGR2HSV )
mask = cv2.inRange( hsvFrame, lowLimitHSV, highLimitHSV )

This does work, but seems inefficient. At least for my task (and others I saw on the web), the HSV frame is only needed to do the thresholding.

My question is: why is there no standard routine to combine cvtColor and inRange in a single pass? Has it been tried? Is it not efficient enough? Just trying to get an idea.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-08 10:26:44.751135


how and why would your idea be more efficient ?

berak gravatar imageberak ( 2017-06-26 11:51:52 -0500 )edit

I am guessing that a single pass through the frame data is faster than 2 passes. Also, it certainly saves some memory, since you don't need to keep the hsvFrame data.

prensing gravatar imageprensing ( 2017-06-26 13:24:21 -0500 )edit

stop guessing. full stop.

berak gravatar imageberak ( 2017-06-26 13:32:08 -0500 )edit

I am also looking for a way to combine these calls. Why wouldn't a single pass be faster berak?

bhj gravatar imagebhj ( 2017-12-18 23:05:51 -0500 )edit

again, forget that idea. putting it in a single call would not reduce the operations required, and both are needed seperate from each other.

berak gravatar imageberak ( 2017-12-19 02:57:23 -0500 )edit