1 | initial version |
It is strange. This code is working for me:
int main( int argc, char** argv )
{
IplImage* gray;
uchar* data;
int m_width;
int m_height;
IplImage * pImgEmbed = NULL;
char filename[] = "baboon.jpg";
gray=cvLoadImage(filename,0);
data=(uchar *)gray->imageData;
m_width=gray->width;
m_height=gray->height;
pImgEmbed=cvCreateImageHeader(cvSize(m_width, m_height), IPL_DEPTH_8U, 1);
cvSetData( pImgEmbed, data, m_width );
cvNamedWindow("sample");
cvShowImage("sample", pImgEmbed);
cvWaitKey(0);
return 0;
}
What version of OpenCV do you use? What OS?