public override void Start() { if (moduleInfo.Args().Length == 0 || moduleInfo.Args()[0].Equals("")) { ListAvailableCameras(); return; } cameraStr = moduleInfo.Args()[0]; _frameSource = FindConnectedCamera(cameraStr); if (_frameSource != null) { InitCamera(_frameSource); } else { logger.Log("Camera matching {0} not found", cameraStr); ListAvailableCameras(); logger.Log("Will keep looking"); } cameraSearchTimer = new Timer(PeriodicCameraSearch, null, (int)SearchPeriod.TotalMilliseconds, (int)SearchPeriod.TotalMilliseconds); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); }
public void HookEvents() { enabled = false; cfs = null; foreach (Camera cam in CameraService.AvailableCameras) { if (cam.Name == webcamName) { Console.Write(""); cfs = new CameraFrameSource(cam); break; } } if (cfs != null) { /* cfs.Camera.CaptureWidth = 1920; * cfs.Camera.CaptureHeight = 1080; * cfs.Camera.Fps = 30;*/ cfs.NewFrame += Cfs_NewFrame; try { cfs.StartFrameCapture(); stopWatch.Start(); captureStarted = true; } catch (Exception exc) { } } }
private void PeriodicCameraSearch(object state) { try { //search only if we haven't received a frame in a while if (DateTime.Now - _latestFrameTime > SearchPeriod) { if (cameraPort != null) { ForgetCamera(); } _frameSource = FindConnectedCamera(cameraStr); if (_frameSource != null) { InitCamera(_frameSource); } } } catch (Exception e) { logger.Log("Exception during camera search: " + e.ToString()); } }
public CameraViewer(string camera) { InitializeComponent(); foreach (Camera item in CameraService.AvailableCameras) { if (item.Name == camera) { _Camera = item; } } try { _frameSource = new CameraFrameSource(_Camera); _frameSource.Camera.CaptureWidth = 640; _frameSource.Camera.CaptureHeight = 480; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCapturedCamera1; _frameSource.StartFrameCapture(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void setFrameSource(CameraFrameSource cameraFrameSource) { if (_frameSource == cameraFrameSource) { return; } _frameSource = cameraFrameSource; }
private void setFrameSource(CameraFrameSource frame) { if (_frameSource == frame) { return; } _frameSource = frame; }
private void ForgetCamera() { DeregisterPortWithPlatform(cameraPort); cameraPort = null; if (_frameSource != null && _frameSource.Camera != null) { _frameSource.Camera.Dispose(); } _frameSource = null; }
public CameraFrameSourceConfigurationElement(CameraFrameSource cameraFrameSource) { _cameraFrameSource = cameraFrameSource; InitializeComponent(); if (!DesignerProperties.GetIsInDesignMode(this) && _cameraFrameSource != null) { _cameraFrameSource.NewFrame += NewFrame; var cameras = CameraService.AvailableCameras.ToList(); comboBoxCameras.ItemsSource = cameras; comboBoxCameras.SelectedItem = _cameraFrameSource.Camera; } }
public void CameraHelper(Camera camera, int width, int height, int fps) { try { _frameSource = new CameraFrameSource(camera) { Camera = { CaptureWidth = width, CaptureHeight = height, Fps = fps } }; _frameSource.NewFrame += OnImageCaptured; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <List <Bitmap> > GetNBitMaps(int n) { this._frameSource = new CameraFrameSource(this.Camera); _frameSource.Camera.CaptureWidth = 640; _frameSource.Camera.CaptureHeight = 480; _frameSource.Camera.Fps = 50; this._frameSource.NewFrame += _frameSource_NewFrame; this._frameSource.StartFrameCapture(); while (n > BitMaps.Count) { System.Threading.Thread.Sleep(100); } this._frameSource.NewFrame -= _frameSource_NewFrame; Camera.Dispose(); return(BitMaps); }
private void InitCamera() { // Configuramos la camara foreach (Camera cam in CameraService.AvailableCameras) { comboBoxCameras.Items.Add(cam); } comboBoxCameras.SelectedIndex = 0; comboBoxCameras.Select(); Camera c = (Camera)comboBoxCameras.SelectedItem; _frameSource = new CameraFrameSource(c); _frameSource.Camera.CaptureWidth = 320; _frameSource.Camera.CaptureHeight = 240; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; pictureBox1.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); }
private void InitCamera(CameraFrameSource frameSource) { logger.Log("Init-ing camera {0}", _frameSource.Camera.ToString()); //add the camera service port if we haven't done that already if (cameraPort == null) { VPortInfo pInfo = GetPortInfoFromPlatform("webcam - " + cameraStr); List <VRole> roles = new List <VRole>() { RoleCamera.Instance }; cameraPort = InitPort(pInfo); BindRoles(cameraPort, roles, OnOperationInvoke); RegisterPortWithPlatform(cameraPort); } SafeThread worker = new SafeThread(delegate() { GetVideo(); }, "DriverWebCam-GetVideo", logger); worker.Start(); }