Exemple #1
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));
     }
 }
 /// <summary>
 /// Create the standard vector of VectorOfInt
 /// </summary>
 public VectorOfVectorOfInt(int[][] values)
     : this()
 {
     using (VectorOfInt v = new VectorOfInt())
     {
         for (int i = 0; i < values.Length; i++)
         {
             v.Push(values[i]);
             Push(v);
             v.Clear();
         }
     }
 }
Exemple #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));
                    }
            }
        }