CvArr img = Cv.LoadImage("image.jpg", LoadMode.Color);
CvArr grayImg = Cv.CreateImage(new CvSize(img.Width, img.Height), BitDepth.U8, 1); Cv.CvtColor(img, grayImg, ColorConversion.BgrToGray);
byte[,] data = new byte[grayImg.Height, grayImg.Width]; unsafe { byte* ptr = (byte*)grayImg.ImageData; for (int y = 0; y < grayImg.Height; y++) { for (int x = 0; x < grayImg.Width; x++) { data[y, x] = *(ptr + y * grayImg.WidthStep + x); *(ptr + y * grayImg.WidthStep + x) = 255; } } }These examples illustrate the basic functionality of the CvArr data structure in OpenCvSharp. The package library for this library is OpenCvSharp4.