/// <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(); }
/// <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)); }
/// <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); }
/// <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); }
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); }
/// <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); }
public void Release() { __CvVideoWriterPtr ptr = vw_; // CvVideoWriter* prt = vw_ PInvoke.cvReleaseVideoWriter(ref ptr); }
/// <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); }
/// <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(); }
public void WriteFrame(CVImage image) { PInvoke.cvWriteFrame(vw_, image.Internal); }
/// <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(); }
/// <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(); }
/// <summary /// Segments image using seed "markers" /// </summary> public void Watershed(CVArr markers) { PInvoke.cvWatershed(new __CvArrPtr(this), new __CvArrPtr(markers)); CVUtils.CheckLastError(); }
/// <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); }
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(); }
/// <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); }
public static void ErrorsToExceptions() { PInvoke.cvRedirectError(_errHandler); }
/// <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); }
public void ResetROI() { PInvoke.cvResetImageROI(Internal); CVUtils.CheckLastError(); }
/// <summary /// Segments image using seed "markers" /// </summary> public void Watershed(CVArr markers) { PInvoke.cvWatershed(new __CvArrPtr(this), new __CvArrPtr(markers)); }
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(); }
/// <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); }
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); }
public void CvtColor(CVArr dst, ColorSpace colorSpace) { PInvoke.cvCvtColor(new __CvArrPtr(this), new __CvArrPtr(dst), (int)colorSpace); }
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; }
///<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)); }
/// <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(); }