Ejemplo n.º 1
0
 public static extern ErrorType opencv_getTextSize(byte[] text,
                                                   int textLength,
                                                   CvHersheyFonts fontFace,
                                                   double fontScale,
                                                   int thickness,
                                                   ref int baseLine,
                                                   out IntPtr returnValue);
Ejemplo n.º 2
0
        public static void PutText(Mat mat,
                                   string text,
                                   Point <double> point,
                                   CvHersheyFonts fontFace,
                                   double fontScale,
                                   Scalar <double> scalar,
                                   int thickness         = 1,
                                   CvLineTypes lineType  = CvLineTypes.Line8,
                                   bool bottomLeftOrigin = false)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }

            mat.ThrowIfDisposed();

            var str = Ncnn.Encoding.GetBytes(text ?? "");

            using (var nativePoint = point.ToNative())
                using (var nativeScalar = scalar.ToNative())
                {
                    NativeMethods.opencv_putText_double(mat.NativePtr,
                                                        str,
                                                        str.Length,
                                                        nativePoint.NativePtr,
                                                        fontFace,
                                                        fontScale,
                                                        nativeScalar.NativePtr,
                                                        thickness,
                                                        lineType,
                                                        bottomLeftOrigin);
                }
        }
Ejemplo n.º 3
0
 public static extern ErrorType opencv_putText_float(IntPtr mat,
                                                     byte[] text,
                                                     int textLength,
                                                     IntPtr point,
                                                     CvHersheyFonts fontFace,
                                                     double fontScale,
                                                     IntPtr scalar,
                                                     int thickness,
                                                     CvLineTypes lineType,
                                                     bool bottomLeftOrigin);
Ejemplo n.º 4
0
        public static Size <int> GetTextSize(string text, CvHersheyFonts fontFace, double fontScale, int thickness, ref int baseLine)
        {
            var str   = Ncnn.Encoding.GetBytes(text ?? "");
            var error = NativeMethods.opencv_getTextSize(str,
                                                         str.Length,
                                                         fontFace,
                                                         fontScale,
                                                         thickness,
                                                         ref baseLine,
                                                         out var ret);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }

            return(new Size <int>(ret));
        }