Exemplo n.º 1
0
        public void cropSubImage(CvRect rect, CvImageWrapper croppedImage)
        {
            if (rect.x < 0 || rect.y < 0 ||
                (rect.x + rect.width > this._size.Width) ||
                (rect.y + rect.height > this._size.Height))
            {
                throw new Exception("invalid rect: " + rect);
            }

            cvSetImageROI(this._rawPtr, rect);
            cvCopy(this._rawPtr, croppedImage._rawPtr, IntPtr.Zero);
            cvResetImageROI(this._rawPtr);
        }
Exemplo n.º 2
0
        public CvImageWrapper cropSubImage(CvRect rect)
        {
            Bitmap b  = GetBitMap();
            Bitmap b2 = new Bitmap(rect.width, rect.height, b.PixelFormat);

            for (int x = 0; x < rect.width; x++)
            {
                for (int y = 0; y < rect.height; y++)
                {
                    b2.SetPixel(x, y, b.GetPixel(x + rect.x, y + rect.y));
                }
            }

            return(new CvImageWrapper(b2));
        }
Exemplo n.º 3
0
 private static extern void cvSetImageROI(IntPtr img, CvRect rect);