drawContours throws exception
Hello, I use opencv3.3.1 from ros-kinetic When executing this code
vector <vector <Point2i> > testContour; vector <Point2i> testedge; testedge.push_back(Point2i(240,240)); testedge.push_back(Point2i(120,240)); testedge.push_back(Point2i(120,120)); testedge.push_back(Point2i(240,120)); testContour.push_back(testedge); vector <Point2i> testedge2; testedge2.push_back(Point2i(200,200)); testedge2.push_back(Point2i(100,200)); testedge2.push_back(Point2i(100,100)); testedge2.push_back(Point2i(200,100)); testContour.push_back(testedge2); drawContours(image, testContour, -1,/*it->getColor()*/Scalar(255,255,255),CV_FILLED,LINE_8);
i get the following error:
OpenCV Error: Assertion failed (reader.ptr != __null) in cvDrawContours, file /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/imgproc/src/drawing.cpp, line 2603 terminate called after throwing an instance of 'cv::Exception' what(): /tmp/binarydeb/ros-kinetic-opencv3-3.3.1/modules/imgproc/src/drawing.cpp:2603: error: (-215) reader.ptr != __null in function cvDrawContours
now this only happens after updating the ros packages... before it ran fine.....
now i don't understand why exactly the reader.ptr() is __null, since my counturs vector is filled as u can see above, also google is quite emoty of that problem.
best regards, homes
edit: it works now with the testContour, but it doesn't appear to work with a dynamically filled Contour vector. Am I correct in my assumption, that this means i am trying to pass a undefined pointer to the drawContours function?
probably you used undefined
edgeVector
try
yep, that was one problem, but edgeVector is a dynamic generated vector<vector<point2i> > , it may be possible, that i'm passing point coordinates out of bounds of the matrix, i'm checking that right now. If that isn't the case i', clueless ...again. edit: the values of the points in the ContourVector are in range of the matrix.
I have the same problem, did you find a solution to your problem?
Thanks!
@jproberge, please do not post answers here, if you have a question or comment, thank you !
(and read above again, it is anwered.)
@berak: please read above again, it is not fully answered yet, and thus the reason why I posted my comment in the first place. "[...] it doesn't appear to work with a dynamically filled Contour vector. Am I correct in my assumption, that this means i am trying to pass a undefined pointer to the drawContours function?". I have the exact same question and concern so please don't consider this as being a closed issue. If anyone has an answer to that question, I would be happy to hear it. Thanks.
@jproberge, rather ask a new question, with your own context. (i doubt, that you're using ROS here)
@berak: Hum... ok so listen, I'm using ros kinetic on Ubuntu 16.04 exactly like the OP. And guess what, I have exactly the same version of OpenCV (3.3.1). I have the exact same context than him. I use a camera and a UR10 robot on ROS and I face the exact same issue. Please stop making assumptions about stuff you have absolutely no idea about. Do you really want me to ask a new question? Because, I'm basically going to ask exactly the same question as the original poster. Thanks
@jproberge,
(3.3.1) -- outdated, probably none here can help you with specific problems related to that.
also silly as it is, ROS insists to install it's own (again outdated) opencv version, more problematic, than useful, ever.
missing context above, code snippet not leading anywhere.
again, please ask your own question (and give your own, specific context ! instead of holping to solve it from here.
Wow, I'm really flabergasted. "Outdated" you say?? It's a version that was released not even 6 months ago!! And yet you think we should not ask questions about it? Do you imagine that everyone everywhere update their library as soon as there's a new release? As you said yourself, most of ros users have opencv 3.3.1, so should they not ask any questions? I still think you don't get the words "same exact context". You want a code snippet? I'm just gonna have to copy-paste the one from the OP then, if you'd like. Or change the name of the variables if you think that would be more acceptable! I'm gonna stop writing now, this is pointless.
Bottom line is, the original poster posted a question. It is not fully answered yet. If anyone has an answer that would be great ...(more)
bottom line here: please ask your own question. (reference the other, nonetheless, but we need to see your specific context)
(having said that, no ROS specific question was EVER succesfully answered from here. wrong forum to ask ?)