我想从一组轮廓中显示一些轮廓,但我只是得到空白窗口。我的代码:
……………………………………
vector<vector<Point>> curvePointSet1;//contours from image1;
vector<vector<Point>> curvePointSet2;contours from image2;
vector<Point> curveMathcePair;//matched contour(curve) pairs,(x,y) stand for corresponding curves from image1 and image2
Mat img1 = Mat( Size( 640, 480 ), CV_8U ,Scalar(0));
Mat img2 = Mat( Size( 640, 480 ), CV_8U ,Scalar(0));
for (int i = 0; i < curveMathcePair.size();i++)
{
vector<vector<Point>> curveTemp1, curveTemp2;
curveTemp1.push_back( curvePointSet1[curveMathcePair[i].x] );//curveMathcePair[i].x stand for curve form image1,and its corresponding curve form image2 denote as curveMathcePair[i].y;
curveTemp2.push_back( curvePointSet2[curveMathcePair[i].y] );
drawContours( img1, curveTemp1,0, Scalar(255),1 );
drawContours( img2, curveTemp2,0, Scalar(255),1 );
}
imshow( "img1", img1 );
imshow( "img2", img2 );
我想我明白了。在上面的代码中,没有错误。我得到空白窗口的原因是我使用了Visual Studio 2013来编译代码,但我的OpenCV适用于Visual Studio 2010。为我的错误道歉。进入项目-属性-配置属性-通用-设置平台工具集:"Visual Studio 2010 (v100)"