private static BasicVideoFrame InternalCreateFrame(int width, int height, Bitmap cameraFrame, int fameNumber, bool variant, FrameProcessingStatus status) { var rv = new BasicVideoFrame(); rv.pixels = ImageUtils.GetPixelArray(width, height, cameraFrame); rv.previewBitmap = cameraFrame; rv.pixelsVariant = null; // TODO: Set these from the unmanaged OCR data, when native OCR is running rv.frameNumber = fameNumber; if (status.Equals(FrameProcessingStatus.Empty)) { rv.exposureStartTime = null; rv.exposureDuration = null; rv.imageInfo = null; } else { if (status.StartExposureSystemTime > 0) { try { rv.exposureStartTime = new DateTime(status.StartExposureSystemTime).ToString("yyyy/MM/dd HH:mm:ss ffff - ") + new DateTime(status.EndExposureSystemTime).ToString("yyyy/MM/dd HH:mm:ss ffff | ") + status.StartExposureFrameNo.ToString("0 - ") + status.EndExposureFrameNo.ToString("0"); } catch { } try { rv.exposureDuration = new TimeSpan(status.EndExposureSystemTime - status.StartExposureSystemTime).TotalMilliseconds; } catch { } } else { rv.exposureStartTime = null; rv.exposureDuration = null; } rv.imageInfo = string.Format("INT:{0};SFID:{1};EFID:{2};CTOF:{3};UFID:{4};IFID:{5};DRPD:{6}", status.DetectedIntegrationRate, status.StartExposureFrameNo, status.EndExposureFrameNo, status.CurrentSignatureRatio, status.CameraFrameNo, status.IntegratedFrameNo, status.DropedFramesSinceIntegrationLock); rv.MaxSignalValue = (uint)(status.DetectedIntegrationRate * 255); if (status.PerformedAction > 0) { rv.imageInfo += string.Format(";ACT:{0};ACT%:{1}", status.PerformedAction, status.PerformedActionProgress); } if (status.OcrWorking > 0) { rv.imageInfo += string.Format(";ORER:{0}", status.OcrErrorsSinceLastReset); } if (status.UserIntegratonRateHint > 0) { rv.imageInfo += string.Format(";USRI:{0}", status.UserIntegratonRateHint); } if (TrackingContext.Current.IsTracking) { TrackingContext.Current.UpdateFromFrameStatus(fameNumber, status); } } return rv; }
internal static BasicVideoFrame FakeFrame(int width, int height) { var rv = new BasicVideoFrame(); s_Counter++; rv.frameNumber = s_Counter; rv.pixels = new int[0, 0]; return rv; }