Ask Your Question

Torlek's profile - activity

2013-06-01 16:03:10 -0600 received badge  Editor (source)
2013-06-01 16:00:02 -0600 asked a question A problem met in using cvInRange

Hi: I'm new to get my hand on opencv. In order to seprate specified object with specified color in image, I used cvInRange, but it fails with some exception. Since I compiled it using vc+clr and did not use the debug static libs, I cannot see anything on the information should be contained in the exception thrown. I ask for help in determine the problem which caused the program failing. Let me describe the program flow short:

 //get image from cam
 IplImage* frame = cvQueryFrame( capture );
 //convert to hsv space
 cvCvtColor( frame , frame , CV_BGR2HSV );
 //conversion completed, set some Scalar
  CvScalar color1;
  CvScalar color2;

color1.val[0] = 113/2;
color1.val[1] = 100;
color1.val[2] = 100;
color1.val[3] = 0;

color2.val[0] = 205/2;
color2.val[1] = 255;
color2.val[2] = 255;
color2.val[3] = 0;

 //create destine mask
 IplImage* imageMask = cvCreateImage(cvGetSize(frame),
IPL_DEPTH_8U, 3);
 //get the points
 cvInRange( frame, 
&color1, 
&color2,
imageMask);
 //cvInRangeS fails as well...
 /*cvInRangeS( frame, 
color1, 
color2,
imageMask);*/
 The program fails the last statement. I tried several days on this, and cannot resolve this, can any one help find out what the problem is?