本文整理汇总了C#中OpenCvSharp.IplImage.DrawPolyLine方法的典型用法代码示例。如果您正苦于以下问题:C# IplImage.DrawPolyLine方法的具体用法?C# IplImage.DrawPolyLine怎么用?C# IplImage.DrawPolyLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.IplImage
的用法示例。
在下文中一共展示了IplImage.DrawPolyLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: routine
/// <summary>
/// Обработка изображения выполняющаяся в отдельном потоке
/// </summary>
private void routine()
{
IplImage cam = new IplImage(Camera.FrameSize, BitDepth.U8, 3);
CvPoint[] mostLengthHole = new CvPoint[0];
RoutineAction innerAction;
bool innerIsRunOnce;
while(isRunning)
{
// Копируем новое значение состояния
innerAction = action;
innerIsRunOnce = isRunOnce;
// Определяем что будем делать в следующем цикле
if (innerIsRunOnce) action = RoutineAction.Pause;
// Если поток на паузе, то ничего не делаем
if (innerAction == RoutineAction.Pause) continue;
if (isRunning && BeforeProcessingEvent != null) BeforeProcessingEvent();
// Захватываем изображение с камеры
Camera.GetIplImage(ref cam);
if (innerAction == RoutineAction.FindContour || innerAction == RoutineAction.Measure)
{
mostLengthHole = Finder.FindMostLengthHole(cam);
}
if (innerAction == RoutineAction.DrawCorners || innerAction == RoutineAction.Calibrate)
{
Calibrator.SetImage(cam);
}
switch (innerAction)
{
case RoutineAction.GetImage:
{
if (isRunning && GetImageEvent != null) GetImageEvent(cam.ToBitmap());
break;
}
case RoutineAction.DrawCorners:
{
Calibrator.FindCorners();
if (isRunning && DrawCornersEvent != null) DrawCornersEvent(cam.ToBitmap());
break;
}
case RoutineAction.Calibrate:
{
bool result = Calibrator.TryToCalibrate(out Transformer);
if (isRunning && CalibrateEvent != null) CalibrateEvent(result);
break;
}
case RoutineAction.FindContour:
{
if (mostLengthHole.Length > 0) cam.DrawPolyLine(new CvPoint[][] { mostLengthHole }, true, Cv.RGB(0, 255, 0), 2);
if (isRunning && FindContoursEvent != null) FindContoursEvent(cam.ToBitmap());
break;
}
case RoutineAction.Measure:
{
if (mostLengthHole.Length > 0)
{
CvPoint2D32f[] realPoints = Transformer.GetRealPoints(mostLengthHole);
CvCircleSegment realCircle = CircleApproximator.Approximate(realPoints);
CvCircleSegment imageCircle = CircleApproximator.Approximate(mostLengthHole);
// Вносим поправки
float ratio = imageCircle.Radius / realCircle.Radius;
realCircle.Radius = realCircle.Radius * CorrectionMultiplier + CorrectionOffset;
imageCircle.Radius = imageCircle.Radius * CorrectionMultiplier + CorrectionOffset * ratio;
int circleRadius = (int)Math.Round(imageCircle.Radius);
CvPoint circleCenter = new CvPoint
(
(int)Math.Round(imageCircle.Center.X),
(int)Math.Round(imageCircle.Center.Y)
);
// Обводим внутреннюю границу кольца
if (circleRadius > 0) cam.DrawCircle(circleCenter, circleRadius, Cv.RGB(0, 0, 255), 2);
// Отмечаем откалиброванную зону
cam.DrawPolyLine(new CvPoint[][] { Calibrator.CalibratedZone }, true, Cv.RGB(255, 255, 0), 2);
if (isRunning && MeasureEvent != null) MeasureEvent(cam.ToBitmap(), realCircle.Radius);
}
break;
}
}
}
//.........这里部分代码省略.........