コード例 #1
0
        public byte[] GetPicture(string devicePath, PictureSize pictureSize, Percent jpegCompressionRate)
        {
            var cacheKey = new PicturesCacheKey
            {
                DevicePath  = devicePath,
                PictureSize = pictureSize
            };

            if (!cacheValues.ContainsKey(cacheKey))
            {
                return(new byte[0]);
            }

            Console.WriteLine("GetPicture from cache");

            return(cacheValues[cacheKey].Data);
        }
コード例 #2
0
        public bool HasPicture(string devicePath, PictureSize pictureSize, Percent jpegCompressionRate)
        {
            var cacheKey = new PicturesCacheKey
            {
                DevicePath = devicePath, PictureSize = pictureSize
            };

            if (!cacheValues.ContainsKey(cacheKey))
            {
                Console.WriteLine("ContainsKey {0}", false);
                return(false);
            }

            var value = cacheValues[cacheKey];

            return(!IsExpired(value));
        }
コード例 #3
0
ファイル: CamDriver.cs プロジェクト: cyberjacob/raspberrycam
        public byte[] GetVideoFrame(Percent compressionRate = default(Percent))
        {
            if (!IsVideoStreamOpenned)
            {
                return(new byte[0]);
            }

            if (!CanReadVideoFrame)
            {
                Thread.Sleep(RemainingWaitingMilliseconds);
            }

            var pictureBuffer = RaspberryCamInterop.ReadVideoFrame(videoStreamHandle, (uint)(100 - compressionRate.Value));

            var data = new byte[pictureBuffer.Size];

            Marshal.Copy(pictureBuffer.Data, data, 0, pictureBuffer.Size);

            return(data);
        }
コード例 #4
0
        public void AddPicture(string devicePath, PictureSize pictureSize, Percent jpegCompressionRate, byte[] data)
        {
            var cacheKey = new PicturesCacheKey
            {
                DevicePath  = devicePath,
                PictureSize = pictureSize
            };
            var cacheValue = new PicturesCacheValue
            {
                Time = DateTime.UtcNow,
                Data = data
            };

            if (!cacheValues.ContainsKey(cacheKey))
            {
                cacheValues.Add(cacheKey, cacheValue);
                return;
            }

            cacheValues[cacheKey] = cacheValue;
        }
コード例 #5
0
ファイル: CamDriver.cs プロジェクト: cyberjacob/raspberrycam
        public void SavePicture(PictureSize pictureSize, string filename, Percent jpegCompressionRate = default(Percent))
        {
            var data = TakePicture(pictureSize, jpegCompressionRate);

            File.WriteAllBytes(filename, data);
        }
コード例 #6
0
ファイル: Percent.cs プロジェクト: cyberjacob/raspberrycam
 public bool Equals(Percent other)
 {
     return(value == other.value);
 }