contourArea example is wrong (Bug #967)
Description
The docs page at: http://opencv.willowgarage.com/documentation/cpp/imgproc_structural_analysis_and_shape_descriptors.html#cv-contourarea
Gives the following example:
vector<Point> contour;
contour.push_back(Point2f(0, 0));
contour.push_back(Point2f(10, 0));
contour.push_back(Point2f(10, 10));
contour.push_back(Point2f(5, 4));
double area0 = contourArea(contour);
vector<Point> approx;
approxPolyDP(contour, approx, 5, true);
double area1 = contourArea(approx);
cout << "area0 =" << area0 << endl <<
"area1 =" << area1 << endl <<
"approx poly vertices" << approx.size() << endl;
The library does not seem to implicitly convert the vector<Point> into a Mat so this example does not work. I suspect the calls to contourArea(approx) should read: contourArea(Mat(approx))
History
Updated by Ilya Lysenkov almost 14 years ago
- Status deleted (
Open)
Updated by Ilya Lysenkov almost 14 years ago
Yes, you were right, the correct version had to be contourArea(Mat(approx)). But the new InputArray class (in trunk) works as a proxy type for Mat, vector and others types. So the example is compiled successfully now using the trunk version.
- Status set to Done
- (deleted custom field) set to obsolete