Opencv使用drawcontours来显示轮廓,但得到空白窗口

时间:2014-03-19 02:25:19

标签: opencv

我想从一组轮廓中显示一些轮廓,但我只是空白窗口。我的代码:

……………………………………
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 );

1 个答案:

答案 0 :(得分:0)

我想我有理由。在上面的代码中,没有错误。我得到空白窗口的原因是我使用Visual Studio 2013编译代码,但我的OpenCV适用于Visual Studio 2010。抱歉,我的错误。转到项目 - 属性 - 配置属性 - 常规 - 设置Plattform工具集:&#34; Visual Studio 2010(v100)&#34;。