我使用https://github.com/shimat/opencvsharp包装器在 C# 中使用 opencv。
其实我想得到我countours的最大边界框。倾斜无关紧要。我想要一个完美的直盒。
找到轮廓后我的实际结果如下所示:
这是我的代码:
Mat src = new Mat("index.jpg", ImreadModes.GrayScale);
// Mat src = Cv2.ImRead("lenna.png", ImreadModes.GrayScale);
Mat dst = new Mat();
Mat dst2 = new Mat();
Cv2.Canny(src, dst, hScrollBar1.Value, hScrollBar2.Value);
//using (new Window("src image", src)) ;
//using (new Window("dst image", dst)) ;
// Find contours
OpenCvSharp.Point[][] contours; //vector<vector<Point>> contours;
HierarchyIndex[] hierarchyIndexes; //vector<Vec4i> hierarchy;
Cv2.FindContours(dst, out contours, out hierarchyIndexes, RetrievalModes.External, ContourApproximationModes.ApproxSimple);
using (new Window("dst image", dst)) ;
我看到有一个函数 BoundingRect
Cv2.BoundingRect()
听起来对我来说是正确的。但是这个函数需要一个名为 curve 的 InputArray。我有点困惑。
如果有人能给我一个提示,那就太好了。
智慧大石
MYYA
相关分类