当前位置: 首页>>代码示例>>C#>>正文


C# Mat.ToBitmap方法代码示例

本文整理汇总了C#中Mat.ToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.ToBitmap方法的具体用法?C# Mat.ToBitmap怎么用?C# Mat.ToBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mat的用法示例。


在下文中一共展示了Mat.ToBitmap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CppTest

        public CppTest()
        {
            //PixelAccess();

            using (Mat mat = new Mat(Const.ImageLenna, LoadMode.Color))
            {
                //CvSize s;
                //CvPoint p;
                //mat.LocateROI(out s, out p);

                // CvMatへの変換
                CvMat m = mat.ToCvMat();
                Console.WriteLine(m);

                // 行を一部分切り出し
                Mat row = mat.RowRange(100, 200);

                // IplImageへ変換し、highguiにより描画
                IplImage img = row.ToIplImage();
                using (new CvWindow("highgui", img))
                {
                    Cv.WaitKey();
                }

                // Bitmapに変換して、WindowsFormで描画する
                using (Bitmap bitmap = mat.ToBitmap())
                using (Form form = new Form() { Text = "WindowsForms", ClientSize = new System.Drawing.Size(bitmap.Width, bitmap.Height) })
                using (PictureBox pb = new PictureBox() { Image = bitmap, Dock = DockStyle.Fill })
                {
                    form.Controls.Add(pb);
                    Application.Run(form);
                }

                // cv::imshowによる表示
                CvCpp.NamedWindow("imshow", WindowMode.AutoSize);
                CvCpp.ImShow("imshow", mat);
                CvCpp.WaitKey(0);
                Cv.DestroyAllWindows();
            }
        }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:40,代码来源:CppTest.cs

示例2: timer1_Tick

        private void timer1_Tick(object sender, EventArgs e)
        {
            Mat mat1 = new Mat(_webCam1.QueryFrame());
            CvPoint webCamPos1 = GetMaxLoc(mat1);
            webCameraImage1.Image = mat1.ToBitmap();
            g = Graphics.FromImage(webCameraImage1.Image);
            g.DrawLine(new Pen(Color.Gold), webCamPos1.X + _temp.Width / 2, 0, webCamPos1.X + _temp.Width / 2, 480);
            g.DrawLine(new Pen(Color.Gold), 0, webCamPos1.Y + _temp.Height / 2, 640, webCamPos1.Y + _temp.Height / 2);

            Mat mat2 = new Mat(_webCam2.QueryFrame());
            CvPoint webCamPos2 = GetMaxLoc(mat2);
            webCameraImage2.Image = mat2.ToBitmap();
            g = Graphics.FromImage(webCameraImage2.Image);
            g.DrawLine(new Pen(Color.Gold), webCamPos2.X + _temp.Width / 2, 0, webCamPos2.X + _temp.Width / 2, 480);
            g.DrawLine(new Pen(Color.Gold), 0, webCamPos2.Y + _temp.Height / 2, 640, webCamPos2.Y + _temp.Height / 2);

            var d = RoboService.GetDistance(webCamPos1, webCamPos2);
            distance.Text = d.ToString(CultureInfo.InvariantCulture);
            var a = RoboService.GetAngle(webCamPos1);
        }
开发者ID:mmcs-robotics,项目名称:lidar_2015,代码行数:20,代码来源:Form1.cs

示例3: SetOutputImage

        void SetOutputImage(Mat outputImage_0, Mat outputImage_1, Mat Image)
        {
            
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                //this.DrawLine(this.GetEllipsePosition(InOutPutMode.output), InOutPutMode.output);

                //windowの画像設定 ここから
                #region
                if (this.caliblationMode == CaliblationMode.back) this.wscs2.SetImage(outputImage_0.ToBitmap());
                else if (this.caliblationMode == CaliblationMode.floor) this.wscs2.SetImage(outputImage_1.ToBitmap());
                else this.wscs2.SetImage(this._sumMat(outputImage_0,outputImage_1,true).ToBitmap());
                this.wscs3_0.SetImage(outputImage_0.ToBitmap());
                this.wscs3_1.SetImage(outputImage_1.ToBitmap());
                #endregion

            
                switch (this.caliblationMode)
                {
                    case CaliblationMode.back:
                        this.OutputImage.Source = WriteableBitmapConverter.ToWriteableBitmap(outputImage_0); break;
                    case CaliblationMode.floor:
                        this.OutputImage.Source = WriteableBitmapConverter.ToWriteableBitmap(outputImage_1); break;
                    case CaliblationMode.calibration:
                        this.OutputImage.Source = WriteableBitmapConverter.ToWriteableBitmap(Image); break;
                }
            }));
            
        }
开发者ID:mahoo168,项目名称:mahoo,代码行数:29,代码来源:MainWindow.xaml.cs

示例4: ToMatGrayScale

        public void ToMatGrayScale()
        {
            Mat img = new Mat(FilePath.Lenna511, LoadMode.GrayScale);
            Bitmap bitmap = img.ToBitmap();

            Mat converted = BitmapConverter2.ToMat(bitmap);
            //Mat converted = Mat.FromBitmap(bitmap);

            using (new Window("Grayscale Bitmap to Mat test", converted))
            {
                Cv2.WaitKey();
            }
        }
开发者ID:jorik041,项目名称:opencvsharp,代码行数:13,代码来源:MatToBitmap.cs

示例5: usingCppInterface2

        private static void usingCppInterface2()
        {
            // Cv2.ImRead
            using (var src = new Mat(@"..\..\Images\Penguin.Png", LoadMode.AnyDepth | LoadMode.AnyColor))
            using (var dst = new Mat())
            {
                Cv2.CvtColor(src, dst, ColorConversion.BgrToGray);

                // How to export
                using (var bitmap = dst.ToBitmap()) // => OpenCvSharp.Extensions.BitmapConverter.ToBitmap(dst)
                {
                    bitmap.Save("gray.png", ImageFormat.Png);
                }

                using (new Window("BgrToGray C++: src", image: src))
                using (new Window("BgrToGray C++: dst", image: dst))
                {
                    Cv2.WaitKey();
                }
            }
        }
开发者ID:kauser-cse-buet,项目名称:OpenCVSharp-Samples,代码行数:21,代码来源:Program.cs

示例6: getBarcodeText

        private static string getBarcodeText(Mat barcode)
        {
            // `ZXing.Net` needs a white space around the barcode
            var barcodeWithWhiteSpace = new Mat(new Size(barcode.Width + 30, barcode.Height + 30), MatType.CV_8U, Scalar.White);
            var drawingRect = new Rect(new Point(15, 15), new Size(barcode.Width, barcode.Height));
            var roi = barcodeWithWhiteSpace[drawingRect];
            barcode.CopyTo(roi);

            Cv2.ImShow("Enhanced Barcode", barcodeWithWhiteSpace);
            Cv2.WaitKey(1); // do events

            return decodeBarcodeText(barcodeWithWhiteSpace.ToBitmap());
        }
开发者ID:kauser-cse-buet,项目名称:OpenCVSharp-Samples,代码行数:13,代码来源:Program.cs


注:本文中的Mat.ToBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。