我正在尝试使用OpenCV将图像加载到窗口上,但我继续在Imshow
处获得断点。这是我在教程中遵循的代码。
namedWindow("result", CV_WINDOW_AUTOSIZE );
Mat image ;
// image = imread( "Particle", 1 );
String inputName;
for( int i = 1; i < argc; i++ )
{
inputName.assign( argv[i] );
}
if( inputName.empty() || (isdigit(inputName.c_str()[0]) && inputName.c_str()[1] == '\0') )
{
if( inputName.size() )
{
image = imread("Particle.png", 1 );
}
else
{
if(image.empty()) cout << "Couldn't read image" << endl;
}
imshow("result",image);
}
答案 0 :(得分:1)
尝试更简单的事情:
int main(int argc, char **argv) {
string imgpath = argv[1]; // call me : prog imgpath [on the cmdline]
Mat m = imread(imgpath);
imshow("lala", m);
waitKey(0);
}