private void FireUploadEvent(ImageDetail incomingImg)
        {
            IList<ImageDetail> imgs = this.cameraImagesQueue[incomingImg.FromCamera];

            if (imgs.Count == 0)
            {
                imgs.Add(incomingImg);
                return;
            }

            int idxOfLastImg = imgs.Count - 1;

            bool sameBatch = incomingImg.CaptureTime == imgs[idxOfLastImg].CaptureTime;

            //已经是新的一组图片
            if (!(sameBatch))
            {
                ImageDetail[] imgsToFire = imgs.ToArray();
                imgs.Clear();
                imgs.Add(incomingImg);
                FireEvent(imgsToFire);
            }
            else
            {
                imgs.Add(incomingImg);
                //一组图片已经收集齐全
                if (imgs.Count == Properties.Settings.Default.LengthOfImageGroup)
                {
                    ImageDetail[] imgsToFire = imgs.ToArray();
                    imgs.Clear();
                    FireEvent(imgsToFire);
                }
            }
        }
        private void FireEvent(ImageDetail[] imgs)
        {
            if (imgs.Length <= 0)
                return;

            if (this.ImagesUploaded != null)
            {
                ImageUploadEventArgs args =
                    new ImageUploadEventArgs { CameraID = imgs[0].FromCamera, Images = imgs };
                this.ImagesUploaded(this, args);
            }
        }
        public void ClassifyImagesTest()
        {
            string[] files = System.IO.Directory.GetFiles(@"d:\20090505");
            ImageDetail[] images = new ImageDetail[10];
            for (int i = 0; i < images.Length; i++)
            {
                ImageDetail d = ImageDetail.FromPath(files[i]);
                images[i] = d;
            }

            ImageClassifier.ClassifyImages(images);
        }
        private static string BuildFolderPath(ImageDetail img)
        {
            string nameWithoutExtension = Path.GetFileNameWithoutExtension(img.Name);
            int idx = nameWithoutExtension.LastIndexOf('-');
            nameWithoutExtension = nameWithoutExtension.Remove(idx);

            string bigPicName = nameWithoutExtension + Path.GetExtension(img.Name);
            string bigPicFolder = Directory.GetParent(img.ContainedBy).ToString();
            bigPicFolder = Path.Combine(bigPicFolder, Properties.Settings.Default.BigImageDirectoryName);
            string bigPicPathName = Path.Combine(bigPicFolder, bigPicName);
            return bigPicPathName;
        }
 public static void ClassifyImages(ImageDetail[] images)
 {
     string outputPathRoot = Properties.Settings.Default.OutputPath;
     foreach (ImageDetail image in images)
     {
         string destDirectory = BuildDestDirectory(outputPathRoot, Properties.Settings.Default.BigImageDirectoryName, image);
         if (!Directory.Exists(destDirectory))
         {
             Directory.CreateDirectory(destDirectory);
         }
         image.MoveTo(destDirectory);
     }
 }
 public static string[] FindVideos(ImageDetail img)
 {
     string videoFilePath = VideoFilePathNameAt(img.CaptureTime, img.FromCamera);
     if (File.Exists(videoFilePath))
     {
         string[] videos = new string[] { videoFilePath };
         return videos;
     }
     else
     {
         return new string[0];
     }
 }
        public static string BigImgPathForFace(ImageDetail face)
        {
            string nameWithoutExtension = Path.GetFileNameWithoutExtension(face.Name);
            int idx = nameWithoutExtension.LastIndexOf('-');
            nameWithoutExtension = nameWithoutExtension.Remove(idx);

            string bigPicName = nameWithoutExtension + Path.GetExtension(face.Name);
            string bigPicFolder = Directory.GetParent(face.ContainedBy).ToString();

            bigPicFolder = bigPicFolder.Replace(Properties.Settings.Default.IconDirectoryName, "");

            bigPicFolder = Path.Combine(bigPicFolder, Properties.Settings.Default.BigImageDirectoryName);
            bigPicFolder = Path.Combine(bigPicFolder, ToStringYearToMinute(face.CaptureTime));
            string bigPicPathName = Path.Combine(bigPicFolder, bigPicName);
            return bigPicPathName;
        }
        public static void PlayRelatedVideo(DateTime captureTime, int cameraId)
        {
            var imgInfo = new ImageDetail();
            imgInfo.CaptureTime = captureTime;
            imgInfo.FromCamera = cameraId;

            using (var session = new Session())
            {
                var c = DevExpress.Data.Filtering.CriteriaOperator.Parse("CaptureTime = ?",
                                                                         captureTime.Date.AddHours(captureTime.Hour).
                                                                             AddMinutes(captureTime.Minute));
                var v = (Damany.PortraitCapturer.DAL.DTO.Video)session.FindObject(typeof(Damany.PortraitCapturer.DAL.DTO.Video), c);

                if (v == null || !File.Exists(v.Path))
                {
                    MessageBox.Show("没有找到相关视频", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                PlayVideosAsync(new string[] { v.Path });
            }
        }
        private static string BuildDestDirectory(string outputPathRoot,
            string subFoldername,
            ImageDetail image)
        {
            StringBuilder sb = new StringBuilder();
            DateTime dt = image.CaptureTime;
            sb.Append(image.FromCamera.ToString("D2"));
            sb.Append(Path.AltDirectorySeparatorChar);
            sb.Append(dt.Year.ToString("D4"));
            sb.Append(Path.AltDirectorySeparatorChar);
            sb.Append(dt.Month.ToString("D2"));
            sb.Append(Path.AltDirectorySeparatorChar);
            sb.Append(dt.Day.ToString("D2"));
            sb.Append(Path.AltDirectorySeparatorChar);
            if (!string.IsNullOrEmpty(subFoldername))
            {
                sb.Append(subFoldername);
                sb.Append(Path.AltDirectorySeparatorChar);
            }

            string destPath = Path.Combine(outputPathRoot, sb.ToString());
            return destPath;
        }
Exemple #10
0
        unsafe ImageDetail[] SaveImage(Target[] targets)
        {
            IList<ImageDetail> imgs = new List<ImageDetail>();

            foreach (Target t in targets)
            {
                Frame frame = t.BaseFrame;

                DateTime dt = DateTime.FromBinary(frame.timeStamp);

                for (int j = 0; j < t.FaceCount; ++j)
                {
                    IntPtr* f = ((IntPtr*)(t.FaceData)) + j;
                    IplImage aFace = new IplImage(*f);
                    aFace.IsEnabledDispose = false;

                    string facePath = GetFacePath(frame, dt, j);

                    aFace.SaveImage(facePath);

                    imgs.Add(ImageDetail.FromPath(facePath));

                }

            }

            ImageDetail[] details = new ImageDetail[imgs.Count];
            imgs.CopyTo(details, 0);

            return details;
        }
Exemple #11
0
        private void ShowLiveFace(ImageDetail[] images)
        {
            if (images.Length == 0) return;

            this.bigImage.Picture = (Bitmap)Damany.Util.Extensions.MiscHelper.FromFileBuffered(images.Last().Path);
        }
Exemple #12
0
        public void ShowImages(ImageDetail[] images)
        {
            ImageCell[] cells = new ImageCell[images.Length];
            for (int i = 0; i < cells.Length; i++)
            {
                Image img = Image.FromFile(images[i].Path);
                string text = images[i].CaptureTime.ToString();
                ImageCell newCell = new ImageCell() { Image = img, Path = images[i].Path, Text = text, Tag = null };
                cells[i] = newCell;
            }

            this.squareListView1.ShowImages(cells);
        }
Exemple #13
0
 public void ShowImages(ImageDetail[] images)
 {
 }
Exemple #14
0
        private ImageDetail[] BuildIconImages(string destFolder, ImageDetail[] bigImgs, string iconFilesString)
        {
            string[] iconFiles = iconFilesString.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

            IDictionary<int, IList<string>> iconGroup = new Dictionary<int, IList<string>>();

            //分组
            for (int i = 0; i < iconFiles.Length; i += 2)
            {
                int idxOfBigPic = int.Parse(iconFiles[i + 1]);
                if (!iconGroup.ContainsKey(idxOfBigPic))
                {
                    iconGroup.Add(idxOfBigPic, new List<string>());
                }

                iconGroup[idxOfBigPic].Add(iconFiles[i]);
            }

            IList<ImageDetail> returnImgs = new List<ImageDetail>();
            foreach (var iconSubGroup in iconGroup)
            {
                for (int i = 0; i < iconSubGroup.Value.Count; i++)
                {
                    int idx = iconSubGroup.Key;
                    string bigPicPath = bigImgs[idx].Path;
                    string bigpicExtension = Path.GetExtension(bigPicPath);
                    string bigPicNameWithoutExtention = Path.GetFileNameWithoutExtension(bigPicPath);
                    string iconFileName = string.Format("{0}-{1:d4}{2}", bigPicNameWithoutExtention, i, bigpicExtension);
                    string iconFilePath = Path.Combine(destFolder, iconFileName);

                    //rename file
                    string origIconFilePath = Path.Combine(destFolder, iconSubGroup.Value[i]);
                    File.Move(origIconFilePath, iconFilePath);
                    returnImgs.Add(ImageDetail.FromPath(iconFilePath));
                }
            }

            ImageDetail[] returnImgsArray = new ImageDetail[returnImgs.Count];
            returnImgs.CopyTo(returnImgsArray, 0);

            return returnImgsArray;
        }
Exemple #15
0
        private ImageDetail[] ExtractIcons(ImageDetail[] imgs)
        {
            string destFolder = PrepareDestFolder(imgs[0]);
            extractor.SetOutputDir(destFolder);
            Array.ForEach<ImageDetail>(imgs, img => extractor.AddInImage(img.Path));

            string iconFilesString = extractor.SelectBestImage();

            ImageDetail[] iconImgs = BuildIconImages(destFolder, imgs, iconFilesString);

            System.Diagnostics.Debug.WriteLine("icon imgs:");
            Array.ForEach(iconImgs, img => System.Diagnostics.Debug.WriteLine(img.Path));

            return iconImgs;
        }
Exemple #16
0
        public void ShowImages(ImageDetail[] images)
        {
            ImageCell[] cells = new ImageCell[images.Length];
            for (int i = 0; i < cells.Length; i++)
            {
                Image img = Damany.Util.Extensions.MiscHelper.FromFileBuffered(images[i].Path);
                string text = images[i].CaptureTime.ToString();
                ImageCell newCell = new ImageCell() { Image = img, Path = images[i].Path, Text = text, Tag = null };
                cells[i] = newCell;
            }

            ShowLiveFace(images);

            // this.squareListView1.ShowImages(cells);
        }
 public static ImageDetail FromPath(string path)
 {
     ImageDetail img = new ImageDetail();
     img.ParsePath(path);
     return img;
 }
Exemple #18
0
 private string PrepareDestFolder(ImageDetail imgToProcess)
 {
     string parentOfBigPicFolder = Directory.GetParent(imgToProcess.ContainedBy).FullName;
     string destFolder = Path.Combine(parentOfBigPicFolder, Properties.Settings.Default.IconDirectoryName);
     if (!Directory.Exists(destFolder))
     {
         Directory.CreateDirectory(destFolder);
     }
     return destFolder;
 }
 private void ShowDetailPic(ImageDetail img)
 {
     FormDetailedPic detail = new FormDetailedPic();
     detail.Img = img;
     detail.ShowDialog(this);
     detail.Dispose();
 }
Exemple #20
0
 private void ShowDetailPic(ImageDetail img)
 {
 }