#include<highgui.h>
#include<cxcore.h>
#include<cv.h>
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage("hello.jpg", CV_WINDOW_FULLSCREEN );
int *img_data;
img_data = malloc(sizeof(*img_data)*img->height*img->width*img->nChannels);
if (!img)
{
printf("Image can NOT Load!!!\n");
return 1;
}
cvNamedWindow("myfirstwindow", CV_WINDOW_FREERATIO );
cvShowImage("myfirstwindow", img);
printf("Height: %d\nwidth: %d\nnchannels:%d\n",img->height,img->width,img->nChannels);
cvCvtColor(img,img_data,CV_RGB2XYZ);
cvWaitKey(0);
cvReleaseImage(&img);
return 0;
}
In this program I am trying to convert RGB color model to XYZ color model using function cvCvtColor. And i am getting error shown below:
OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /build/buildd/opencv-2.3.1/modules/core/src/matrix.cpp, line 646 terminate called after throwing an instance of 'cv::Exception'
what(): /build/buildd/opencv-2.3.1/modules/core/src/matrix.cpp:646: error: (-5) Unknown array type in function cvarrToMat
Any help or suggestion will be greatly appreciated. Thank you.