Example #1
0
        public void OnImageCaptured(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource,
                                    HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
        {
            List <VParamType> ret = new List <VParamType>();

            lock (this)
            {
                _latestFrame     = frame.Image;
                _latestFrameTime = DateTime.Now;

                var newImageBytes = ImageToByteArray(frame.Image);

                //make a copy, so we do not pass on this new object to the remote guys (which leads to higher memory consumption)

                if (_latestImageBytes.Length < newImageBytes.Length)
                {
                    _latestImageBytes = newImageBytes;
                }
                else
                {
                    Buffer.BlockCopy(newImageBytes, 0, _latestImageBytes, 0, newImageBytes.Length);
                }
            }

            ret.Add(new ParamType(ParamType.SimpleType.jpegimage, _latestImageBytes));


            cameraPort.Notify(RoleCamera.RoleName, RoleCamera.OpGetVideo, ret);
        }
        private void NewFrame(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource, HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
        {
            //We want to ignore frames we can't render fast enough
            lock (_frameSync)
            {
                if (!_frameWaiting)
                {
                    _frameWaiting = true;
                    Action workAction = delegate
                    {
                        this.labelCameraFPSValue.Content = fps.ToString();
                        this.imgPreview.Source           = frame.OriginalImage.ToBitmapSource();

                        lock (_frameSync)
                        {
                            _frameWaiting = false;
                        }
                    };
                    Dispatcher.BeginInvoke(workAction);
                }
            }
        }
Example #3
0
 public void OnImageCaptured(HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.IFrameSource frameSource, HomeOS.Hub.Common.WebCam.WebCamWrapper.Contracts.Frame frame, double fps)
 {
     _latestFrame = frame.Image;
     pictureBoxDisplay.Invalidate();
 }