public CameraTracking(int subtractionHistory, int subtractionThreshold, int frameBlurStrength, int largestDetectionHeightSizeDivisor, int largestDetectionWidthSizeDivisor, int smallestDetectionHeightSizeDivisor, int smallestDetectionWidthSizeDivisor) { FrameBlurStrength = frameBlurStrength; LargestDetectionHeightSizeDivisor = largestDetectionHeightSizeDivisor; LargestDetectionWidthSizeDivisor = largestDetectionWidthSizeDivisor; SmallestDetectionHeightSizeDivisor = smallestDetectionHeightSizeDivisor; SmallestDetectionWidthSizeDivisor = smallestDetectionWidthSizeDivisor; try { _cameraCapture = new VideoCapture(); // I had to set this by hand to match our camera as opencv doesn't always pull these properties correctly and sometimes shows funky frames or nothing at all // _cameraCapture.SetCaptureProperty(CapProp.FrameWidth, 1600); // _cameraCapture.SetCaptureProperty(CapProp.FrameHeight, 1200); // _cameraCapture.SetCaptureProperty(CapProp.FourCC, Emgu.CV.VideoWriter.Fourcc('Y', 'U', 'Y', '2')); _fgDetector = new Emgu.CV.VideoSurveillance.BackgroundSubtractorMOG2(subtractionHistory, subtractionThreshold); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); Ready = true; } catch (Exception e) { Ready = false; } }
void Run() { try { _cameraCapture = new VideoCapture(1); _fgDetector = new Emgu.CV.VideoSurveillance.BackgroundSubtractorMOG2(); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); Application.Idle += ProcessFrame; } catch (Exception e) { } }
void Run() { try { _cameraCapture = new VideoCapture(); } catch (Exception e) { MessageBox.Show(e.Message); return; } _fgDetector = new BackgroundSubtractorMOG2(); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); Application.Idle += ProcessFrame; }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Please pass in camera name and address"); return; } var codeFiles = @"C:\Users\jakka\Documents\code.txt"; _code = File.ReadAllText(codeFiles); AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _fgDetector = new BackgroundSubtractorMOG2(); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); _name = args[0]; var address = args[1]; var fn = Path.Combine(Path.GetTempPath(), "survel"); if (!Directory.Exists(fn)) { Directory.CreateDirectory(fn); } else { //foreach (var f in Directory.GetFiles(fn)) //{ // File.Delete(f); //} } Task.Run(async() => { await _processor(address, fn); }); _watcher(_name, fn).GetAwaiter().GetResult(); }
public CameraTracking(int subtractionHistory, int subtractionThreshold, int frameBlurStrength, int largestDetectionHeightSizeDivisor, int largestDetectionWidthSizeDivisor, int smallestDetectionHeightSizeDivisor, int smallestDetectionWidthSizeDivisor) { Debug.WriteLine("CameraTracking:: Initializing"); if (largestDetectionHeightSizeDivisor > smallestDetectionHeightSizeDivisor || largestDetectionWidthSizeDivisor > smallestDetectionWidthSizeDivisor) { throw new Exception("The large detection divisors should be smaller then the smallest detection divisors!"); } this.frameBlurStrength = frameBlurStrength; this.largestDetectionHeightSizeDivisor = largestDetectionHeightSizeDivisor; this.largestDetectionWidthSizeDivisor = largestDetectionWidthSizeDivisor; this.smallestDetectionHeightSizeDivisor = smallestDetectionHeightSizeDivisor; this.smallestDetectionWidthSizeDivisor = smallestDetectionWidthSizeDivisor; try { CameraTracking._cameraCapture = new VideoCapture(); // I had to set this by hand to match our camera as opencv doesn't always pull these properties correctly // and sometimes shows funky frames or nothing at all // CameraTracking._cameraCapture.SetCaptureProperty(CapProp.FrameWidth, 1600); // CameraTracking._cameraCapture.SetCaptureProperty(CapProp.FrameHeight, 1200); // CameraTracking._cameraCapture.SetCaptureProperty(CapProp.FourCC, Emgu.CV.VideoWriter.Fourcc('Y', 'U', 'Y', '2')); CameraTracking._fgDetector = new Emgu.CV.BackgroundSubtractorMOG2(subtractionHistory, subtractionThreshold); CameraTracking._blobDetector = new CvBlobDetector(); CameraTracking._tracker = new CvTracks(); this.Ready = true; Debug.WriteLine("CameraTracking:: Camera Initialized"); } catch (Exception e) { throw new Exception("Unable to initialize the webcam!"); } }
static void Main(string[] args) { _cameraCapture = new VideoCapture(1); _fgDetector = new Emgu.CV.VideoSurveillance.BackgroundSubtractorMOG2(); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); Task.Run(() => { DetectFaces(); }) .ContinueWith((p) => { if (p != null && p.IsFaulted) { Console.WriteLine(p.Exception.InnerException.Message); } }); Task.Run(() => { IdentifyFaces(); }) .ContinueWith((p) => { if (p != null && p.IsFaulted) { Console.WriteLine(p.Exception.InnerException.Message); } }); Console.ReadKey(); }
void Run() { try { _cameraCapture = new VideoCapture(); } catch (Exception e) { MessageBox.Show(e.Message); return; } _fgDetector = new Emgu.CV.VideoSurveillance.BackgroundSubtractorMOG2(); _blobDetector = new CvBlobDetector(); _tracker = new CvTracks(); Application.Idle += ProcessFrame; }