OpenCV cvInRange() not Working With cvScalar()

I am attempting to use the function cvInRange() from the OpenCV library, however, when I use:

cvInRange(image, cvScalar(100, 0, 0), cvScalar(256, 0, 0), processedImage);

I get the following error:

cannot convert ‘CvScalar’ to ‘const CvArr* {aka const void*}’ for argument ‘2’ to ‘void cvInRange(const CvArr*, const CvArr*, const CvArr*, CvArr*)’
                 cvInRange(image, cvScalar(100, 0, 0), cvScalar(256, 0, 0), processedImage);

Is there a way to specify the minimum and maximum threshold values for cvInRange() as CvArrs to prevent this problem from occurring, or is there some other way to fix this issue?


There are several versions of cvInRange(). The one you want is cvInRangeS(), which takes CvScalar as the two threshold arguments. Replacing the call to cvInRange() with cvInRangeS() will fix your problem.

I think you missed 1 number on your code. I remember that cvScalar have 4 tuple, and must type every number. Example if you user RGB code that have 3 tuple :

RGB = 123,123,123

in cvScalar you must type like this

cvScalar example = cvScalar(123,123,123,0);

Need Your Help

How to tell if no element had a listener called for a click event

javascript events listener handler

I'm trying to find a way to detect if a click event was handled by some element on the page or not. Right now during some of our rendering, the click events are not handled. This is making it diff...

httphandler shared hosting deployment

deployment hosting httphandler shared

I have the httphandler on shared webhosting.