//private void imageProvider_GrabbingStartedEvent() //{ // grabbing = true; // if (GrabbingStatusChanged != null) // GrabbingStatusChanged(this, EventArgs.Empty); //} private void BaumerProvider_BufferProduced(object sender, BufferEventArgs e) { BGAPI2.Buffer buffer = e.Buffer; if (buffer == null || buffer.IsIncomplete || buffer.MemPtr == IntPtr.Zero) { return; } int payloadLength = (int)buffer.SizeFilled; // Wrap the buffer in an image, convert if needed. BGAPI2.Image image = imgProcessor.CreateImage((uint)buffer.Width, (uint)buffer.Height, buffer.PixelFormat, buffer.MemPtr, buffer.MemSize); bool ready = imageFormat == ImageFormat.JPEG || (imageFormat == ImageFormat.Y800 && BaumerHelper.IsY800(image.PixelFormat)); if (!ready) { // Color conversion is required. BGAPI2.Image transformedImage = GetTransformedImage(image); image.Release(); image = transformedImage; int bpp = BaumerHelper.IsY800(image.PixelFormat) ? 1 : 3; payloadLength = (int)(image.Width * image.Height * bpp); } CopyFrame(image, payloadLength); image.Release(); if (imageFormat != ImageFormat.JPEG && finishline.Enabled) { bool flush = finishline.Consolidate(frameBuffer); if (flush) { ComputeDataRate(finishline.BufferOutput.Length); if (FrameProduced != null) { FrameProduced(this, new FrameProducedEventArgs(finishline.BufferOutput, finishline.BufferOutput.Length)); } } } else { ComputeDataRate(payloadLength); if (FrameProduced != null) { FrameProduced(this, new FrameProducedEventArgs(frameBuffer, payloadLength)); } } }
private void BaumerProducer_BufferProduced(object sender, BufferEventArgs e) { BGAPI2.Buffer buffer = e.Buffer; if (buffer == null) { hadError = true; waitHandle.Set(); return; } image = new Bitmap((int)buffer.Width, (int)buffer.Height, PixelFormat.Format24bppRgb); bool filled = FillRGB24(e.Buffer, image); if (filled) { int bufferSize = ImageFormatHelper.ComputeBufferSize(image.Width, image.Height, Kinovea.Services.ImageFormat.RGB24); bool topDown = true; imageDescriptor = new ImageDescriptor(Kinovea.Services.ImageFormat.RGB24, image.Width, image.Height, topDown, bufferSize); } waitHandle.Set(); }