cvQueryFrame() приватный Метод

private cvQueryFrame ( IntPtr capture ) : IntPtr
capture IntPtr
Результат IntPtr
Пример #1
0
        /// <summary>
        /// Capture a Gray image frame
        /// </summary>
        /// <returns> A Gray image frame</returns>
        public virtual Image <Gray, Byte> QueryGrayFrame()
        {
            IntPtr img = CvInvoke.cvQueryFrame(Ptr);

            MIplImage iplImage = (MIplImage)Marshal.PtrToStructure(img, typeof(MIplImage));

            Image <Gray, Byte> res;

            if (iplImage.nChannels == 3)
            { //if the image captured is Bgr, convert it to Grayscale
                res = new Image <Gray, Byte>(iplImage.width, iplImage.height);
                CvInvoke.cvCvtColor(img, res.Ptr, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2GRAY);
            }
            else
            {
                res = new Image <Gray, byte>(iplImage.width, iplImage.height, iplImage.widthStep, iplImage.imageData);
            }

            //inplace flip the image if necessary
            res._Flip(FlipType);

            return(res);
        }
Пример #2
0
        /// <summary>
        /// Capture a Bgr image frame
        /// </summary>
        /// <returns> A Bgr image frame</returns>
        public virtual Image <Bgr, Byte> QueryFrame()
        {
#if TEST_CAPTURE
            Image <Bgr, Byte> tmp  = new Image <Bgr, Byte>(320, 240, new Bgr());
            MCvFont           font = new MCvFont(CvEnum.FONT.CV_FONT_HERSHEY_PLAIN, 1.0, 1.0);
            tmp.Draw(System.DateTime.Now.Ticks.ToString(),
                     ref font,
                     new Point(10, 50),
                     new Bgr(255.0, 255.0, 255.0));
            IntPtr img = tmp;
#else
            IntPtr img = CvInvoke.cvQueryFrame(Ptr);
#endif
            if (img == IntPtr.Zero)
            {
                return(null);
            }

            MIplImage iplImage = (MIplImage)Marshal.PtrToStructure(img, typeof(MIplImage));

            Image <Bgr, Byte> res;
            if (iplImage.nChannels == 1)
            { //if the image captured is Grayscale, convert it to BGR
                res = new Image <Bgr, Byte>(iplImage.width, iplImage.height);
                CvInvoke.cvCvtColor(img, res.Ptr, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_GRAY2BGR);
            }
            else
            {
                res = new Image <Bgr, byte>(iplImage.width, iplImage.height, iplImage.widthStep, iplImage.imageData);
            }

            //inplace flip the image if necessary
            res._Flip(FlipType);

            return(res);
        }