c# 椭圆拟合库_在C#中使用EmguCV(2.4)改进拟合椭圆

我在C#中使用EmguCV 2.4进行图片中椭圆对象的边缘检测和椭圆拟合(例如激光点)。

EmguCV已经实现了使用最小二乘法将椭圆拟合到点云的功能,但是根据它们的角度,椭圆并不适合椭球。

以下是我使用的基本代码:

CHAIN_APPROX_METHOD approxMethod = CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE;

RETR_TYPE RetrType = RETR_TYPE.CV_RETR_LIST;

Bitmap Bmp = new Bitmap(@"C:\Users\pernizki\Downloads\binary2.bmp"); // read Bitmap

Image ImgIn = new Image(Bmp); // Convert to Image<>

Image ImgBin = ImgIn.Convert(); // convert Bgr to Gray

ImgBin = ImgBin.ThresholdBinary(new Gray(140), new Gray(120)).PyrDown().PyrUp(); // convert to binary and reduce noise

ImgBin = ImgBin.Canny(100, 120); // detect the edges from binary image

Contour Contour = ImgBin.FindContours(approxMethod, RetrType); // Get Contour from binary Image

int cntr = 0;

PointF[] ContourPts = new PointF[Contour.Total];

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值