PointCollection類為靜态類 ,Namespace: Emgu.CV
1.通過點集确定矩形
public static Rectangle BoundingRectangle(
PointF[] points
)
2.通過點集确認橢圓
public static Ellipse EllipseLeastSquareFitting(
PointF[] points
)
3.在橢圓周圍生成一個随機點雲。
public static PointF[] GeneratePointCloud(
Ellipse e,
int numberOfPoints // 點的個數
)
4.把點轉換為線
public static LineSegment2D[] PolyLine(
Point[] points,
bool closed
)
public static LineSegment2DF[] PolyLine(
PointF[] points,
bool closed
)
5.單通道像素點轉換到3D數組中
Re-project pixels on a 1-channel disparity map to array of 3D points.
public static MCvPoint3D32f[] ReprojectImageTo3D(
IInputArray disparity,
IInputArray Q
)
案例學習:
PointF [] ki = new PointF[]{ new PointF(20, 20), new PointF(100, 20), new PointF(20, 120) , new PointF(100, 120), new PointF(110, 125), new PointF(200, 300) };
Rectangle a1= PointCollection.BoundingRectangle(ki); 矩形
//Ellipse a1 = PointCollection.EllipseLeastSquareFitting(ki); 橢圓
LineSegment2DF[] ko = PointCollection.PolyLine(ki, false); 采用不閉合
Emgu.CV.Image<Bgr, Byte> g2 = GG.ToImage<Bgr, Byte>();
g2.Draw(a1, new Bgr(Color.Red)); //可以看出繪圖矩形按照最大點位畫出,而橢圓卻不是采用。
foreach (var jj in ko)
{
g2.Draw(jj, new Bgr(Color.Red),2);
}
imageBox1.Image = g2;