【发布时间】:2012-02-29 05:24:27
【问题描述】:
我正在尝试使用以下代码使用 OpenCV 2.1(今天才开始)、C++ 读取图像。 我看不出下面有什么问题。如果你能提供一些帮助,谢谢。
int main( int argc, char** argv )
{
int height,width,step,channels;
//Load the image and make sure that it loads correctly
IplImage* im = cvLoadImage("kermit.jpg", 1);
if(!im )
{
//Drop out if the image isn't found
cout << "Failed to load: "<<"kermit.jpg"<<"\n";
return 0;
}
else
{
cout<<"Image was loaded with success "<<"kermit.jpg"<<"\n";
return (0);
}
height=im->height;
width=im->width;
step=im->widthStep;
channels=im->nChannels;
cout<<"(height, width)"<<height<<width<<"\n";
cvNamedWindow("kermit.jpj",CV_WINDOW_AUTOSIZE);
cvShowImage( "kermit.jpg", im );
cvWaitKey(0);
cvDestroyWindow ("kermit.jpg");
return 0;
}
【问题讨论】: