kaszewczyk
11th December 2012, 20:47
Hello I have a quick question.
Im trying to do some object tracking with OpenCv library, and at one point I wanted to display a thresholded image, but what I got is black square.
Here is code:
QImage Camera::captureTrasholdedImage()
{
IplImage* frame = cvQueryFrame( this->captureHandle );
IplImage* frameHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
cvCvtColor(frame, frameHSV, CV_BGR2HSV);
IplImage* trashold = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
cvInRangeS(frame, cvScalar(170, 160, 160), cvScalar(180,256, 256), trashold);
QByteArray buff(trashold->imageData, trashold->imageSize);
int height = trashold->height;
int width = trashold->width;
QPixmap pix(width, height);
pix.loadFromData(buff);
return pix.toImage();
}
Can someone give me a hint please ?
Im trying to do some object tracking with OpenCv library, and at one point I wanted to display a thresholded image, but what I got is black square.
Here is code:
QImage Camera::captureTrasholdedImage()
{
IplImage* frame = cvQueryFrame( this->captureHandle );
IplImage* frameHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3);
cvCvtColor(frame, frameHSV, CV_BGR2HSV);
IplImage* trashold = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
cvInRangeS(frame, cvScalar(170, 160, 160), cvScalar(180,256, 256), trashold);
QByteArray buff(trashold->imageData, trashold->imageSize);
int height = trashold->height;
int width = trashold->width;
QPixmap pix(width, height);
pix.loadFromData(buff);
return pix.toImage();
}
Can someone give me a hint please ?