// Example of an image event handler. void OnImageGrabbed(Object sender, ImageGrabbedEventArgs e) { LOG("OnImageGrabbed started"); IGrabResult grabResult = e.GrabResult; if (grabResult.GrabSucceeded) // Image grabbed successfully? { LOG(string.Format("GrabbedImage XY={0}|{1} ", grabResult.Width, grabResult.Height)); lock (storedGrabResult_locker) { lock (initialize_locker) { if (initialized == false) { grabResultBufferRGB_size = converter.GetBufferSizeForConversion(sourcePixelType, grabResult.Width, grabResult.Height); initialized = true; LOG("destinationBufferSize initialized!"); } } storedGrabResult = grabResult.Clone(); lock (storedNewGrabResult_locker) { storedNewGrabResult = true; } lock (frameCountCameraGrabbed_locker) { frameCountCameraGrabbed++; } //LOG("Started to convert grabbed result!"); //byte[] rgb = ConvertGrabResultToByteArray(grabResult); //LOG("Grabbed result converted to byte array!"); } } else { LOG_err(string.Format("Unsuccessfull grab - Error: {0} {1}", grabResult.ErrorCode, grabResult.ErrorDescription)); } }