コード例 #1
0
 /// <summary>
 /// Up-samples image and smoothes the result with gaussian kernel.
 ///   dst_width = src_width*2,
 ///   dst_height = src_height*2
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void PyrUp(CVImage dst, PyrFilter filter)
 {
     PInvoke.cvPyrUp(new __CvImagePtr(this), new __CvImagePtr(dst), (int)filter);
     CVUtils.CheckLastError();
 }
コード例 #2
0
 /// <summary>
 /// Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y)
 /// TODO: Remove 'sum' argument and return a CVArr object
 /// </summary>
 public void Integral(CVArr sum, CVArr sqsum, CVArr titled_sum)
 {
     PInvoke.cvIntegral(new __CvImagePtr(this), new __CvArrPtr(sum), new __CvArrPtr(sqsum), new __CvArrPtr(titled_sum));
 }
コード例 #3
0
 /// <summary>
 /// Calculates the image Laplacian: (d2/dx + d2/dy)I
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Laplace(CVArr dst, int aperture_size)
 {
     PInvoke.cvLaplace(new __CvArrPtr(this), new __CvArrPtr(dst), aperture_size);
 }
コード例 #4
0
 /// <summary>
 /// Resizes image (input array is resized to fit the destination array)
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Resize(CVArr dst, ResizeInterpolation interpolation)
 {
     PInvoke.cvResize(new __CvArrPtr(this), new __CvArrPtr(dst), (int)interpolation);
 }
コード例 #5
0
 public void PyrMeanShiftFiltering(CVArr dst, double sp, double sr, int max_level, CVTermCriteria termcrit)
 {
     PInvoke.cvPyrMeanShiftFiltering(new __CvArrPtr(this), new __CvArrPtr(dst), sp, sr, max_level, termcrit);
 }
コード例 #6
0
 /// <summary>
 /// Inpaints the selected region in the image
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Inpaint(CVArr inpaint_mask, CVArr dst, double inpaintRange, int flags)
 {
     PInvoke.cvInpaint(new __CvArrPtr(this), new __CvArrPtr(inpaint_mask), new __CvArrPtr(dst), inpaintRange, flags);
 }
コード例 #7
0
ファイル: CVVideoWriter.cs プロジェクト: tdck/opencvdotnet
        public void Release()
        {
            __CvVideoWriterPtr ptr = vw_; // CvVideoWriter* prt = vw_

            PInvoke.cvReleaseVideoWriter(ref ptr);
        }
コード例 #8
0
 /// <summary>
 /// Builds the whole pyramid at once. Output array of CvMat headers (levels[*])
 //  is initialized with the headers of subsequent pyramid levels
 /// TODO: Remove 'container' argument and return an object
 /// </summary>
 public void CalcPyramid(CVArr container, CVMat levels, int level_count, PyrFilter filter)
 {
     PInvoke.cvCalcPyramid(new __CvImagePtr(this), new __CvArrPtr(container), levels.Ptr, level_count, (int)filter);
 }
コード例 #9
0
 /// <summary>
 /// Resizes image (input array is resized to fit the destination array)
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Resize(CVArr dst, ResizeInterpolation interpolation)
 {
     PInvoke.cvResize(new __CvArrPtr(this), new __CvArrPtr(dst), (int)interpolation);
     CVUtils.CheckLastError();
 }
コード例 #10
0
ファイル: CVVideoWriter.cs プロジェクト: tdck/opencvdotnet
 public void WriteFrame(CVImage image)
 {
     PInvoke.cvWriteFrame(vw_, image.Internal);
 }
コード例 #11
0
 /// <summary>
 /// Calculates the image Laplacian: (d2/dx + d2/dy)I
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Laplace(CVArr dst, int aperture_size)
 {
     PInvoke.cvLaplace(new __CvArrPtr(this), new __CvArrPtr(dst), aperture_size);
     CVUtils.CheckLastError();
 }
コード例 #12
0
 /// <summary>
 /// Calculates an image derivative using generalized Sobel
 /// (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
 /// Scharr can be used only for the first dx or dy derivative
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Sobel(CVArr dst, int xorder, int yorder, int aperture_size)
 {
     PInvoke.cvSobel(new __CvArrPtr(this), new __CvArrPtr(dst), xorder, yorder, aperture_size);
     CVUtils.CheckLastError();
 }
コード例 #13
0
 /// <summary
 /// Segments image using seed "markers"
 /// </summary>
 public void Watershed(CVArr markers)
 {
     PInvoke.cvWatershed(new __CvArrPtr(this), new __CvArrPtr(markers));
     CVUtils.CheckLastError();
 }
コード例 #14
0
 /// <summary>
 /// Copies source 2D array inside of the larger destination array and
 /// makes a border of the specified type (IPL_BORDER_*) around the copied area.
 /// </summary>
 public CVImage CopyMakeBorder(CVImage dst, Point offset, int bordertype, CVScalar value)
 {
     PInvoke.cvCopyMakeBorder(new __CvArrPtr(this), new __CvArrPtr(dst), new __CvPoint(offset), bordertype, new __CvScalar(value));
     return(dst);
 }
コード例 #15
0
ファイル: CVVideoWriter.cs プロジェクト: tdck/opencvdotnet
 protected void Create(string filename, CVCodec codec, CVFramesPerSecond fps, int width, int height, bool is_color)
 {
     vw_ = PInvoke.cvCreateVideoWriter(filename, (int)codec, (int)fps,
                                       new __CvSize(width, height), is_color ? 1 : 0);
     CVUtils.CheckLastError();
 }
コード例 #16
0
 /// <summary>
 /// Up-samples image and smoothes the result with gaussian kernel.
 ///   dst_width = src_width*2,
 ///   dst_height = src_height*2
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void PyrUp(CVImage dst, PyrFilter filter)
 {
     PInvoke.cvPyrUp(new __CvImagePtr(this), new __CvImagePtr(dst), (int)filter);
 }
コード例 #17
0
 public static void ErrorsToExceptions()
 {
     PInvoke.cvRedirectError(_errHandler);
 }
コード例 #18
0
 /// <summary>
 /// Splits color or grayscale image into multiple connected components
 //  of nearly the same color/brightness using modification of Burt algorithm.
 //  comp with contain a pointer to sequence (CvSeq)
 //  of connected components (CvConnectedComp)
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void PyrSegmentation(CVImage dst, IntPtr storage, IntPtr comp, int level, double threshold1, double threshold2)
 {
     PInvoke.cvPyrSegmentation(new __CvImagePtr(this), new __CvImagePtr(dst), new __CvMemStoragePtr(storage), new __CvSeqPtr(comp), level, threshold1, threshold2);
 }
コード例 #19
0
 public void ResetROI()
 {
     PInvoke.cvResetImageROI(Internal);
     CVUtils.CheckLastError();
 }
コード例 #20
0
 /// <summary
 /// Segments image using seed "markers"
 /// </summary>
 public void Watershed(CVArr markers)
 {
     PInvoke.cvWatershed(new __CvArrPtr(this), new __CvArrPtr(markers));
 }
コード例 #21
0
 public unsafe CVImage(CVImage clone)
 {
     Create(clone.Width, clone.Height, clone.Depth, clone.Channels);
     PInvoke.cvConvertImage(clone.Array, this.image, clone.Internal.ToPointer()->origin == 1 ? (int)CVConvertImageFlags.Flip : 0);
     CVUtils.CheckLastError();
 }
コード例 #22
0
 /// <summary>
 /// Calculates an image derivative using generalized Sobel
 /// (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
 /// Scharr can be used only for the first dx or dy derivative
 /// TODO: Remove 'dst' argument and return a CVImage object
 /// </summary>
 public void Sobel(CVArr dst, int xorder, int yorder, int aperture_size)
 {
     PInvoke.cvSobel(new __CvArrPtr(this), new __CvArrPtr(dst), xorder, yorder, aperture_size);
 }
コード例 #23
0
        public unsafe CVImage(System.Drawing.Bitmap sourceImage)
        {
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
            rect.X      = 0;
            rect.Y      = 0;
            rect.Width  = sourceImage.Width;
            rect.Height = sourceImage.Height;

            System.Drawing.Imaging.BitmapData bData =
                sourceImage.LockBits(rect,
                                     System.Drawing.Imaging.ImageLockMode.ReadWrite,
                                     PixelFormat.Format24bppRgb);

            // New implementation:
            int pixelSizeInBytes = 8;
            int numberOfChannels = 3;

            this.image =
                PInvoke.cvCreateImage(
                    new __CvSize(sourceImage.Width, sourceImage.Height),
                    pixelSizeInBytes,
                    numberOfChannels);
            CVUtils.CheckLastError();

            unsafe
            {
                int   height = sourceImage.Height;
                int   width  = sourceImage.Width;
                byte *pRead  = (byte *)bData.Scan0.ToPointer();
                byte *pWrite = this.Internal.ToPointer()->imageData;

                int nReadStride  = bData.Stride - width * numberOfChannels;
                int nWriteStride = this.Internal.ToPointer()->widthStep - width * numberOfChannels;

                for (int row = 0; row < height; ++row, pRead += nReadStride, pWrite += nWriteStride)
                {
                    for (int col = 0; col < width; ++col, pRead += numberOfChannels, pWrite += numberOfChannels)
                    {
                        pWrite[0] = pRead[0]; // Blue
                        pWrite[1] = pRead[1]; // Green
                        pWrite[2] = pRead[2]; // Red
                    }
                }
            }


            #region Old Implementation
            //__IplImagePtr tempImage = PInvoke.cvCreateImageHeader(new __CvSize(sourceImage.Width, sourceImage.Height), 8, Bitmap.GetPixelFormatSize(sourceImage.PixelFormat) / 8);
            //tempImage.ToPointer()->imageData = (byte*)bData.Scan0.ToPointer();

            //__IplImagePtr[] dst = new __IplImagePtr[4];
            //for (int i = 0; i < 4; ++i)
            //{
            //    dst[i] = IntPtr.Zero;
            //}
            //for (int i = 0; i < tempImage.ToPointer()->nChannels; i++)
            //{
            //    dst[i] = PInvoke.cvCreateImage(new __CvSize(sourceImage.Width, sourceImage.Height), 8, 1);
            //}

            //PInvoke.cvSplit(
            //    tempImage,
            //    dst[0],
            //    dst[1],
            //    dst[2],
            //    dst[3]);

            //image = PInvoke.cvCreateImage(new __CvSize(sourceImage.Width, sourceImage.Height), 8, 3);
            //PInvoke.cvMerge(dst[0], dst[1], dst[2], IntPtr.Zero, image) ;

            //for (int i = 0; i < tempImage.ToPointer()->nChannels; i++)
            //{
            //    PInvoke.cvReleaseImage(ref dst[i]);
            //}
            #endregion

            created = true;
            sourceImage.UnlockBits(bData);
        }
コード例 #24
0
 public void CvtColor(CVArr dst, ColorSpace colorSpace)
 {
     PInvoke.cvCvtColor(new __CvArrPtr(this), new __CvArrPtr(dst), (int)colorSpace);
 }
コード例 #25
0
 private void Create(int width, int height, CVDepth depth, int channels)
 {
     image = PInvoke.cvCreateImage(new __CvSize(width, height), (int)depth, channels);
     CVUtils.CheckLastError();
     created = true;
 }
コード例 #26
0
 ///<summary>
 /// Warps image with affine transform
 /// TODO: Remove 'dst' argument and return a CVImage object
 ///</summary>
 public void WarpAffine(CVArr dst, CVMat map_matrix, WarpFlags flags, CVScalar fillval)
 {
     PInvoke.cvWarpAffine(new __CvArrPtr(this), new __CvArrPtr(dst), new __CvMatPtr(map_matrix), (int)flags, new __CvScalar(fillval));
 }
コード例 #27
0
 /// <summary>
 /// Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y)
 /// TODO: Remove 'sum' argument and return a CVArr object
 /// </summary>
 public void Integral(CVArr sum, CVArr sqsum, CVArr titled_sum)
 {
     PInvoke.cvIntegral(new __CvImagePtr(this), new __CvArrPtr(sum), new __CvArrPtr(sqsum), new __CvArrPtr(titled_sum));
     CVUtils.CheckLastError();
 }