Ask Your Question

mouthbag's profile - activity

2017-04-26 05:38:53 -0600 commented question drawCountours with fixed points not working

Okay, apparently I have to wait until tomorrow to answer my own question. That's why I'm posting a comment and the official answer will follow tomorrow.

I solved the problem by looking at the OpenCV libraries I linked to my build. I was using the "release" libraries for a debug build in Visual Studio. This worked fine until now so I did not notice my mistake.

2017-04-26 03:56:50 -0600 asked a question drawCountours with fixed points not working

Hello Forum,

I need to create a simple mask for an arbitrarily shaped user defined region on interest. I thought using cv::drawContours should fit my purpose. However, I am unable to run my program.

Here is the sample code:

int QtBilderkennung::simpleFunction(){

cv::Mat Image(100, 100, CV_8UC1,cv::Scalar(0)); //Create an empty Mat

std::vector<std::vector<cv::Point>> MyCont;       //Vector for user defined points
std::vector<cv::Point> MyPoint;                          //Vector for contour drawing

//Insert some points for the contour here
MyPoint.push_back(cv::Point(1, 1));
MyPoint.push_back(cv::Point(50, 50));
MyPoint.push_back(cv::Point(70, 70));
MyPoint.push_back(cv::Point(1, 1));

//Add vector with contour to MyCont
MyCont.push_back(MyPoint);

cv::Scalar color(255);
// Draw the countour
cv::drawContours(Image, MyCont, 0, color);
return 0; }

The code compiles without any problems. When I run the function it generates a std::length_error in drawContours(). Hopefully somebody can help me since I can't find anything wrong with the code.

For further intomation I am using VisualStudio 2015 and OpenCV 3.2.(x86) compiled for msvc2015.

Best regards, mouthbag