示例#1
0
        private void GetWebCamFrame(string cameraId)
        {
            Camera camera;

            if (!Cameras.TryGetValue(cameraId, out camera))
            {
                return;
            }
            while (_client != null && _client.IsConnected && camera.StreamActive && camera.Physical.IsRunning)
            {
                byte[] imageBytes;
                if (CameraFrames.TryGetValue(cameraId, out imageBytes))
                {
                    var cameraData = new
                    {
                        cameraId,
                        cameraData = imageBytes.Select(b => (int)b).ToArray()
                    };
                    _builder.Endpoint = "cameraframe";
                    _builder.WriteMessage(cameraData);
                }
                Thread.Sleep(150);
            }
            camera.StreamActive = false;
        }
示例#2
0
 private static void HandleFrame(object sender, NewFrameEventArgs camera, string cameraId)
 {
     if (sender == null)
     {
         throw new ArgumentNullException(nameof(sender));
     }
     if (camera?.Frame == null)
     {
         return;
     }
     byte[] bytes;
     if (!CameraFrames.TryGetValue(cameraId, out bytes))
     {
         CameraFrames[cameraId] = ImageToByte2(camera.Frame);
     }
     else
     {
         if (UseMotionDetection)
         {
             detector.ProcessFrame(camera.Frame);
         }
         CameraFrames[cameraId] = ImageToByte2(camera.Frame);
     }
 }