// See dummy reference for documentation public (BitmapSource, int) Run() { // Check is Video Capture hasn't been previously disposed, and start it if it has //IPCore.IsVideoCaptureDisposed(); // Try reading frame from capture device //(Mat frame, bool isFrameValid) = IPCore.TryReadVideoCaptureFrame(); // ELI // ENGINE WRAPPER //(Mat frame, bool isFrameValid) = IPCore.GetHamamatsuFrame(); // ELI // DCAM WRAPPER (Mat frame, bool isFrameValid) = IPCore.DummyHamamatsuInterop(); if (isFrameValid == true) { Cv2.WaitKey(1); //Set image processing parameters IPCore.SetImageProcessingParameters(); // Call processing algorthm - C# 7 tuple syntax return (Mat processedImage, int pixelDistance) = ProcessImage(ref frame); // Conversions & return return(OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(processedImage), pixelDistance); } else { return(null, 0); } }
// ELI public (BitmapSource, System.Drawing.Point) Run(System.Drawing.Point actuatorPositionPixels) { // Check is Video Capture hasn't been previously disposed, and start it if it has //IPCore.IsVideoCaptureDisposed(); // Try reading frame from capture device //(Mat frame, bool isFrameValid) = IPCore.TryReadVideoCaptureFrame(); // ELI // ENGINE WRAPPER //(Mat frame, bool isFrameValid) = IPCore.GetHamamatsuFrame(); // ELI // DCAM WRAPPER (Mat frame, bool isFrameValid) = IPCore.DummyHamamatsuInterop(); // Mirror vertically and/or horizontally frame = IPCore.CheckImageMirroring(ref frame, IPCore.VideoFeedSettings.IsMirroredX, IPCore.VideoFeedSettings.IsMirroredY); if (isFrameValid == true) { Cv2.WaitKey(1); //Set image processing parameters IPCore.SetImageProcessingParameters(); // TO DO - try catch! // Return frame is no algorithm is selected if (IPCore.TASettings.ImgProcAlgorithm == Enums.ImgProcAlgorithm.None) { return(OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(frame), new System.Drawing.Point(int.MinValue, int.MinValue)); } // Call processing algorthm - C# 7 tuple syntax return (Mat processedImage, OpenCvSharp.Point centerPointCV) = ProcessImage(ref frame, ref actuatorPositionPixels); // Conversions & return return(OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(processedImage), new System.Drawing.Point() { X = centerPointCV.X, Y = centerPointCV.Y }); } else { return(null, new System.Drawing.Point()); } }