コード例 #1
0
ファイル: ContinuousCapture.cs プロジェクト: bzyk72/Shiretii
        /// <summary>
        /// Calls the method to compare the pictures and if differences found
        /// sends a mail to the defined address book.
        /// </summary>
        /// <param name="cam"></param>
        private void CompareTakenPictures(Camera cam)
        {
            string path = Path.Combine(picturesFolder, cam.CameraName);
            List<String> files = Directory.EnumerateFiles(path).ToList();

            if (files.Count > 2)
            {
                foreach (string file in files)
                {
                    File.Delete(file);
                }
            }
            else if (files.Count == 2)
            {
                FileInfo file0 = new FileInfo(files[0]);
                FileInfo file1 = new FileInfo(files[1]);

                if (file0.CreationTime > file1.CreationTime)
                {
                    file0 = new FileInfo(files[1]);
                    file1 = new FileInfo(files[0]);
                }

                Boolean compareResult = ImageComparer.Compare(file0.FullName, file1.FullName);

                if (!compareResult)
                {
                    new EmailCreator().SendMailForDifferentImages(file1.FullName);
                }

                File.Delete(file0.FullName);
            }
        }
コード例 #2
0
ファイル: CaptureImage.cs プロジェクト: bzyk72/Shiretii
 /// <summary>
 /// Takes the picture from the given camera
 /// </summary>
 /// <param name="camera"></param>
 /// <param name="cameras"></param>
 public void TakePicture(Camera camera, Cameras cameras)
 {
     int jpegCompressionRate = 20;
     string saveToPath = GetImageSavePath(camera);
     cameras.Get(camera.CameraName)
         .SavePicture(new PictureSize(camera.PictureWidth
                     , camera.PictureHeight)
                     , saveToPath
                     , jpegCompressionRate);
 }
コード例 #3
0
ファイル: CaptureImage.cs プロジェクト: bzyk72/Shiretii
        /// <summary>
        /// Gets the path and file name where to save the picture
        /// </summary>
        /// <param name="camera"></param>
        /// <returns></returns>
        private string GetImageSavePath(Camera camera)
        {
            DateTime currentDateTime = DateTime.Now;
            string folder = new AppSettingsQuery().GetAppSettingByKey(QueryConstants.AppSettingsKey_PicturesSavePath);
            folder = String.Format(@"{0}/{1}/", folder, camera.CameraName);

            if (!Directory.Exists(folder))
                Directory.CreateDirectory(folder);

            string fileName = String.Format("{0}[{1}-{2}-{3}][{4}-{5}-{6}].jpg"
                , camera.CameraName
                , currentDateTime.Year, currentDateTime.Month, currentDateTime.Day
                , currentDateTime.Hour, currentDateTime.Minute, currentDateTime.Second);

            string saveToPath = Path.Combine(folder, fileName);
            return saveToPath;
        }