public void UpdateFrameHandler(webcam.UpdateFrame updateFrame)
        {
            _state.LastFrameUpdate = updateFrame.Body.TimeStamp;

            updateFrame.ResponsePort.Post(DefaultUpdateResponseType.Instance);

            SendNotification(_subMgr, updateFrame);
        }
 void OnCameraUpdateFrame(cam.UpdateFrame updateFrame)
 {
     if (!_state.UpdateFrame)
     {
         _state.UpdateFrame = true;
         SpawnIterator(new List <ColorBin>(_state.ColorBins), ProcessImage);
     }
 }
Esempio n. 3
0
        void CameraUpdateFrameHandler(cam.UpdateFrame update)
        {
            if (_state.Processing || _state.Shutdown)
            {
                return;
            }

            _state.Processing = true;

            SpawnIterator(update, DoCameraUpdateFrameHandler);
        }
Esempio n. 4
0
 void OnWebcamUpdateFrame(webcam.UpdateFrame updateFrame)
 {
     _fwdPort.Post(new ProcessFrame(true));
 }
Esempio n. 5
0
 // Timer for simulated cameras ONLY
 void CameraTimer(DateTime signal)
 {
     //LogInfo(LogGroups.Console, "Send UpdateFrame to webcam");
     cam.UpdateFrame request = new cam.UpdateFrame();
     _webCamPort.Post(request);
     Activate(
         Arbiter.Receive(false, TimeoutPort(_state.Options.CameraInterval), CameraTimer)
     );
 }
Esempio n. 6
0
        IEnumerator <ITask> DoCameraUpdateFrameHandler(cam.UpdateFrame update)
        {
            try
            {
                cam.QueryFrameResponse frame = null;
                Fault fault = null;

                yield return(Arbiter.Choice(
                                 _webCamPort.QueryFrame(new cam.QueryFrameRequest()),
                                 delegate(cam.QueryFrameResponse success)
                {
                    frame = success;
                },
                                 delegate(Fault f)
                {
                    fault = f;
                }
                                 ));

                if (fault != null)
                {
                    LogError(null, "Failed to get frame from camera", fault);
                    yield break;
                }

                Bitmap bmp = new Bitmap(
                    frame.Size.Width,
                    frame.Size.Height,
                    PixelFormat.Format24bppRgb
                    );

                BitmapData data = bmp.LockBits(
                    new Rectangle(0, 0, bmp.Width, bmp.Height),
                    ImageLockMode.WriteOnly,
                    PixelFormat.Format24bppRgb
                    );

                Marshal.Copy(frame.Frame, 0, data.Scan0, frame.Frame.Length);

                bmp.UnlockBits(data);

                FormInvoke setImage = new FormInvoke(
                    delegate()
                {
                    if (!_form.IsDisposed)
                    {
                        _form.CameraImage = bmp;
                    }
                }
                    );

                WinFormsServicePort.Post(setImage);

                Arbiter.Choice(
                    setImage.ResultPort,
                    delegate(EmptyValue success) { },
                    delegate(Exception e)
                {
                    fault = Fault.FromException(e);
                }
                    );

                if (fault != null)
                {
                    LogError(null, "Unable to set camera image on form", fault);
                    yield break;
                }
            }
            finally
            {
                _mainPort.Post(new UpdateProcessing(false));
            }
        }