perogram

How to visualize FaceTracker.cs? 分析された顔情報の可視化

f:id:peroon:20181121044640p:plain

  • FaceTracker.cs に追記する
        public bool enableDebugLine = true;

        ...
        
        public void draw(Mat im, Scalar pts_color, Scalar con_color)
        {

            int[] smodel_C_int = new int[smodel.C.total()];
            Utils.copyFromMat<int>(smodel.C, smodel_C_int);

            ScaleFaceParts();
            CropFacePartsAll(im);
            FaceInpaint(im);

            foreach (var point in points)
            {
                int n = point.Length;
                if (n == 0)
                {
                    return;
                }   

                int rows = smodel.C.rows();
                int cols = smodel.C.cols();
                for (int i = 0; i < rows; i++)
                {
                    int j = smodel_C_int [i * cols], k = smodel_C_int [(i * cols) + 1];
#if OPENCV_2
                Core.line(im, point[j], point[k], con_color, 1);
#else
                    if (enableDebugLine)
                    {
                        int lineWidth = 2;
                        Imgproc.line(im, point[j], point[k], con_color, lineWidth);
                    }
#endif
                                
                }
                for (int i = 0; i < n; i++)
                {
#if OPENCV_2
                Core.circle (im, point [i], 1, pts_color, 2, Core.LINE_AA, 0);
#else
                    if (enableDebugLine)
                    {
                        Imgproc.circle(im, point[i], 1, pts_color, 2, Core.LINE_AA, 0);
                        Imgproc.putText(im, i.ToString(), point[i], Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Core.LINE_AA, false);
                    }
#endif
                }
            }
        }