示例#1
0
        /// <summary>
        /// Draw a straight line indicating head pose on the specified image.
        /// </summary>
        /// <param name="rotation">The rotation matrix of the head.</param>
        /// <param name="translation">The translation matrix of the head.</param>
        /// <param name="cameraMatrix">The camera calibration matrix.</param>
        /// <param name="coefficients">The coefficient matrix.</param>
        /// <param name="shape">The list of facial landmark points.</param>
        /// <param name="image">The image to draw on.</param>
        public static void DrawPoseLine(
            Mat rotation,
            Mat translation,
            MatOfDouble cameraMatrix,
            MatOfDouble coefficients,
            FullObjectDetection shape,
            Bitmap image)
        {
            // create a new model point in front of the nose and project it into 2d
            var poseModel      = new MatOfPoint3d(1, 1, new Point3d(0, 0, 1000));
            var poseProjection = new MatOfPoint2d();

            Cv2.ProjectPoints(poseModel, rotation, translation, cameraMatrix, coefficients, poseProjection);

            // get landmark point 30 (tip of the nose)
            var point     = shape.GetPart(30);
            var tipOfNose = new OpenCvSharp.Point2d(point.X, point.Y);

            // draw a line from the tip of the nose pointing in the direction of head pose
            var p   = poseProjection.At <Point2d>(0);
            var pen = new Pen(Brushes.White, 2);

            using (Graphics g = Graphics.FromImage(image))
            {
                g.DrawLine(pen, (int)tipOfNose.X, (int)tipOfNose.Y, (int)p.X, (int)p.Y);
            }
        }
示例#2
0
 public static void Run(IntPtr ptr, Point2d v) => NativeMethods.core_Mat_push_back_Point2d(ptr, v);
示例#3
0
        /// <summary>
        /// 指定した点がこの矩形に含まれているかどうかを判断する
        /// </summary>
        /// <param name="pt">点</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Determines if the specified point is contained within the rectangular region defined by this Rectangle.
        /// </summary>
        /// <param name="pt">point</param>
        /// <returns></returns>
#endif
        public bool Contains(Point2d pt)
        {
            return(Contains(pt.X, pt.Y));
        }
示例#4
0
 public static extern unsafe void calib3d_calibrationMatrixValues_array(
     double *cameraMatrix, Size imageSize,
     double apertureWidth, double apertureHeight, out double fovx, out double fovy, out double focalLength,
     out Point2d principalPoint, out double aspectRatio);
 public static extern ExceptionStatus core_Mat_push_back_Point2d(IntPtr self, Point2d v);
示例#6
0
 public static extern void core_FileStorage_shift_Point2d(IntPtr fs, Point2d val);
 public static extern ExceptionStatus calib3d_findEssentialMat_InputArray2(
     IntPtr points1, IntPtr points2, double focal, Point2d pp,
     int method, double prob, double threshold, IntPtr mask, out IntPtr returnValue);
 public static extern ExceptionStatus calib3d_recoverPose_InputArray2(
     IntPtr E, IntPtr points1, IntPtr points2,
     IntPtr R, IntPtr P, double focal, Point2d pp, IntPtr mask,
     out int returnValue);
 public static extern ExceptionStatus calib3d_calibrationMatrixValues_InputArray(
     IntPtr cameraMatrix,
     Size imageSize, double apertureWidth, double apertureHeight, out double fovx, out double fovy,
     out double focalLength, out Point2d principalPoint, out double aspectRatio);
 public static extern ExceptionStatus imgproc_ellipse2Poly_double(
     Point2d center, Size2d axes, int angle, int arcStart, int arcEnd, int delta, IntPtr pts);
 public static extern ExceptionStatus imgproc_phaseCorrelate(IntPtr src1, IntPtr src2, IntPtr window,
                                                             out double response, out Point2d returnValue);