Ask Your Question
1

how do i do a multi color tracking?

asked 2013-01-20 15:04:22 -0500

lemon gravatar image

updated 2013-01-20 23:09:58 -0500

Haris gravatar image

I am trying to do a if else statement to color detection, if the cvInRanges detect red, then it will show video with red threshold, here is my code :

 cvCvtColor(frame, hsv_frame, CV_BGR2HSV);
 cvInRangeS(hsv_frame,hsv_min,hsv_max, thresholded);
  if(hsv_min = CvScalar(150 , 84, 130, 0),hsv_max = cvScalar(358, 256, 255, 0));
   {
     cvSmooth( thresholded, thresholded, CV_GAUSSIAN, 9, 9 );
     cvShowImage( "After Color Filtering", thresholded );
    }

the problem occur : in if statement, hsv_min show me a (expression must have bool type) error, how could i overcome it ?

edit retag flag offensive close merge delete

Comments

1

What you want to do with this line "if(hsv_min = CvScalar(150 , 84, 130, 0),hsv_max = cvScalar(358, 256, 255, 0));"

Haris gravatar imageHaris ( 2013-01-20 23:23:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-01-21 08:16:59 -0500

unxnut gravatar image

updated 2013-01-21 08:17:40 -0500

Your if statement assigns the CvScalar value to hsv_min (and hsv_max). You should probably run a minmax on thresholded array to find the pixels in range, or better still, perform an AND operation on thresholded and original to get the matching pixels in their original value.

If you want to stay with your current statement, the boolean type error is from the comma in there. Finally, notice the semicolon at the end of the if statement. You really need to be careful with your semantics.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-01-20 15:04:22 -0500

Seen: 386 times

Last updated: Jan 21 '13