public static extern int LPREngine_PutFrameImageBuffer(IntPtr hEngine, IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat, long timestamp, long customData);
public void OnFrameCaptured(VideoCapture videoCap, IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat, long timestamp, object customObject) { LPREngine engine = (LPREngine)customObject; engine.PutFrameImageBuffer(pBuffer, width, height, stride, pixelFormat, timestamp, 0); Bitmap bmp = DTKLPR4.CreateBitmapFromBuffer(pBuffer, width, height, stride, pixelFormat); SetFrame(bmp); }
public static extern IntPtr LPREngine_ReadFromImageBuffer(IntPtr hEngine, IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat);
public static Bitmap CreateBitmapFromBuffer(IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat) { // Create bitmap and copy pixels data PixelFormat format; if (pixelFormat == PIXFMT.BGR24) { format = PixelFormat.Format24bppRgb; } else if (pixelFormat == PIXFMT.RGB24) { format = PixelFormat.Format24bppRgb; } else if (pixelFormat == PIXFMT.GRAYSCALE) { format = PixelFormat.Format8bppIndexed; } else { return(null); } Bitmap bmp = new Bitmap(width, height, format); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat); IntPtr dst = bmpData.Scan0; IntPtr src = pBuffer; for (int i = 0; i < height; i++) { CopyMemory(dst, src, stride); dst = new IntPtr(dst.ToInt64() + bmpData.Stride); src = new IntPtr(src.ToInt64() + stride); } bmp.UnlockBits(bmpData); return(bmp); }
private void OnFrameCapturedNative(IntPtr hVideoCapture, IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat, long timestamp, IntPtr notUsed) { if (this.frameCapturedCallback != null) { this.frameCapturedCallback(this, pBuffer, width, height, stride, pixelFormat, timestamp, this.customObject); } }
/// <summary> /// Puts the video frame to processing queue, the engine must be initialized for video processing (bVideo parameters must be set to 'True' in LPR engine constructor). /// </summary> /// <param name="pBuffer">pointer to memory buffer</param> /// <param name="width">image width</param> /// <param name="height">image height</param> /// <param name="stride">the size of a single image row in bytes</param> /// <param name="pixelFormat">1 - grayscale, 2 - RGB24, 4 - YUV420</param> /// <param name="frameID">custom parameter which can be used to identify video frame</param> /// <returns></returns> public int PutFrameImageBuffer(IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat, long timestamp, long customData) { return(DTKLPR4.LPREngine_PutFrameImageBuffer(this.hEngine, pBuffer, width, height, stride, pixelFormat, timestamp, customData)); }
/// <summary> /// eads license plates from image buffer, the engine must be initialized for still image processing (bVideo parameters must be set to 'False' in LPR engine constructor). /// </summary> /// <param name="pBuffer">pointer to memory buffer</param> /// <param name="width">image width</param> /// <param name="height">image height</param> /// <param name="stride">the size of a single image row in bytes</param> /// <param name="pixelFormat">1 - grayscale, 2 - RGB24, 4 - YUV420</param> /// <returns></returns> public List <LicensePlate> ReadFromImageBuffer(IntPtr pBuffer, int width, int height, int stride, PIXFMT pixelFormat) { List <LicensePlate> res = new List <LicensePlate>(); IntPtr hResult = DTKLPR4.LPREngine_ReadFromImageBuffer(this.hEngine, pBuffer, width, height, stride, pixelFormat); int count = DTKLPR4.LPRResult_GetPlatesCount(hResult); for (int i = 0; i < count; i++) { IntPtr hPlate = DTKLPR4.LPRResult_GetPlate(hResult, i); res.Add(new LicensePlate(hPlate)); } return(res); }