jmatraszek
jmatraszek

Reputation: 808

OpenCV -- how to optimize color tracking program?

I want to optimize my program, in which I am using color object tracking algorithm described here. The only difference is that I am using cvBlob library, instead of cv::moments (cvBlob was faster and more accurate). Using profiler (valgrind + kcachegrind) I have found that ~29% of time is taken by colorspace conversion method (cv::cvtColor; I am tracking objects in three colors). I am converting from BGR to HSV.

I've read in some papers that using YCbCr colorspace is even better in color tracking. Is it good idea to convert from BGR to YCbCR? It should be slightly faster, as it requires less multiplications (I am not sure about that -- I do not know how OpenCv does it internally). Does this algorithm need some changes, or can I just convert lower and upper boundaries for tracked color from HSV to YCbCr, and then use inRangeS method, as I did with HSV?

Is there any way to get the frame from driver in YcbCr (or YUV)? I am not asking about HSV, because this is not supported by v4l2, AFAIR.

Do you have any other ideas? I don't want to use IPP or GPU.

Upvotes: 0

Views: 1512

Answers (1)

Abid Rahman K
Abid Rahman K

Reputation: 52646

Check out the OpenCV documentation for cvtColor. It talks about conversion between BGR2YCbCr using cvtColor.

(Please try that and also comment here about result, ie how much percentage of total time it takes in YCbCr mode. Because it will help lots of people in future.)

Upvotes: 2

Related Questions