當前位置: 首頁>>代碼示例>>C#>>正文


C# IplImage.SaveImage方法代碼示例

本文整理匯總了C#中OpenCvSharp.IplImage.SaveImage方法的典型用法代碼示例。如果您正苦於以下問題:C# IplImage.SaveImage方法的具體用法?C# IplImage.SaveImage怎麽用?C# IplImage.SaveImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenCvSharp.IplImage的用法示例。


在下文中一共展示了IplImage.SaveImage方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SaveImage

        public SaveImage()
        {
            using (IplImage img = new IplImage(Const.Image16bit, LoadMode.Color))
            {
                // JPEG quality test
                img.SaveImage("q000.jpg", new JpegEncodingParam(0));
                img.SaveImage("q025.jpg", new JpegEncodingParam(25));
                img.SaveImage("q050.jpg", new JpegEncodingParam(50));
                img.SaveImage("q075.jpg", new JpegEncodingParam(75));
                img.SaveImage("q100.jpg", new JpegEncodingParam(100));

                using (IplImage q000 = new IplImage("q000.jpg", LoadMode.Color))
                using (IplImage q025 = new IplImage("q025.jpg", LoadMode.Color))
                using (IplImage q050 = new IplImage("q050.jpg", LoadMode.Color))
                using (IplImage q075 = new IplImage("q075.jpg", LoadMode.Color))
                using (IplImage q100 = new IplImage("q100.jpg", LoadMode.Color))
                using (CvWindow w000 = new CvWindow("quality 0", q000))
                using (CvWindow w025 = new CvWindow("quality 25", q025))
                using (CvWindow w050 = new CvWindow("quality 50", q050))
                using (CvWindow w075 = new CvWindow("quality 75", q075))
                using (CvWindow w100 = new CvWindow("quality 100", q100))
                {
                    Cv.WaitKey();
                }
            }
        }
開發者ID:qxp1011,項目名稱:opencvsharp,代碼行數:26,代碼來源:SaveImage.cs

示例2: Main

        static void Main(string[] args)
        {
            //  CreateCameraCaptureの引數はカメラのIndex(通常は0から始まる)
            using (var capture = Cv.CreateCameraCapture(0))
            {
                IplImage frame = new IplImage();

                //  W320 x H240のウィンドウを作る
                double w = 320, h = 240;
                Cv.SetCaptureProperty(capture, CaptureProperty.FrameWidth, w);
                Cv.SetCaptureProperty(capture, CaptureProperty.FrameHeight, h);

                //  何かキーを押すまでは、Webカメラの畫像を表示し続ける
                while (Cv.WaitKey(1) == -1)
                {
                    //  カメラからフレームを取得
                    frame = Cv.QueryFrame(capture);

                    //  Window「Capture」を作って、Webカメラの畫像を表示
                    Cv.ShowImage("Capture", frame);
                }

                //  bmp以外に、jpegやpngでの保存が可能
                frame.SaveImage("result.bmp");

                //  使い終わったWindow「Capture」を破棄
                Cv.DestroyWindow("Capture");
            }
        }
開發者ID:Grandge,項目名稱:CSharp-Sample,代碼行數:29,代碼來源:Program.cs

示例3: Edge

        public Edge()
        {
            using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.Color))
            using (IplImage gray = new IplImage(src.Size, BitDepth.U8, 1))
            using (IplImage temp = new IplImage(src.Size, BitDepth.S16, 1))
            using (IplImage dstSobel = new IplImage(src.Size, BitDepth.U8, 1))
            using (IplImage dstLaplace = new IplImage(src.Size, BitDepth.U8, 1))
            using (IplImage dstCanny = new IplImage(src.Size, BitDepth.U8, 1))
            {
                //src.CvtColor(gray, ColorConversion.RgbToGray);
                src.CvtColor(gray, ColorConversion.BgrToGray);

                // Sobel
                Cv.Sobel(gray, temp, 1, 0, ApertureSize.Size3);
                Cv.ConvertScaleAbs(temp, dstSobel);

                // Laplace
                Cv.Laplace(gray, temp);
                Cv.ConvertScaleAbs(temp, dstLaplace);

                // Canny
                Cv.Canny(gray, dstCanny, 50, 200, ApertureSize.Size3);

                using (new CvWindow("src", src)) 
                using (new CvWindow("sobel", dstSobel))
                using (new CvWindow("laplace", dstLaplace)) 
                using (new CvWindow("canny", dstCanny))
                {
                    CvWindow.WaitKey();
                }

                dstSobel.SaveImage("sobel.png");
                dstLaplace.SaveImage("laplace.png");
                dstCanny.SaveImage("canny.png");
            }
        }
開發者ID:healtech,項目名稱:opencvsharp,代碼行數:36,代碼來源:Edge.cs

示例4: Inpaint

        public Inpaint()
        {
            // cvInpaint
            // 畫像の不要な文字列部分に対するマスク畫像を指定して文字列を除去する

            Console.WriteLine(
                "Hot keys: \n" +
                "\tESC - quit the program\n" +
                "\tr - restore the original image\n" +
                "\ti or ENTER - run inpainting algorithm\n" +
                "\t\t(before running it, paint something on the image)\n" +
                "\ts - save the original image, mask image, original+mask image and inpainted image to desktop."
            );

            // 原畫像の読み込み
            using (IplImage img0 = new IplImage(Const.ImageFruits, LoadMode.AnyDepth | LoadMode.AnyColor))
            {
                // お絵かき用の畫像を確保(マスク)
                using (IplImage img = img0.Clone())
                using (IplImage inpaintMask = new IplImage(img0.Size, BitDepth.U8, 1))
                // Inpaintの出力先畫像を確保
                using (IplImage inpainted = img0.Clone())
                {
                    inpainted.Zero();
                    inpaintMask.Zero();

                    using (CvWindow wImage = new CvWindow("image", WindowMode.AutoSize, img))
                    {

                        // マウスイベントの処理
                        CvPoint prevPt = new CvPoint(-1, -1);
                        wImage.OnMouseCallback += delegate(MouseEvent ev, int x, int y, MouseEvent flags)
                        {
                            if (ev == MouseEvent.LButtonUp || (flags & MouseEvent.FlagLButton) == 0)
                            {
                                prevPt = new CvPoint(-1, -1);
                            }
                            else if (ev == MouseEvent.LButtonDown)
                            {
                                prevPt = new CvPoint(x, y);
                            }
                            else if (ev == MouseEvent.MouseMove && (flags & MouseEvent.FlagLButton) != 0)
                            {
                                CvPoint pt = new CvPoint(x, y);
                                if (prevPt.X < 0)
                                {
                                    prevPt = pt;
                                }
                                inpaintMask.Line(prevPt, pt, CvColor.White, 5, LineType.AntiAlias, 0);
                                img.Line(prevPt, pt, CvColor.White, 5, LineType.AntiAlias, 0);
                                prevPt = pt;
                                wImage.ShowImage(img);
                            }
                        };

                        for (; ; )
                        {
                            switch ((char)CvWindow.WaitKey(0))
                            {
                                case (char)27:    // ESCキーで終了
                                    CvWindow.DestroyAllWindows();
                                    return;
                                case 'r':   // 原畫像を復元
                                    inpaintMask.Zero();
                                    img0.Copy(img);
                                    wImage.ShowImage(img);
                                    break;
                                case 'i':   // Inpaintの実行
                                case '\r':
                                    CvWindow wInpaint = new CvWindow("inpainted image", WindowMode.AutoSize);
                                    img.Inpaint(inpaintMask, inpainted, 3, InpaintMethod.Telea);
                                    wInpaint.ShowImage(inpainted);
                                    break;
                                case 's': // 畫像の保存
                                    string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                                    img0.SaveImage(Path.Combine(desktop, "original.png"));
                                    inpaintMask.SaveImage(Path.Combine(desktop, "mask.png"));
                                    img.SaveImage(Path.Combine(desktop, "original+mask.png"));
                                    inpainted.SaveImage(Path.Combine(desktop, "inpainted.png"));
                                    break;
                            }
                        }

                    }

                }
            }

        }
開發者ID:healtech,項目名稱:opencvsharp,代碼行數:89,代碼來源:Inpaint.cs

示例5: SaveImage

        unsafe ImageDetail[] SaveImage(Target[] targets)
        {
            IList<ImageDetail> imgs = new List<ImageDetail>();

            foreach (Target t in targets)
            {
                Frame frame = t.BaseFrame;

                DateTime dt = DateTime.FromBinary(frame.timeStamp);

                for (int j = 0; j < t.FaceCount; ++j)
                {
                    IntPtr* f = ((IntPtr*)(t.FaceData)) + j;
                    IplImage aFace = new IplImage(*f);
                    aFace.IsEnabledDispose = false;

                    string facePath = GetFacePath(frame, dt, j);

                    aFace.SaveImage(facePath);

                    imgs.Add(ImageDetail.FromPath(facePath));

                }

            }

            ImageDetail[] details = new ImageDetail[imgs.Count];
            imgs.CopyTo(details, 0);

            return details;
        }
開發者ID:dalinhuang,項目名稱:appcollection,代碼行數:31,代碼來源:Presenter.cs

示例6: SaveFrame

        private static void SaveFrame(Frame frame)
        {
            IplImage ipl = new IplImage(frame.image);
            ipl.IsEnabledDispose = false;

            string path = frame.GetFileName();
            DateTime dt = DateTime.FromBinary(frame.timeStamp);

            string root = Path.Combine(Properties.Settings.Default.OutputPath,
                      frame.cameraID.ToString("d2"));

            string folder = ImageClassifier.BuildDestDirectory(root, dt, Properties.Settings.Default.BigImageDirectoryName);
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            path = Path.Combine(folder, path);
            ipl.SaveImage(path);
        }
開發者ID:dalinhuang,項目名稱:appcollection,代碼行數:20,代碼來源:Presenter.cs

示例7: SaveImage

        private static string SaveImage(IplImage image, DateTime captureTime)
        {
            var path = GetImagePath(captureTime);
            var dir = Path.GetDirectoryName(path);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            image.SaveImage(path);

            return path;
        }
開發者ID:dalinhuang,項目名稱:appcollection,代碼行數:12,代碼來源:FaceSearchFacade.cs

示例8: button1_Click_2

        private void button1_Click_2(object sender, EventArgs e)
        {
            string[] files = Directory.GetFiles(@"D:\pictures in hall");
            foreach (string file in files)
            {
                string ext = Path.GetExtension(file);
                if (ext != ".jpg") continue;

                Bitmap img1 = (Bitmap)Bitmap.FromFile(file);

                IplImage ipl = BitmapConverter.ToIplImage(img1);

                IplImage ipl1 = new IplImage(ipl.CvPtr);

                Bitmap bmp = ipl1.ToBitmap();
                this.pictureFace.Image = bmp;

                ipl1.SaveImage(@"d:\iplimg.jpg");

                return;

                //                 byte[] data = File.ReadAllBytes(file);
                //                 Frame f = new Frame();
                //                 f.data = IntPtr.Zero;// Marshal.AllocCoTaskMem(data.Length);
                //                 //Marshal.Copy(data, 0, f.data, data.Length);
                //                 f.dataLength = 0;// data.Length;
                //                 f.image = IntPtr.Zero;
                //                 f.timeStamp = 0;
                //                 f.searchRect = IntPtr.Zero;
                //                 f.fileName = Marshal.StringToCoTaskMemAnsi(file);
                //
                //                 bool group = NativeMethods.PreProcessFrame(ref f);

            }
        }
開發者ID:dalinhuang,項目名稱:appcollection,代碼行數:35,代碼來源:LiveCamera.cs


注:本文中的OpenCvSharp.IplImage.SaveImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。