简体   繁体   English

我在OpenCV中有错误“ approxPolyDP(ROI_Vertices,ROI_Poly,1.0,true)”

[英]I have mistake “approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, true)” in OpenCV

I don't know what I've done wrong. 我不知道我做错了什么。

Mat mask(img.size(), CV_8UC1, Scalar::all(0));

// Create Polygon from vertices
vector<Point> ROI_Vertices(4);
ROI_Vertices.push_back(Point(196,40));
ROI_Vertices.push_back(Point(47,450));
ROI_Vertices.push_back(Point(204,450));
ROI_Vertices.push_back(Point(275,40));

vector<Point> ROI_Poly;

approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, true);

// Fill polygon white
fillConvexPoly(mask, &ROI_Poly[0], ROI_Poly.size(), 255, 8, 0);

// Create new image for result storage
Mat resImage(480, 640, CV_8UC3);

// Cut out ROI and store it in imageDest
img.copyTo(resImage, mask);
    imshow("h",img);
    imshow("hh",resImage);

I think my program recognize 我认为我的程序可以识别
ROI_Vertices have Point(0,0) ROI_Vertices具有Point(0,0)

How can I fix this? 我怎样才能解决这个问题?

That's simple.Remove the points (0,0). 很简单,删除点(0,0)。 Make the following change 进行以下更改

ROI_Vertices.clear();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM