Beispiel #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;
        }
Beispiel #2
0
 public void Merge(VocaloidMotionData data)
 {
     if (data.MotionFrames != null)
     {
         MotionFrames.AddRange(data.MotionFrames);
     }
     if (data.MorphFrames != null)
     {
         MorphFrames.AddRange(data.MorphFrames);
     }
     if (data.CameraFrames != null)
     {
         CameraFrames.AddRange(data.CameraFrames);
     }
     if (data.LightFrames != null)
     {
         LightFrames.AddRange(data.LightFrames);
     }
     if (data.ShadowFrames != null)
     {
         ShadowFrames.AddRange(data.ShadowFrames);
     }
     if (data.PropertyFrames != null)
     {
         PropertyFrames.AddRange(data.PropertyFrames);
     }
 }
Beispiel #3
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);
     }
 }
Beispiel #4
0
        /// <summary>
        /// VMDを読み込む
        /// </summary>
        /// <returns>EndOfStreamExceptionが発生した場合 true を返す</returns>
        public bool Read(BinaryReader reader)
        {
            try
            {
                byte[] bChar = reader.ReadBytes(HEADER_LENGTH);
                header = new string(Encoding.GetChars(bChar));
                int eosPos = header.IndexOf('\0');
                if (eosPos >= 0)
                {
                    header = header.Remove(eosPos);
                }

                bChar     = reader.ReadBytes(MODEL_NAME_LENGTH);
                ModelName = new string(Encoding.GetChars(bChar));
                eosPos    = ModelName.IndexOf('\0');
                if (eosPos >= 0)
                {
                    ModelName = ModelName.Remove(eosPos);
                }

                uint len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    MotionFrames.Add(new VmdMotionFrameData(reader));
                }

                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    MorphFrames.Add(new VmdMorphFrameData(reader));
                }

                //camera
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    CameraFrames.Add(new VmdCameraFrameData(reader));
                }

                //light
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    LightFrames.Add(new VmdLightFrameData(reader));
                }

                //self shadow
                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    ShadowFrames.Add(new VmdShadowFrameData(reader));
                }

                len = reader.ReadUInt32();
                for (int i = 0; i < len; i++)
                {
                    PropertyFrames.Add(new VmdPropertyFrameData(reader));
                }
                return(false);
            }
            catch (EndOfStreamException)
            {
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }