为确定的地标点绘制轮廓(OpenCvForUnity)
Draw contours for determined landmark points ( OpenCvForUnity )
我之前使用过 OpenCV python。但是我越来越难以统一使用 OpenCV。
我针对面部特定点的训练数据。我可以找到地标点,我可以在 unity webcamTexture 上显示这些点,但我想在我确定的地标点上绘制轮廓。首先,我需要将地标点转换为凸包点,以便在现有点之间绘制轮廓。如何转换?
I tried
List<List<Vector2>> landmarkPoints = new List<List<Vector2>>();
OpenCVForUnityUtils.ConvertVector2ListToArray(landmarkPoints) ;
But landmark points doesn't convert. I need to convert landmark points to Hull Points.
Imgproc.drawContours (rgbaMat, hullPoints, -1, new Scalar (0, 255, 0), 2);
你能帮帮我吗?
我终于找到了这个解决方案。如果您遇到相同的问题,那么答案可能对您有所帮助。
// detect face landmark points.
OpenCVForUnityUtils.SetImage(faceLandmarkDetector, rgbaMat);
for (int i = 0; i < trackedRects.Count; i++)
{
List<Vector2> points = faceLandmarkDetector.DetectLandmark(rect);
List<Vector2> pointss = new List<Vector2>();
//Draw Contours
List<Point> pointsss = OpenCVForUnityUtils.ConvertVector2ListToPointList(pointss);
MatOfPoint hullPointMat = new MatOfPoint();
hullPointMat.fromList(pointsss);
List<MatOfPoint> hullPoints = new List<MatOfPoint>();
hullPoints.Add(hullPointMat);
Imgproc.drawContours(rgbaMat, hullPoints, -1, new Scalar(150, 100, 5,255), -1);
}
我之前使用过 OpenCV python。但是我越来越难以统一使用 OpenCV。
我针对面部特定点的训练数据。我可以找到地标点,我可以在 unity webcamTexture 上显示这些点,但我想在我确定的地标点上绘制轮廓。首先,我需要将地标点转换为凸包点,以便在现有点之间绘制轮廓。如何转换?
I tried
List<List<Vector2>> landmarkPoints = new List<List<Vector2>>();
OpenCVForUnityUtils.ConvertVector2ListToArray(landmarkPoints) ;
But landmark points doesn't convert. I need to convert landmark points to Hull Points.
Imgproc.drawContours (rgbaMat, hullPoints, -1, new Scalar (0, 255, 0), 2);
你能帮帮我吗?
我终于找到了这个解决方案。如果您遇到相同的问题,那么答案可能对您有所帮助。
// detect face landmark points.
OpenCVForUnityUtils.SetImage(faceLandmarkDetector, rgbaMat);
for (int i = 0; i < trackedRects.Count; i++)
{
List<Vector2> points = faceLandmarkDetector.DetectLandmark(rect);
List<Vector2> pointss = new List<Vector2>();
//Draw Contours
List<Point> pointsss = OpenCVForUnityUtils.ConvertVector2ListToPointList(pointss);
MatOfPoint hullPointMat = new MatOfPoint();
hullPointMat.fromList(pointsss);
List<MatOfPoint> hullPoints = new List<MatOfPoint>();
hullPoints.Add(hullPointMat);
Imgproc.drawContours(rgbaMat, hullPoints, -1, new Scalar(150, 100, 5,255), -1);
}