- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的椭圆随着时间而增长。
为了检测椭圆,我使用了CvInvoke.AbsDiff方法。
我得到这样的图像
我想将此椭圆设置为fit-椭圆方法并获取其半径es。
这就是我采取的方法。
CvInvoke.AbsDiff(First, img, grayscale);
CvInvoke.CvtColor(grayscale, grayscale, ColorConversion.Bgr2Gray);
CvInvoke.GaussianBlur(grayscale, grayscale, new System.Drawing.Size(11, 11), 15, 15);
CvInvoke.Threshold(grayscale, grayscale, Convert.ToInt16(Threshold), Convert.ToInt16(Threshold * 2), ThresholdType.Binary );
Mat element = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Rectangle, new System.Drawing.Size(3, 3), new System.Drawing.Point(-1, -1));
CvInvoke.Dilate(grayscale, grayscale, element, new System.Drawing.Point(-1, 1), 5, BorderType.Constant, new MCvScalar(255, 255, 255));
CvInvoke.Canny(grayscale, grayscale, Threshold, MaxThreshold * 2, 3);
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
CvInvoke.FindContours(grayscale, contours, null, RetrType.Ccomp, ChainApproxMethod.ChainApproxTc89Kcos);
double area = 0;
double ContourArea = 0;
int contour = 0;
int CenterX;
int CenterY;
for (int i = 0; i < contours.Size; i++)
{
System.Drawing.Rectangle rec = CvInvoke.BoundingRectangle(contours[i]);
output.Draw(rec, new Bgr(255, 0, 255), 2);
CenterX = ((rec.Width) / 2) + rec.X;
CenterY = ((rec.Height) / 2) + rec.Y;
ContourArea = rec.Width * rec.Height; ;
if ((HWidth - CenterFactor) < CenterX && CenterX < (HWidth + CenterFactor) && (HHeight - CenterFactor) < CenterY && CenterY< (HHeight + CenterFactor) )
{
if (ContourArea < 1000000)
if (area < ContourArea)
{
area = ContourArea;
contour = i;
}
}
}
//if (contour == 0)
//{
// return arr;
//}
System.Drawing.Rectangle rect = CvInvoke.BoundingRectangle(contours[contour]);
output.Draw(rect, new Bgr(0, 255, 0), 3);
最佳答案
尽管此方法并不完全完美,但这可能是您可能采取的方向。
Mat input = CvInvoke.Imread(@"C:\Users\ajones\Desktop\Images\inputImg.png", ImreadModes.AnyColor);
Mat input2 = input.Clone();
Mat thresh = new Mat();
CvInvoke.GaussianBlur(input, thresh, new System.Drawing.Size(7, 7), 10, 10);
CvInvoke.Threshold(thresh, thresh, 3, 10, ThresholdType.Binary);
CvInvoke.Imshow("The Thresh", thresh);
CvInvoke.WaitKey(0);
Mat output = new Mat();
CvInvoke.CvtColor(thresh, output, ColorConversion.Bgr2Gray);
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
CvInvoke.FindContours(output, contours, null, RetrType.External, ChainApproxMethod.ChainApproxSimple);
CvInvoke.DrawContours(input, contours, -1, new MCvScalar(0, 255, 0), 3, LineType.FourConnected);
CvInvoke.Imshow("The Image", input);
CvInvoke.WaitKey(0);
int biggest = 0;
int index = 0;
for (int i = 0; i<contours.Size; i++)
{
if (contours[i].Size > biggest)
{
biggest = contours[i].Size;
index = i;
}
}
CvInvoke.DrawContours(input2, contours, index, new MCvScalar(0, 255, 0), 3, LineType.FourConnected);
CvInvoke.Imshow("The Image2", input2);
CvInvoke.WaitKey(0);
关于c# - 使用CVInvoke.AbsDiff方法从 mask 中检测椭圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61944191/
我正在尝试使用蒙版计算两个图像的绝对差异,因此在计算差异时只考虑图像的一个区域。但是 OpenCV 在 its function 中没有掩码部分.我看到了this question但对我不起作用。我试
我试图找到两张图片之间的区别,但是,我正在使用 JavaCV,虽然我发现了一个 openCV 函数,它似乎可以满足我的需要,但我似乎无法让它工作,因为我不确定我如何在 java 中使用 cvAbsDi
OpenCV 的 cv::absdiff(InputArray src1, InputArray src2, OutputArray dst) 使用什么方法/算法? 对于 1 channel Mat,
我正在使用 cv2::absdiff() 从图像矩阵中减去标量。我使用的代码是: double min; double max; Scalar mean; Scalar std_dev
我正在尝试使用 OpenCv 从图像中检测条形码,我正在使用渐变法:http://www.pyimagesearch.com/2014/11/24/detecting-barcodes-images-
我一直在研究一个通过背景减去来检测手的程序。我试图将相机的第一帧保存为背景并减去当前帧,但它们似乎以某种方式具有不同的亮度。我已经试了好几次了,但我没有换灯,可能是什么问题? image1 image
使用 Peano 风格的类型级自然函数,编写绝对差异类型级函数(又名类型族)相当容易: {-# LANGUAGE DataKinds, StandaloneKindSignatures, TypeFa
如何使用 magnitude和 absdiff ?我阅读了the documentation中的解释,但每次它都会出错,因为我不明白输入数组和输出究竟应该如何。应该是vector , Mat或 Sca
有谁知道如何让 absdiff 在 opencv 中工作。以下代码给出错误: @Override public void onManagerConnected(int status) {
这是来自 C++ 的示例: cv::absdiff(input,cv::Scalar(target),output); 其中 target 是 cv::Vec3b [190, 119, 102] 我在
是否可以在没有临时 img 的情况下计算 cv2.absdiff(img1, img2).sum() ? 我有一个视频流,我需要在处理开始时进行某种图像稳定。absdiff 在使用以下两个图像检查不同
我是一名优秀的程序员,十分优秀!