I'm writing a simple algorithm to convert a RGB image, from my webcam, to HSV, it's compiling fine, but crashes when the .exe is executed.
#include <cv.h>
#include <highgui.h>
int main(int argc, char** argv)
{
// Cria uma janela.
cvNamedWindow("imagem", CV_WINDOW_AUTOSIZE);
// Cria a conexão com a webcam.
CvCapture *capture = cvCreateCameraCapture(0);
// Variável que armazena o frame.
IplImage *frame;
IplImage* imghsv = cvCreateImage(cvGetSize(frame),8,3);
while(1)
{
// Variável recebe o frame.
frame = cvQueryFrame(capture);
if(!frame) break;
cvCvtColor(frame, imghsv, CV_BGR2HSV);
// Exibe o frame na janela.
cvShowImage("imagem", frame);
cvShowImage("hsv", imghsv);
// Encerra o loop com uma tecla.
if( cvWaitKey(100) == 27 ) break;
}
// Libera a memória utiliazada.
cvReleaseImage(&frame);
cvReleaseImage(&imghsv);
cvReleaseCapture(&capture);
// Fecha a janela.
cvDestroyWindow("imagem");
cvDestroyWindow("hsv");
}
Without the line "IplImage* imghsv = cvCreateImage(cvGetSize(frame),8,3);" the .exe works, but the algorithm only shows my image.
I'm using Dev C++ 4.9.9.2 and OpenCV 2.1 in Windows XP SP3. Sorry about the english. Thanks
The problem was solved replacing IplImage *frame;
by IplImage *frame=cvQueryFrame(capture);
.