OpenCvSharp.Cv2.Flip C# (CSharp) Method

Flip() public static method

reverses the order of the rows, columns or both in a matrix
public static Flip ( InputArray src, OutputArray dst, FlipMode flipCode ) : void
src InputArray The source array
dst OutputArray The destination array; will have the same size and same type as src
flipCode FlipMode Specifies how to flip the array: /// 0 means flipping around the x-axis, positive (e.g., 1) means flipping around y-axis, /// and negative (e.g., -1) means flipping around both axes. See also the discussion below for the formulas.
return void
        public static void Flip(InputArray src, OutputArray dst, FlipMode flipCode)
        {
            if (src == null)
                throw new ArgumentNullException(nameof(src));
            if (dst == null)
                throw new ArgumentNullException(nameof(dst));
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();
            NativeMethods.core_flip(src.CvPtr, dst.CvPtr, (int)flipCode);
            GC.KeepAlive(src);
            dst.Fix();
        }
        #endregion

Usage Example

コード例 #1
0
        /// <summary>
        /// 播放摄像头线程
        /// </summary>
        private void Play_Camera()
        {
            while (bPlayflag)
            {
                //Thread.Sleep(40);
                Mat cFrame = new Mat();
                m_vCapture.Read(cFrame);
                int sleepTime = (int)Math.Round(1000 / m_vCapture.Fps);
                Cv2.WaitKey(sleepTime);
                if (cFrame.Empty())
                {
                    continue;
                }
                Cv2.Flip(cFrame, cFrame, OpenCvSharp.FlipMode.Y);
                Rect cMaxrect = new Rect(170, 90, 150, 150);
                if (bTakePicture)//拍照,截取指定区域
                {
                    Mat cHead = new Mat(cFrame, cMaxrect);
                    Cv2.ImWrite(PicSavePath, cHead);
                    SetPictureBoxImage(pic_head, cHead.ToBitmap());
                    cHead.Release();
                    bTakePicture = false;
                }
                //绘制指定区域(人脸框)
                Scalar color = new Scalar(0, 100, 0);
                Cv2.Rectangle(cFrame, cMaxrect, color, 2);

                SetPictureBoxImage(pic_cam, cFrame.ToBitmap());

                cFrame.Release();//释放
            }
        }
Cv2