Exemplo n.º 1
0
      /// <summary>
      /// Load the trained detector from files
      /// </summary>
      /// <param name="fileNames">The names of the trained latent svm file</param>
      /// <param name="classNames">The names of the class</param>
      public LatentSvmDetector(String[] fileNames, String[] classNames = null)
      {
         CvString[] fileNameStrings = new CvString[fileNames.Length];
         for (int i = 0; i < fileNames.Length ;i++)
            fileNameStrings[i] = new CvString(fileNames[i]);

         CvString[] classNameStrings = null;
         if (classNames != null)
         {
            classNameStrings = new CvString[classNames.Length];
            for (int i = 0; i < classNames.Length; i++)
               classNameStrings[i] = new CvString(classNames[i]);
         }
         try
         {
            using (VectorOfCvString fvcs = new VectorOfCvString(fileNameStrings))
            using (VectorOfCvString cvcs = new VectorOfCvString())
            {
               if (classNameStrings != null)
                  cvcs.Push(classNameStrings);

               _ptr = cveLSVMDetectorCreate(fvcs, cvcs);
            }
         }
         finally
         {
            for (int i =  0; i < fileNameStrings.Length; i++)
               fileNameStrings[i].Dispose();

            if (classNameStrings != null)
               for (int i = 0; i < classNameStrings.Length; i++)
                  classNameStrings[i].Dispose();
         }
      }
Exemplo n.º 2
0
 public void RemoveWidget(String id)
 {
    using (CvString cvsId = new CvString(id))
    {
       CvInvoke.cveViz3dRemoveWidget(_ptr, cvsId);
    }
 }
Exemplo n.º 3
0
      /// <summary>
      /// Saves the image to the specified file. The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format
      /// </summary>
      /// <param name="filename">The name of the file to be saved to</param>
      /// <param name="image">The image to be saved</param>
      /// <param name="parameters">The parameters</param>
      /// <returns>true if success</returns>
      public static bool Imwrite(String filename, IInputArray image, params int[] parameters)
      {
         using (Util.VectorOfInt vec = new Util.VectorOfInt())
         {
            if (parameters.Length > 0)
               vec.Push(parameters);
            using (CvString s = new CvString(filename))
            using (InputArray iaImage = image.GetInputArray())
            {
#if !(__IOS__ || __ANDROID__ || NETFX_CORE)
               bool containsUnicode = (s.Length != filename.Length);
               if (containsUnicode &&
                   (Emgu.Util.Platform.OperationSystem != OS.MacOSX) &&
                   (Emgu.Util.Platform.OperationSystem != OS.Linux))
               {
                  //Handle unicode in Windows platform
                  //Work around for Open CV ticket:
                  //https://github.com/Itseez/opencv/issues/4292
                  //https://github.com/Itseez/opencv/issues/4866     
                  System.IO.FileInfo fi = new System.IO.FileInfo(filename);

                  using (VectorOfByte vb = new VectorOfByte())
                  {
                     CvInvoke.Imencode(fi.Extension, image, vb, parameters);
                     byte[] arr = vb.ToArray();
                     System.IO.File.WriteAllBytes(filename, arr);
                     return true;
                  }
               }
               else
#endif
                  return cveImwrite(s, iaImage, vec);
            }
         }
      }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new 3D visualizer windows
 /// </summary>
 /// <param name="windowName">The name of the windows</param>
 public Viz3d(String windowName)
 {
    using (CvString cvs = new CvString(windowName))
    {
       _ptr = CvInvoke.cveViz3dCreate(cvs);
    }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create an opencl kernel
 /// </summary>
 /// <param name="kernelName">The name of the kernel</param>
 /// <param name="programSource">The program source code</param>
 /// <param name="buildOps">The build options</param>
 /// <param name="errMsg">Option error message container that can be passed to this function</param>
 /// <returns>True if the kernel can be created</returns>
 public bool Create(String kernelName, ProgramSource programSource, String buildOps = null, CvString errMsg = null)
 {
    using (CvString cs = new CvString(kernelName))
    using (CvString buildOptStr = new CvString(buildOps))
    {
       return OclInvoke.oclKernelCreate(_ptr, cs, programSource, buildOptStr, errMsg);
    }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Shows the image in the specified window
 /// </summary>
 /// <param name="name">Name of the window</param>
 /// <param name="image">Image to be shown</param>
 public static void Imshow(String name, IInputArray image)
 {
    using (CvString s = new CvString(name))
    using (InputArray iaImage = image.GetInputArray())
    {
       cveImshow(s, iaImage);
    }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileStorage"/> class.
 /// </summary>
 /// <param name="source">Name of the file to open or the text string to read the data from. Extension of the
 /// file (.xml or .yml/.yaml) determines its format (XML or YAML respectively). Also you can append .gz
 /// to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and
 /// FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g.
 /// mydata.xml, .yml etc.).</param>
 /// <param name="flags">Mode of operation.</param>
 /// <param name="encoding">Encoding of the file. Note that UTF-16 XML encoding is not supported currently and
 /// you should use 8-bit encoding instead of it.</param>
 public FileStorage(String source, Mode flags, String encoding = null)
 {
    using (CvString enc = new CvString(encoding))
    using (CvString src = new CvString(source))
    {
       _ptr = CvInvoke.cveFileStorageCreate(src, flags, enc);
    }
 }
Exemplo n.º 8
0
      /// <summary>
      /// Create a Cuda cascade classifier using the specific file
      /// </summary>
      /// <param name="fileName">The file to create the classifier from</param>
      public CudaCascadeClassifier(String fileName)
      {
#if !NETFX_CORE
         Debug.Assert(File.Exists(fileName), String.Format("The Cascade file {0} does not exist.", fileName));
#endif
         using (CvString s = new CvString(fileName))
            _ptr = CudaInvoke.cudaCascadeClassifierCreate(s);
      }
Exemplo n.º 9
0
        /// <summary>
        /// Create a video writer using the specific information
        /// </summary>
        /// <param name="fileName">The name of the video file to be written to </param>
        /// <param name="compressionCode">Compression code. Usually computed using CvInvoke.CV_FOURCC.
        /// On windows use -1 to open a codec selection dialog.
        /// On Linux, use CvInvoke.CV_FOURCC('I', 'Y', 'U', 'V') for default codec for the specific file name.
        /// </param>
        /// <param name="fps">frame rate per second</param>
        /// <param name="size">the size of the frame</param>
        /// <param name="isColor">true if this is a color video, false otherwise</param>
        /// <param name="apiPreference">Allows to specify API backends to use. Use 0 if you don't have any preference.</param>
        public VideoWriter(String fileName, int apiPreference, int compressionCode, double fps, System.Drawing.Size size, bool isColor)
        {
            using (CvString s = new CvString(fileName))
                _ptr = CvInvoke.cveVideoWriterCreate2(s, apiPreference, compressionCode, fps, ref size, isColor);

            if (_ptr == IntPtr.Zero || IsOpened == false)
            {
                throw new NullReferenceException("Unable to create VideoWriter. Make sure you have the specific codec installed");
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Write point cloud to file
 /// </summary>
 /// <param name="file">The point cloud file name</param>
 /// <param name="cloud">The point cloud</param>
 /// <param name="colors">The color</param>
 /// <param name="normals">The normals</param>
 public static void WriteCloud(String file, IInputArray cloud, IInputArray colors = null, IInputArray normals = null)
 {
     using (CvString cs = new CvString(file))
         using (InputArray iaCloud = cloud.GetInputArray())
             using (InputArray iaColors = colors == null ? InputArray.GetEmpty() : colors.GetInputArray())
                 using (InputArray iaNormals = normals == null ? InputArray.GetEmpty() : normals.GetInputArray())
                 {
                     cveWriteCloud(cs, iaCloud, iaColors, iaNormals);
                 }
 }
Exemplo n.º 11
0
 /// <summary>
 /// encode image and store the result as a byte vector.
 /// </summary>
 /// <param name="ext">The image format</param>
 /// <param name="image">The image</param>
 /// <param name="buf">Output buffer resized to fit the compressed image.</param>
 /// <param name="parameters">The pointer to the array of integers, which contains the parameter for encoding, use IntPtr.Zero for default</param>
 public static void Imencode(String ext, IInputArray image, VectorOfByte buf, params KeyValuePair <CvEnum.ImwriteFlags, int>[] parameters)
 {
     using (CvString extStr = new CvString(ext))
         using (VectorOfInt p = new VectorOfInt())
         {
             PushParameters(p, parameters);
             using (InputArray iaImage = image.GetInputArray())
                 cveImencode(extStr, iaImage, buf, p);
         }
 }
Exemplo n.º 12
0
      /// <summary>
      /// Create a video writer using the specific information
      /// </summary>
      /// <param name="fileName">The name of the video file to be written to </param>
      /// <param name="compressionCode">Compression code. Usually computed using CvInvoke.CV_FOURCC. 
      /// On windows use -1 to open a codec selection dialog.
      /// On Linux, use CvInvoke.CV_FOURCC('I', 'Y', 'U', 'V') for default codec for the specific file name.
      /// </param>
      /// <param name="fps">frame rate per second</param>
      /// <param name="size">the size of the frame</param>
      /// <param name="isColor">true if this is a color video, false otherwise</param>
      public VideoWriter(String fileName, int compressionCode, int fps, System.Drawing.Size size, bool isColor)
      {
         using (CvString s = new CvString(fileName))
         _ptr = /*CvToolbox.HasFFMPEG?
            CvInvoke.cvCreateVideoWriter_FFMPEG(fileName, compressionCode, fps, new System.Drawing.Size(width, height), isColor):*/
            CvInvoke.cveVideoWriterCreate(s, compressionCode, fps, ref size, isColor);

         if (_ptr == IntPtr.Zero)
           throw new NullReferenceException("Unable to create VideoWriter. Make sure you have the specific codec installed");
      }
Exemplo n.º 13
0
 /// <summary>
 /// Decodes QR code on a curved surface in image once it's found by the detect() method.
 /// </summary>
 /// <param name="img">grayscale or color (BGR) image containing QR code.</param>
 /// <param name="points">Quadrangle vertices found by detect() method (or some other algorithm).</param>
 /// <param name="straightQrcode">The optional output image containing rectified and binarized QR code</param>
 /// <returns>UTF8-encoded output string or empty string if the code cannot be decoded.</returns>
 public String DecodeCurved(IInputArray img, IInputArray points, IOutputArray straightQrcode = null)
 {
     using (InputArray iaImage = img.GetInputArray())
         using (InputArray iaPoints = points.GetInputArray())
             using (OutputArray oaStraightQrcode = straightQrcode == null ? OutputArray.GetEmpty() : straightQrcode.GetOutputArray())
                 using (CvString decodedInfo = new CvString())
                 {
                     CvInvoke.cveQRCodeDetectorDecodeCurved(_ptr, iaImage, iaPoints, decodedInfo, oaStraightQrcode);
                     return(decodedInfo.ToString());
                 }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Saves the image to the specified file. The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format
 /// </summary>
 /// <param name="filename">The name of the file to be saved to</param>
 /// <param name="image">The image to be saved</param>
 /// <param name="parameters">The parameters</param>
 /// <returns>true if success</returns>
 public static bool Imwrite(String filename, IInputArray image, params int[] parameters)
 {
    using (Util.VectorOfInt vec = new Util.VectorOfInt())
    {
       if (parameters.Length > 0)
          vec.Push(parameters);
       using (CvString s = new CvString(filename))
       using (InputArray iaImage = image.GetInputArray())
          return cveImwrite(s, iaImage, vec);
    }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Create a video writer using the specific information
        /// </summary>
        /// <param name="fileName">The name of the video file to be written to </param>
        /// <param name="compressionCode">Compression code. Usually computed using CvInvoke.CV_FOURCC.
        /// On windows use -1 to open a codec selection dialog.
        /// On Linux, use VideoWriter.Fourcc('I', 'Y', 'U', 'V') for default codec for the specific file name.
        /// </param>
        /// <param name="fps">frame rate per second</param>
        /// <param name="size">the size of the frame</param>
        /// <param name="apiPreference">Allows to specify API backends to use.</param>
        /// <param name="writerProperties">Optional writer properties. e.g. new Tuple&lt;VideoWriter.WriterProperty&gt;(VideoWriter.WriterProperty.HwAcceleration, (int) VideoAccelerationType.Any)</param>
        public VideoWriter(String fileName, int apiPreference, int compressionCode, double fps, System.Drawing.Size size, params Tuple <WriterProperty, int>[] writerProperties)
        {
            using (CvString s = new CvString(fileName))
                using (VectorOfInt vectInt = ConvertWriterProperties(writerProperties))
                    _ptr = CvInvoke.cveVideoWriterCreate3(s, apiPreference, compressionCode, fps, ref size, vectInt);

            if (_ptr == IntPtr.Zero || IsOpened == false)
            {
                throw new NullReferenceException("Unable to create VideoWriter. Make sure you have the specific codec installed");
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Read point cloud from file
 /// </summary>
 /// <param name="file">The point cloud file</param>
 /// <param name="colors">The color of the points</param>
 /// <param name="normals">The normal of the points</param>
 /// <returns>The points</returns>
 public static Mat ReadCloud(String file, IOutputArray colors = null, IOutputArray normals = null)
 {
     using (CvString cs = new CvString(file))
         using (OutputArray oaColors = colors == null ? OutputArray.GetEmpty() : colors.GetOutputArray())
             using (OutputArray oaNormals = normals == null ? OutputArray.GetEmpty() : normals.GetOutputArray())
             {
                 Mat cloud = new Mat();
                 cveReadCloud(cs, cloud, oaColors, oaNormals);
                 return(cloud);
             }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Create a video writer using the specific information
        /// </summary>
        /// <param name="fileName">The name of the video file to be written to </param>
        /// <param name="compressionCode">Compression code. Usually computed using CvInvoke.CV_FOURCC.
        /// On windows use -1 to open a codec selection dialog.
        /// On Linux, use CvInvoke.CV_FOURCC('I', 'Y', 'U', 'V') for default codec for the specific file name.
        /// </param>
        /// <param name="fps">frame rate per second</param>
        /// <param name="size">the size of the frame</param>
        /// <param name="isColor">true if this is a color video, false otherwise</param>
        public VideoWriter(String fileName, int compressionCode, double fps, System.Drawing.Size size, bool isColor)
        {
            using (CvString s = new CvString(fileName))
                _ptr = /*CvToolbox.HasFFMPEG?
                        * CvInvoke.cvCreateVideoWriter_FFMPEG(fileName, compressionCode, fps, new System.Drawing.Size(width, height), isColor):*/
                       CvInvoke.cveVideoWriterCreate(s, compressionCode, fps, ref size, isColor);

            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException("Unable to create VideoWriter. Make sure you have the specific codec installed");
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Create an Extremal Region Filter for the 1st stage classifier of N&amp;M algorithm
 /// </summary>
 /// <param name="classifierFileName">The file name of the classifier</param>
 /// <param name="thresholdDelta">Threshold step in subsequent thresholds when extracting the component tree.</param>
 /// <param name="minArea">The minimum area (% of image size) allowed for retreived ER’s.</param>
 /// <param name="maxArea">The maximum area (% of image size) allowed for retreived ER’s.</param>
 /// <param name="minProbability">The minimum probability P(er|character) allowed for retreived ER’s.</param>
 /// <param name="nonMaxSuppression">Whenever non-maximum suppression is done over the branch probabilities.</param>
 /// <param name="minProbabilityDiff">The minimum probability difference between local maxima and local minima ERs.</param>
 public ERFilterNM1(
     String classifierFileName,
     int thresholdDelta       = 1,
     float minArea            = 0.00025f,
     float maxArea            = 0.13f,
     float minProbability     = 0.4f,
     bool nonMaxSuppression   = true,
     float minProbabilityDiff = 0.1f)
 {
     using (CvString s = new CvString(classifierFileName))
         _ptr = CvERFilterNM1Create(s, thresholdDelta, minArea, maxArea, minProbability, nonMaxSuppression, minProbabilityDiff);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Selects ROI on the given image. Function creates a window and allows user to select a ROI using mouse. Controls: use space or enter to finish selection, use key c to cancel selection (function will return the zero cv::Rect).
        /// </summary>
        /// <param name="windowName"> Name of the window where selection process will be shown.</param>
        /// <param name="img"> Image to select a ROI.</param>
        /// <param name="showCrosshair"> If true crosshair of selection rectangle will be shown.</param>
        /// <param name="fromCenter"> If true center of selection will match initial mouse position. In opposite case a corner of selection rectangle will correspont to the initial mouse position.</param>
        /// <returns> Selected ROI or empty rect if selection canceled.</returns>
        public static Rectangle SelectROI(String windowName, IInputArray img, bool showCrosshair = true, bool fromCenter = false)
        {
            Rectangle roi = new Rectangle();

            using (CvString csWindowName = new CvString(windowName))
                using (InputArray iaImg = img.GetInputArray())
                {
                    cveSelectROI(csWindowName, iaImg, showCrosshair, fromCenter, ref roi);
                }

            return(roi);
        }
Exemplo n.º 20
0
 /// <summary>
 /// encode image and store the result as a byte vector.
 /// </summary>
 /// <param name="ext">The image format</param>
 /// <param name="image">The image</param>
 /// <param name="buf">Output buffer resized to fit the compressed image.</param>
 /// <param name="parameters">The pointer to the array of intergers, which contains the parameter for encoding, use IntPtr.Zero for default</param>
 public static void Imencode(String ext, IInputArray image, VectorOfByte buf, params int[] parameters)
 {
     using (CvString extStr = new CvString(ext))
         using (VectorOfInt p = new VectorOfInt())
         {
             if (parameters.Length > 0)
             {
                 p.Push(parameters);
             }
             using (InputArray iaImage = image.GetInputArray())
                 cveImencode(extStr, iaImage, buf, p);
         }
 }
Exemplo n.º 21
0
 /// <summary>
 /// Saves the image to the specified file. The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format
 /// </summary>
 /// <param name="filename">The name of the file to be saved to</param>
 /// <param name="image">The image to be saved</param>
 /// <param name="parameters">The parameters</param>
 /// <returns>true if success</returns>
 public static bool Imwrite(String filename, IInputArray image, params int[] parameters)
 {
     using (Util.VectorOfInt vec = new Util.VectorOfInt())
     {
         if (parameters.Length > 0)
         {
             vec.Push(parameters);
         }
         using (CvString s = new CvString(filename))
             using (InputArray iaImage = image.GetInputArray())
                 return(cveImwrite(s, iaImage, vec));
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// Selects ROIs on the given image. Function creates a window and allows user to select a ROIs using mouse. Controls: use space or enter to finish current selection and start a new one, use esc to terminate multiple ROI selection process.
 /// </summary>
 /// <param name="windowName"> Name of the window where selection process will be shown.</param>
 /// <param name="img"> Image to select a ROI.</param>
 /// <param name="showCrosshair"> If true crosshair of selection rectangle will be shown.</param>
 /// <param name="fromCenter"> If true center of selection will match initial mouse position. In opposite case a corner of selection rectangle will correspont to the initial mouse position.</param>
 /// <returns> Selected ROIs.</returns>
 public static Rectangle[] SelectROIs(
     String windowName,
     IInputArray img,
     bool showCrosshair = true,
     bool fromCenter    = false)
 {
     using (VectorOfRect vr = new VectorOfRect())
         using (CvString csWindowName = new CvString(windowName))
             using (InputArray iaImg = img.GetInputArray())
             {
                 cveSelectROIs(csWindowName, iaImg, vr, showCrosshair, fromCenter);
                 return(vr.ToArray());
             }
 }
Exemplo n.º 23
0
      ///<summary> Create a CascadeClassifier from the specific file</summary>
      ///<param name="fileName"> The name of the file that contains the CascadeClassifier</param>
      public CascadeClassifier(String fileName)
      {
#if !NETFX_CORE
         FileInfo file = new FileInfo(fileName);
         if (!file.Exists)
            throw new FileNotFoundException("File '{0}' not found", file.FullName);
#endif
         using (CvString s = new CvString(fileName))
            _ptr = CvInvoke.cveCascadeClassifierCreateFromFile(s);

         if (_ptr == IntPtr.Zero)
         {
            throw new NullReferenceException(String.Format("Fail to create HaarCascade object: {0}", fileName));
         }
      }
Exemplo n.º 24
0
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        /// <param name="captureProperties">Optional capture properties. e.g. new Tuple&lt;CvEnum.CapProp&gt;(CvEnum.CapProp.HwAcceleration, (int) VideoAccelerationType.Any)</param>
        public VideoCapture(String fileName, API captureApi = API.Any, params Tuple <CvEnum.CapProp, int>[] captureProperties)
        {
            using (CvString s = new CvString(fileName))
                using (VectorOfInt vectInt = ConvertCaptureProperties(captureProperties))
                {
                    _captureModuleType = CaptureModuleType.Highgui;
                    _ptr = CvInvoke.cveVideoCaptureCreateFromFile(s, captureApi, vectInt);

                    if (_ptr == IntPtr.Zero)
                    {
                        throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
                    }
                }
            _needDispose = true;
        }
Exemplo n.º 25
0
        /// <summary>Create a CascadeClassifier from the specific file</summary>
        /// <param name="fileName">The name of the file that contains the CascadeClassifier</param>
        public CascadeClassifier(String fileName)
        {
            FileInfo file = new FileInfo(fileName);

            if (!file.Exists)
            {
                throw new FileNotFoundException(String.Format("File '{0}' not found", fileName));
            }
            using (CvString s = new CvString(fileName))
                _ptr = CvInvoke.cveCascadeClassifierCreateFromFile(s);

            if (_ptr == IntPtr.Zero)
            {
                throw new NullReferenceException(String.Format("Fail to create HaarCascade object: {0}", fileName));
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Load the trained detector from files
        /// </summary>
        /// <param name="fileNames">The names of the trained latent svm file</param>
        /// <param name="classNames">The names of the class</param>
        public LatentSvmDetector(String[] fileNames, String[] classNames = null)
        {
            CvString[] fileNameStrings = new CvString[fileNames.Length];
            for (int i = 0; i < fileNames.Length; i++)
            {
                fileNameStrings[i] = new CvString(fileNames[i]);
            }

            CvString[] classNameStrings = null;
            if (classNames != null)
            {
                classNameStrings = new CvString[classNames.Length];
                for (int i = 0; i < classNames.Length; i++)
                {
                    classNameStrings[i] = new CvString(classNames[i]);
                }
            }
            try
            {
                using (VectorOfCvString fvcs = new VectorOfCvString(fileNameStrings))
                    using (VectorOfCvString cvcs = new VectorOfCvString())
                    {
                        if (classNameStrings != null)
                        {
                            cvcs.Push(classNameStrings);
                        }

                        _ptr = CvInvoke.cveLSVMDetectorCreate(fvcs, cvcs);
                    }
            }
            finally
            {
                for (int i = 0; i < fileNameStrings.Length; i++)
                {
                    fileNameStrings[i].Dispose();
                }

                if (classNameStrings != null)
                {
                    for (int i = 0; i < classNameStrings.Length; i++)
                    {
                        classNameStrings[i].Dispose();
                    }
                }
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Initialize the WeChatQRCode. It includes two models, which are packaged with caffe format. Therefore, there are prototxt and caffe models (In total, four paramenters).
 /// </summary>
 /// <param name="detectorPrototxtPath">Prototxt file path for the detector</param>
 /// <param name="detectorCaffeModelPath">Caffe model file path for the detector</param>
 /// <param name="superResolutionPrototxtPath">Prototxt file path for the super resolution model</param>
 /// <param name="superResolutionCaffeModelPath">Caffe file path for the super resolution model</param>
 public WeChatQRCode(
     String detectorPrototxtPath,
     String detectorCaffeModelPath,
     String superResolutionPrototxtPath,
     String superResolutionCaffeModelPath)
 {
     using (CvString csDetectorPrototxtPath = new CvString(detectorPrototxtPath))
         using (CvString csDetectorCaffeModelPath = new CvString(detectorCaffeModelPath))
             using (CvString csSuperResolutionPrototxtPath = new CvString(superResolutionPrototxtPath))
                 using (CvString csSuperResolutionCaffeModelPath = new CvString(superResolutionCaffeModelPath))
                     _ptr = WeChatQRCodeInvoke.cveWeChatQRCodeCreate(
                         csDetectorPrototxtPath,
                         csDetectorCaffeModelPath,
                         csSuperResolutionPrototxtPath,
                         csSuperResolutionCaffeModelPath
                         );
 }
Exemplo n.º 28
0
      /// <summary>
      /// The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
      /// </summary>
      /// <param name="filename">Name of file to be loaded.</param>
      /// <param name="flags">Read flags</param>
      /// <returns>Null if the reading fails, otherwise, an array of Mat from the file</returns>
      public static Mat[] Imreadmulti(String filename, CvEnum.ImreadModes flags = ImreadModes.AnyColor)
      {
         using (VectorOfMat vm = new VectorOfMat())
            using (CvString strFilename = new CvString(filename))
         {
            if (!cveImreadmulti(strFilename, vm, flags))
               return null;
            Mat[] result = new Mat[vm.Size];

            for (int i = 0; i < result.Length; i++)
            {
               Mat m = new Mat();
               CvInvoke.Swap(m, vm[i]);
               result[i] = m;
            }
            return result;
         }
      }
Exemplo n.º 29
0
 /// <summary>
 /// Creates an instance of this class with given parameters.
 /// </summary>
 /// <param name="model">The path of the onnx model used for face recognition</param>
 /// <param name="config">The path to the config file for compability, which is not requested for ONNX models</param>
 /// <param name="backendId">The id of backend</param>
 /// <param name="targetId">The id of target device</param>
 public FaceRecognizerSF(
     String model,
     String config,
     Emgu.CV.Dnn.Backend backendId,
     Emgu.CV.Dnn.Target targetId)
 {
     using (CvString csModel = new CvString(model))
         using (CvString csConfig = new CvString(config))
         {
             _ptr = CvInvoke.cveFaceRecognizerSFCreate(
                 csModel,
                 csConfig,
                 backendId,
                 targetId,
                 ref _sharedPtr
                 );
         }
 }
Exemplo n.º 30
0
 /// <summary>
 /// Create a new TrackerDaSiamRPN
 /// </summary>
 /// <param name="model">The model file</param>
 /// <param name="kernelCls1">The kernelCls1 file</param>
 /// <param name="kernelR1">The kernelR1 file</param>
 /// <param name="backend">The preferred DNN backend</param>
 /// <param name="target">The preferred DNN target</param>
 public TrackerDaSiamRPN(
     String model        = "dasiamrpn_model.onnx",
     String kernelCls1   = "dasiamrpn_kernel_cls1.onnx",
     String kernelR1     = "dasiamrpn_kernel_r1.onnx",
     Dnn.Backend backend = Dnn.Backend.Default,
     Dnn.Target target   = Target.Cpu)
 {
     using (CvString csModel = new CvString(model))
         using (CvString csKernelCls1 = new CvString(kernelCls1))
             using (CvString csKernelR1 = new CvString(kernelR1))
                 _ptr = CvInvoke.cveTrackerDaSiamRPNCreate(
                     csModel,
                     csKernelCls1,
                     csKernelR1,
                     backend,
                     target,
                     ref _trackerPtr,
                     ref _sharedPtr);
 }
Exemplo n.º 31
0
        /// <summary>
        /// Find groups of Extremal Regions that are organized as text blocks.
        /// </summary>
        /// <param name="channels">Array of sinle channel images from wich the regions were extracted</param>
        /// <param name="erstats">Vector of ER’s retreived from the ERFilter algorithm from each channel</param>
        /// <param name="groupingTrainedFileName">The XML or YAML file with the classifier model (e.g. trained_classifier_erGrouping.xml)</param>
        /// <param name="minProbability">The minimum probability for accepting a group.</param>
        /// <returns>The output of the algorithm that indicates the text regions</returns>
        public static System.Drawing.Rectangle[] ERGrouping(IInputArray channels, VectorOfERStat[] erstats, String groupingTrainedFileName, float minProbability = 0.5f)
        {
            IntPtr[] erstatPtrs = new IntPtr[erstats.Length];

            for (int i = 0; i < erstatPtrs.Length; i++)
            {
                erstatPtrs[i] = erstats[i].Ptr;
            }

            using (VectorOfRect regions = new VectorOfRect())
                using (CvString s = new CvString(groupingTrainedFileName))
                    using (InputArray iaChannels = channels.GetInputArray())
                    {
                        GCHandle erstatsHandle = GCHandle.Alloc(erstatPtrs, GCHandleType.Pinned);
                        CvERGrouping(iaChannels, erstatsHandle.AddrOfPinnedObject(), erstatPtrs.Length, s, minProbability, regions);
                        erstatsHandle.Free();
                        return(regions.ToArray());
                    }
        }
Exemplo n.º 32
0
        /// <summary>
        /// The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects.
        /// </summary>
        /// <param name="filename">Name of file to be loaded.</param>
        /// <param name="flags">Read flags</param>
        /// <returns>Null if the reading fails, otherwise, an array of Mat from the file</returns>
        public static Mat[] Imreadmulti(String filename, CvEnum.ImreadModes flags = ImreadModes.AnyColor)
        {
            using (VectorOfMat vm = new VectorOfMat())
                using (CvString strFilename = new CvString(filename))
                {
                    if (!cveImreadmulti(strFilename, vm, flags))
                    {
                        return(null);
                    }
                    Mat[] result = new Mat[vm.Size];

                    for (int i = 0; i < result.Length; i++)
                    {
                        Mat m = new Mat();
                        CvInvoke.Swap(m, vm[i]);
                        result[i] = m;
                    }
                    return(result);
                }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Saves the image to the specified file. The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format
        /// </summary>
        /// <param name="filename">The name of the file to be saved to</param>
        /// <param name="image">The image to be saved</param>
        /// <param name="parameters">The parameters</param>
        /// <returns>true if success</returns>
        public static bool Imwrite(String filename, IInputArray image, params KeyValuePair <CvEnum.ImwriteFlags, int>[] parameters)
        {
            using (Util.VectorOfInt vec = new Util.VectorOfInt())
            {
                PushParameters(vec, parameters);

                using (CvString s = new CvString(filename))
                //
                {
#if __IOS__
                    using (InputArray iaImage = image.GetInputArray())
                        return(cveImwrite(s, iaImage, vec));
#else
                    bool containsUnicode = (s.Length != filename.Length);
                    if (containsUnicode &&
                        (Emgu.Util.Platform.OperationSystem != OS.MacOS) &&
                        (Emgu.Util.Platform.OperationSystem != OS.Linux))
                    {
                        //Handle unicode in Windows platform
                        //Work around for Open CV ticket:
                        //https://github.com/Itseez/opencv/issues/4292
                        //https://github.com/Itseez/opencv/issues/4866
                        System.IO.FileInfo fi = new System.IO.FileInfo(filename);

                        using (VectorOfByte vb = new VectorOfByte())
                        {
                            CvInvoke.Imencode(fi.Extension, image, vb, parameters);
                            byte[] arr = vb.ToArray();
                            System.IO.File.WriteAllBytes(filename, arr);
                            return(true);
                        }
                    }
                    else
                    {
                        using (InputArray iaImage = image.GetInputArray())
                            return(cveImwrite(s, iaImage, vec));
                    }
#endif
                }
            }
        }
Exemplo n.º 34
0
      /// <summary>
      /// Create video frame source from video file
      /// </summary>
      /// <param name="fileName">The name of the file</param>
      /// <param name="tryUseGpu">If true, it will try to create video frame source using gpu</param>
      public FrameSource(String fileName, bool tryUseGpu)
      {
         using(CvString s = new CvString(fileName))
         if (tryUseGpu)
         {
            try
            {
               _ptr = SuperresInvoke.cvSuperresCreateFrameSourceVideo(s, true);
            }
            catch
            {
               _ptr = SuperresInvoke.cvSuperresCreateFrameSourceVideo(s, false);
            }
         }
         else
         {
            _ptr = SuperresInvoke.cvSuperresCreateFrameSourceVideo(s, false);
         }

         _frameSourcePtr = _ptr;
      }
Exemplo n.º 35
0
        /// <summary>
        /// Create a capture from file or a video stream
        /// </summary>
        /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
        /// <param name="captureApi">The preferred Capture API backends to use. Can be used to enforce a specific reader implementation if multiple are available.</param>
        public VideoCapture(String fileName, API captureApi = API.Any)
        {
            using (CvString s = new CvString(fileName))
            {
                /*
                 * if (Util.CvToolbox.HasFFMPEG)
                 * {
                 * _captureModuleType = CaptureModuleType.FFMPEG;
                 * _ptr = CvInvoke.cvCreateFileCapture_FFMPEG(fileName);
                 * }
                 * else*/
                {
                    _captureModuleType = CaptureModuleType.Highgui;
                    _ptr = CvInvoke.cveVideoCaptureCreateFromFile(s, captureApi);
                }

                if (_ptr == IntPtr.Zero)
                {
                    throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
                }
            }
        }
Exemplo n.º 36
0
        ///<summary> Create a CascadeClassifier from the specific file</summary>
        ///<param name="fileName"> The name of the file that contains the CascadeClassifier</param>
        public CascadeClassifier(String fileName)
        {
#if !NETFX_CORE
            FileInfo file = new FileInfo(fileName);
            if (!file.Exists)
#if (UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE || UNITY_METRO)
            { throw new FileNotFoundException("File '{0}' not found", file.FullName); }
#else
            { throw new FileNotFoundException(Properties.StringTable.FileNotFound, file.FullName); }
#endif
#endif
            using (CvString s = new CvString(fileName))
                _ptr = CvCascadeClassifierCreate(s);

            if (_ptr == IntPtr.Zero)
            {
#if NETFX_CORE || (UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE || UNITY_METRO)
                throw new NullReferenceException(String.Format("Fail to create HaarCascade object: {0}", fileName));
#else
                throw new NullReferenceException(String.Format(Properties.StringTable.FailToCreateHaarCascade, file.FullName));
#endif
            }
        }
Exemplo n.º 37
0
 /// <summary>
 /// Get the list of parameter definitions
 /// </summary>
 /// <param name="algorithm">The algorithm to retrieve the parameter list from</param>
 /// <returns>The list of parameter definitions</returns>
 public static ParamDef[] GetParams(this IAlgorithm algorithm)
 {
     using (VectorOfCvString names = new VectorOfCvString())
         using (VectorOfInt types = new VectorOfInt())
             using (VectorOfCvString helps = new VectorOfCvString())
             {
                 CvInvoke.cveAlgorithmGetParams(algorithm.AlgorithmPtr, names, types, helps);
                 ParamDef[] results = new ParamDef[names.Size];
                 for (int i = 0; i < results.Length; i++)
                 {
                     ParamDef t = new ParamDef();
                     using (CvString n = names[i])
                         using (CvString h = helps[i])
                         {
                             t.Name = n.ToString();
                             t.Type = (ParamType)types[i];
                             t.Help = h.ToString();
                         }
                     results[i] = t;
                 }
                 return(results);
             }
 }
Exemplo n.º 38
0
      ///<summary> Create a CascadeClassifier from the specific file</summary>
      ///<param name="fileName"> The name of the file that contains the CascadeClassifier</param>
      public CascadeClassifier(String fileName)
      {
#if !NETFX_CORE
         FileInfo file = new FileInfo(fileName);
         if (!file.Exists)
#if ( UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE || UNITY_METRO )
            throw new FileNotFoundException("File '{0}' not found", file.FullName);
#else
            throw new FileNotFoundException(Properties.StringTable.FileNotFound, file.FullName);
#endif
#endif
         using (CvString s = new CvString(fileName))
            _ptr = CvCascadeClassifierCreate(s);

         if (_ptr == IntPtr.Zero)
         {
#if NETFX_CORE || ( UNITY_ANDROID || UNITY_IPHONE || UNITY_STANDALONE || UNITY_METRO )
            throw new NullReferenceException(String.Format("Fail to create HaarCascade object: {0}", fileName));
#else
            throw new NullReferenceException(String.Format(Properties.StringTable.FailToCreateHaarCascade, file.FullName));
#endif
         }
      }
Exemplo n.º 39
0
        /// <summary>
        /// Saves the image to the specified file. The image format is chosen depending on the filename extension, see cvLoadImage. Only 8-bit single-channel or 3-channel (with 'BGR' channel order) images can be saved using this function. If the format, depth or channel order is different, use cvCvtScale and cvCvtColor to convert it before saving, or use universal cvSave to save the image to XML or YAML format
        /// </summary>
        /// <param name="filename">The name of the file to be saved to</param>
        /// <param name="image">The image to be saved</param>
        /// <param name="parameters">The parameters</param>
        /// <returns>true if success</returns>
        public static bool Imwrite(String filename, IInputArray image, params int[] parameters)
        {
            using (Util.VectorOfInt vec = new Util.VectorOfInt())
            {
                if (parameters.Length > 0)
                {
                    vec.Push(parameters);
                }
                using (CvString s = new CvString(filename))
                    using (InputArray iaImage = image.GetInputArray())
                    {
#if !(__IOS__ || __ANDROID__ || NETFX_CORE)
                        bool containsUnicode = (s.Length != filename.Length);
                        if (containsUnicode &&
                            (Emgu.Util.Platform.OperationSystem != OS.MacOSX) &&
                            (Emgu.Util.Platform.OperationSystem != OS.Linux))
                        {
                            //Handle unicode in Windows platform
                            //Work around for Open CV ticket:
                            //https://github.com/Itseez/opencv/issues/4292
                            //https://github.com/Itseez/opencv/issues/4866
                            System.IO.FileInfo fi = new System.IO.FileInfo(filename);

                            using (VectorOfByte vb = new VectorOfByte())
                            {
                                CvInvoke.Imencode(fi.Extension, image, vb, parameters);
                                byte[] arr = vb.ToArray();
                                System.IO.File.WriteAllBytes(filename, arr);
                                return(true);
                            }
                        }
                        else
#endif
                        return(cveImwrite(s, iaImage, vec));
                    }
            }
        }
Exemplo n.º 40
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="m">The Mat to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(Mat m, String nodeName = null)
 {
    using (CvString cs = new CvString(nodeName))
       CvInvoke.cveFileStorageWriteMat(_ptr, cs, m);
 }
Exemplo n.º 41
0
 /// <summary>
 /// encode image and store the result as a byte vector.
 /// </summary>
 /// <param name="ext">The image format</param>
 /// <param name="image">The image</param>
 /// <param name="buf">Output buffer resized to fit the compressed image.</param>
 /// <param name="parameters">The pointer to the array of intergers, which contains the parameter for encoding, use IntPtr.Zero for default</param>
 public static void Imencode(String ext, IInputArray image, VectorOfByte buf, params int[] parameters)
 {
    using (CvString extStr = new CvString(ext))
    using (VectorOfInt p = new VectorOfInt())
    {
       if (parameters.Length > 0)
          p.Push(parameters);
       using (InputArray iaImage = image.GetInputArray())
          cveImencode(extStr, iaImage, buf, p);
    }
 }
Exemplo n.º 42
0
      public void TestCvString()
      {
         string s = "From ? to ?";

         using (CvString str = new CvString(s))
         {
            string s2 = str.ToString();
            EmguAssert.IsTrue(s.Equals(s2));
         }
      }
Exemplo n.º 43
0
 /// <summary>
 /// Convert the DepthType to a string that represent the OpenCL value type.
 /// </summary>
 /// <param name="depthType">The depth type</param>
 /// <param name="channels">The number of channels</param>
 /// <returns>A string the repsent the OpenCL value type</returns>
 public static String TypeToString(DepthType depthType, int channels = 1)
 {
    using (CvString str = new CvString())
    {
       oclTypeToString(CvInvoke.MakeType(depthType, channels), str);
       return str.ToString();
    }
 }
Exemplo n.º 44
0
      /// <summary>
      /// Create a capture from file or a video stream
      /// </summary>
      /// <param name="fileName">The name of a file, or an url pointed to a stream.</param>
      public Capture(String fileName)
      {
         using (CvString s = new CvString(fileName))
         {
            /*
            if (Util.CvToolbox.HasFFMPEG)
            {
               _captureModuleType = CaptureModuleType.FFMPEG;
               _ptr = CvInvoke.cvCreateFileCapture_FFMPEG(fileName);
            }
            else*/
            {
               _captureModuleType = CaptureModuleType.Highgui;
               _ptr = CvInvoke.cveVideoCaptureCreateFromFile(s);
            }

            if (_ptr == IntPtr.Zero)
               throw new NullReferenceException(String.Format("Unable to create capture from {0}", fileName));
         }
      }
Exemplo n.º 45
0
 /// <summary>
 /// Gets the specified element of the top-level mapping.
 /// </summary>
 /// <param name="nodeName">Name of the node.</param>
 /// <returns>The specified element of the top-level mapping.</returns>
 public FileNode GetNode(String nodeName)
 {
    using (CvString nn = new CvString(nodeName))
    {
       return new FileNode(CvInvoke.cveFileStorageGetNode(_ptr, nn));
    }
 }
Exemplo n.º 46
0
 /// <summary>
 /// encode image and store the result as a byte vector.
 /// </summary>
 /// <param name="ext">The image format</param>
 /// <param name="image">The image</param>
 /// <param name="buf">Output buffer resized to fit the compressed image.</param>
 /// <param name="parameters">The pointer to the array of intergers, which contains the parameter for encoding, use IntPtr.Zero for default</param>
 public static void Imencode(String ext, IInputArray image, VectorOfByte buf, params KeyValuePair<CvEnum.ImwriteFlags, int>[] parameters)
 {
    using (CvString extStr = new CvString(ext))
    using (VectorOfInt p = new VectorOfInt())
    {
       PushParameters(p, parameters);
       using (InputArray iaImage = image.GetInputArray())
          cveImencode(extStr, iaImage, buf, p);
    }
 }
Exemplo n.º 47
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="value">The value to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(int value, String nodeName = null)
 {
    using (CvString cs = new CvString(nodeName))
       CvInvoke.cveFileStorageWriteInt(_ptr, cs, value);
 }
Exemplo n.º 48
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="m">The Mat to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(Mat m, String nodeName = null)
 {
     using (CvString cs = new CvString(nodeName))
         CvInvoke.cveFileStorageWriteMat(_ptr, cs, m);
 }
Exemplo n.º 49
0
 /// <summary>
 /// Closes the file and releases all the memory buffers
 /// Call this method after all I/O operations with the storage are finished. If the storage was
 /// opened for writing data and FileStorage.Mode.Write was specified
 /// </summary>
 /// <returns>The string that represent the text in the FileStorage</returns>
 public String ReleaseAndGetString()
 {
    using (CvString s = new CvString())
    {
       CvInvoke.cveFileStorageReleaseAndGetString(_ptr, s);
       return s.ToString();
    }
 }
Exemplo n.º 50
0
 /// <summary>
 /// Creates a window which can be used as a placeholder for images and trackbars. Created windows are reffered by their names. 
 /// If the window with such a name already exists, the function does nothing.
 /// </summary>
 /// <param name="name">Name of the window which is used as window identifier and appears in the window caption</param>
 /// <param name="flags">Flags of the window.</param>
 public static void NamedWindow(String name, CvEnum.NamedWindowType flags = NamedWindowType.AutoSize)
 {
    using (CvString s = new CvString(name))
       cveNamedWindow(s, flags);
 }
Exemplo n.º 51
0
 public OclProgramSource(String source)
 {
    _programSource = new CvString(source);
    _ptr = OclInvoke.oclProgramSourceCreate(_programSource);
    
 }
Exemplo n.º 52
0
 public void TestUnicodeCvString()
 {
    String target = "测试.jpg";
    using (CvString s = new CvString(target))
    {
       String s2 = s.ToString();
       EmguAssert.IsTrue(s2.Equals(target));
    }
 }
Exemplo n.º 53
0
 /// <summary>
 /// Renders the text in the image with the specified font and color. The printed text is clipped by ROI rectangle. Symbols that do not belong to the specified font are replaced with the rectangle symbol.
 /// </summary>
 /// <param name="img">Input image</param>
 /// <param name="text">String to print</param>
 /// <param name="org">Coordinates of the bottom-left corner of the first letter</param>
 /// <param name="fontFace">Font type.</param>
 /// <param name="fontScale">Font scale factor that is multiplied by the font-specific base size.</param>
 /// <param name="color">Text color</param>
 /// <param name="thickness">Thickness of the lines used to draw a text.</param>
 /// <param name="lineType">Line type</param>
 /// <param name="bottomLeftOrigin">When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.</param>
 public static void PutText(
    IInputOutputArray img, String text, Point org, CvEnum.FontFace fontFace, double fontScale,
    MCvScalar color, int thickness = 1, CvEnum.LineType lineType = CvEnum.LineType.EightConnected, bool bottomLeftOrigin = false)
 {
    using (CvString s = new CvString(text))
    using (InputOutputArray ioaImg = img.GetInputOutputArray())
       cvePutText(ioaImg, s, ref org, fontFace, fontScale, ref color, thickness, lineType, bottomLeftOrigin);
 }
Exemplo n.º 54
0
 /// <summary>
 /// Destroys the window with a given name
 /// </summary>
 /// <param name="name">Name of the window to be destroyed</param>
 public static void DestroyWindow(String name)
 {
    using (CvString s = new CvString(name))
       cveDestroyWindow(s);
 }
Exemplo n.º 55
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="value">The value to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(String value, String nodeName = null)
 {
     using (CvString cs = new CvString(nodeName))
         using (CvString vs = new CvString(value))
             CvInvoke.cveFileStorageWriteString(_ptr, cs, vs);
 }
Exemplo n.º 56
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="value">The value to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(String value, String nodeName = null)
 {
    using (CvString cs = new CvString(nodeName))
    using (CvString vs = new CvString(value))
       CvInvoke.cveFileStorageWriteString(_ptr, cs, vs);
 }
Exemplo n.º 57
0
 /// <summary>
 /// Writes the specified Mat to the node with the specific <param Name="nodeName"></param>
 /// </summary>
 /// <param name="value">The value to be written to the file storage</param>
 /// <param name="nodeName">The name of the node.</param>
 public void Write(int value, String nodeName = null)
 {
     using (CvString cs = new CvString(nodeName))
         CvInvoke.cveFileStorageWriteInt(_ptr, cs, value);
 }
Exemplo n.º 58
0
 /// <summary>
 /// Show a widget in the window
 /// </summary>
 /// <param name="id">A unique id for the widget.</param>
 /// <param name="widget">The widget to be displayed in the window.</param>
 /// <param name="pose">Pose of the widget.</param>
 public void ShowWidget(String id, IWidget widget, Affine3d pose = null)
 {
     using (CvString cvsId = new CvString(id))
         CvInvoke.cveViz3dShowWidget(_ptr, cvsId, widget.GetWidget, pose);
 }
Exemplo n.º 59
0
 /// <summary>
 /// Sets pose of a widget in the window.
 /// </summary>
 /// <param name="id">The id of the widget whose pose will be set.</param>
 /// <param name="pose">The new pose of the widget.</param>
 public void SetWidgetPose(String id, Affine3d pose)
 {
     using (CvString cvsId = new CvString(id))
         CvInvoke.cveViz3dSetWidgetPose(_ptr, cvsId, pose);
 }
Exemplo n.º 60
0
 /// <summary>
 /// Calculates the width and height of a text string.
 /// </summary>
 /// <param name="text">Input text string.</param>
 /// <param name="fontFace">Font to use</param>
 /// <param name="fontScale">Font scale factor that is multiplied by the font-specific base size.</param>
 /// <param name="thickness">Thickness of lines used to render the text. </param>
 /// <param name="baseLine">Y-coordinate of the baseline relative to the bottom-most text point.</param>
 /// <returns>The size of a box that contains the specified text.</returns>
 public static Size GetTextSize(String text, CvEnum.FontFace fontFace, double fontScale, int thickness, ref int baseLine)
 {
    Size s = new Size();
    using (CvString textStr = new CvString(text))
       cveGetTextSize(textStr, fontFace, fontScale, thickness, ref baseLine, ref s);
    return s;
 }