Beispiel #1
0
        public void Empty()
        {
            using var umat1 = new UMat();
            Assert.True(umat1.Empty());

            using var umat2 = new UMat(1, 2, MatType.CV_32FC1);
            Assert.False(umat2.Empty());
        }
Beispiel #2
0
        void doExecute(object param)
        {
            // Capture capture;

            VideoCapture capture = VideoCapture.FromCamera(0, VideoCaptureAPIs.ANY);

            UMat frame = new UMat();

            /*
             *
             * var src = new Mat("lenna.png", ImreadModes.Grayscale);
             * var dst = new Mat();
             *
             * Cv2.Canny(src, dst, 50, 200);
             * using (new Window("src image", src))
             * using (new Window("dst image", dst))
             * {
             *  Cv2.WaitKey();
             * }
             */


            for (; ;)
            {
                if (!mStopCapture)
                {
                    break;
                }

                _ = capture.Read(frame);
                Bitmap bitmap = BitmapConverter.ToBitmap(frame.GetMat(AccessFlag.MASK));

                if (frame.Empty())
                {
                    //  cerr << "Can't capture frame: " << i << std::endl;
                    break;
                }

                // OpenCV Trace macro for NEXT named region in the same C++ scope
                // Previous "read" region will be marked complete on this line.
                // Use this to eliminate unnecessary curly braces.
                // process_frame(frame);

                updateView(bitmap);
            }
        }