示例#1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void BtnOpenFile_MouseUp(object sender, MouseButtonEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Image files |*.bmp;*.jpg;*.png;*.BMP;*.JPG;*.PNG";
            ofd.ShowDialog();
            if (ofd.FileName != "")
            {
                m_imagePath        = ofd.FileName;
                picturebox1.Source = TGMTimage.LoadImageWithoutLock(m_imagePath);
            }
        }
示例#2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void BtnOpen2_MouseUp(object sender, MouseButtonEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Image files |*.bmp;*.jpg;*.png;*.BMP;*.JPG;*.PNG";
            ofd.ShowDialog();
            if (ofd.FileName != "")
            {
                imagePath2    = ofd.FileName;
                image2.Source = TGMTimage.LoadImageWithoutLock(imagePath2);
            }

            Compare();
        }
示例#3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void workerSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                string filePath = e.Result.ToString();

                if (filePath != "")
                {
                    string[] splitted = filePath.Split(',');
                    filePath = splitted[0];
                    if (filePath != "" && splitted.Length > 1)
                    {
                        int percent = int.Parse(splitted[1]);
                        lblPercent.Content = percent.ToString() + "%";

                        if (percent >= faceCompMgr.Thresh)
                        {
                            lblPercent.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x00, 0xBB, 0x3C));
                        }
                        else
                        {
                            lblPercent.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
                        }

                        picturebox2.Source = TGMTimage.LoadImageWithoutLock(filePath);

                        m_result = filePath;
                    }
                }
            }
            catch (Exception ex)
            {
            }


            btnSearch.IsEnabled = true;
            timerProgress.Stop();
            progressbar.Value      = progressbar.Minimum;
            progressbar.Visibility = Visibility.Hidden;
        }
示例#4
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        void DrawLandmarkAndSave()
        {
            if (imagePath1 != null && imagePath2 != null && imagePath1 != "" && imagePath2 != "")
            {
                var    watch            = System.Diagnostics.Stopwatch.StartNew();
                string imageOutputPath1 = Directory.GetCurrentDirectory() + "\\result1.jpg";
                string imageOutputPath2 = Directory.GetCurrentDirectory() + "\\result2.jpg";
                faceCompMgr.DrawLandmarkAndSave(imagePath1, imageOutputPath1);
                faceCompMgr.DrawLandmarkAndSave(imagePath2, imageOutputPath2);
                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;

                this.Dispatcher.Invoke(() =>
                {
                    imageResult1.Source = TGMTimage.LoadImageWithoutLock(imageOutputPath1);
                });


                this.Dispatcher.Invoke(() =>
                {
                    imageResult2.Source = TGMTimage.LoadImageWithoutLock(imageOutputPath2);
                });
            }
        }
示例#5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void buttonExtractJPG_Click(object sender, EventArgs e)
        {
            if (lstCr2.Items.Count == 0)
            {
                return;
            }
            progressBar.Visible = true;
            progressBar.Value   = 0;
            lblMessage.Text     = "Processing...";
            int nbExtracted = 0;


            foreach (ListViewItem item in lstCr2.Items)
            {
                string filePath = item.Text;
                if (File.Exists(filePath))
                {
                    string baseName = Path.GetFileNameWithoutExtension(filePath);
                    string outDir   = Path.GetDirectoryName(filePath) + "\\";
                    baseName = outDir + baseName;
                    string jpgName = baseName + m_ext;

                    if (!chkOverwrite.Checked && File.Exists(jpgName))
                    {
                        int version = 1;

                        do
                        {
                            jpgName = String.Format("{0}_{1}" + m_ext, baseName, version);
                            ++version;
                        }while (File.Exists(jpgName));
                    }

                    Size size = new Size();
                    if (chkResize.Checked)
                    {
                        if (chkKeepAspect.Checked && numWidth.Value > 0)
                        {
                            size = new Size((int)numWidth.Value, 0);
                        }
                        else if (numWidth.Value > 0 && numHeight.Value > 0)
                        {
                            size = new Size((int)numWidth.Value, (int)numHeight.Value);
                        }
                    }

                    if (TGMTimage.ConvertCr2(filePath, jpgName, chkRotate.Checked, size))
                    {
                        progressBar.Value = ++nbExtracted;
                        if (item.SubItems.Count == 1)
                        {
                            item.SubItems.Add("done");
                        }
                        else
                        {
                            item.SubItems[1].Text = "done";
                        }
                        item.ForeColor = Color.Green;
                        if (chkDelete.Checked)
                        {
                            FileSystem.DeleteFile(filePath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                        }
                    }
                }
                else //file does not exist
                {
                    if (item.SubItems.Count == 1)
                    {
                        item.SubItems.Add("File not exist");
                    }
                    else
                    {
                        item.SubItems[1].Text = "File not exist";
                    }
                    item.ForeColor = Color.Red;
                }
            }

            lblMessage.Text     = "Complete";
            progressBar.Visible = false;
        }