Пример #1
0
 /// <summary>
 /// Show a picture in the <code>imgAdded</code> Image control with the file <code>fileName</code>.
 /// </summary>
 /// <param name="fileName"></param>
 private void showAddPicInfo(String fileName)
 {
     if (!String.IsNullOrEmpty(fileName))
     {
         string pattern = ClothUtil.ExtractPattern(fileName);
         // use pattern as name currently.
         showAddPicInfo(fileName, pattern);
     }
 }
Пример #2
0
        private void btnOpenKeyPic_Click(object sender, RoutedEventArgs e)
        {
            if (dlgOpenKeyPic.ShowDialog() == true)
            {
                BitmapImage bi = ViewHelper.NewBitmapImage(dlgOpenKeyPic.FileName);
                if (bi == null)
                {
                    MessageBox.Show("您选择的文件无法识别, 可能不是图片文件.", "显示关键图...");
                    return;
                }

                imgKeyPic.Source = bi;
                keyCloth         = new Cloth();
                keyCloth.Path    = dlgOpenKeyPic.FileName;
                keyCloth.Pattern = ClothUtil.ExtractPattern(keyCloth.Path);
                keyCloth.Name    = keyCloth.Pattern;

                //keyCloth.ColorVector = imageMatcher.ExtractRGBSeparateColorVector(keyCloth.Path, SearchConstants.IgnoreColors);
                //keyCloth.TextureVector = imageMatcher.ExtractDaubechiesWaveletVector(keyCloth.Path);
                //keyCloth.GaborVector = imageMatcher.ExtractGaborVector(keyCloth.Path);
                //keyCloth.CooccurrenceVector = imageMatcher.ExtractCooccurrenceVector(keyCloth.Path);

                /*keyClothOpened = true;
                 * if (keyClothThread != null && keyClothThread.IsAlive)
                 * {
                 *  keyClothThread.Abort();
                 * }
                 * ParameterizedThreadStart threadDelegate = new ParameterizedThreadStart(fillKeyCloth);
                 * keyClothThread = new Thread(threadDelegate);
                 * keyClothThread.IsBackground = true;
                 * keyClothThread.Start(dlgOpenKeyPic.FileName);
                 */
                /*lock (keyClothLock)
                 * {
                 *  FillKeyCloth fkc = new FillKeyCloth(fillKeyCloth);
                 *  fkc.BeginInvoke(dlgOpenKeyPic.FileName, ++curKeyClothOperId, null, null);
                 * }*/

                //ViewHelper.ExtractFeatures(keyCloth);
                //keyCloth.ColorVector = imageMatcher.ExtractRGBSeparateColorVector(keyCloth.Path, ViewConstants.IgnoreColors);
                //keyCloth.TextureVector = imageMatcher.ExtractDaubechiesWaveletVector(keyCloth.Path);
                //keyCloth.GaborVector = imageMatcher.ExtractGaborVector(keyCloth.Path);
                //keyCloth.CooccurrenceVector = imageMatcher.ExtractCooccurrenceVector(keyCloth.Path);

                updateSearchButton();
            }
        }
Пример #3
0
        private void btnAddFileSave_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(addPicFileName))
            {
                // should not be here.
                MessageBox.Show("请先选择一张图片.", "温馨提醒");
                return;
            }
            Cloth cloth = new Cloth();

            // whether use the key cloth.
            bool useKeyPic = (null != keyCloth && keyCloth.Path == addPicFileName);

            cloth.Path = addPicFileName;

            if (!String.IsNullOrEmpty(txtAddPattern.Text))
            {
                cloth.Pattern = txtAddPattern.Text;
            }
            cloth.Name = useKeyPic && keyCloth.Name != null ? keyCloth.Name : ClothUtil.ExtractPattern(addPicFileName);

            ColorEnum colors = ColorEnum.NONE;

            foreach (ColorItem ci in colorItems)
            {
                if (ci.Selected)
                {
                    colors |= ci.Value;
                }
            }
            cloth.Colors = colors;

            ShapeEnum shapes = ShapeEnum.NONE;

            foreach (ShapeItem si in shapeItems)
            {
                if (si.Selected)
                {
                    shapes |= si.Value;
                }
            }
            cloth.Shapes = shapes;

            // feature vectors
            //cloth.RGBSeparateColorVector = (useKeyPic && keyCloth.RGBSeparateColorVector != null)
            //    ? keyCloth.RGBSeparateColorVector : ClothUtil.ImageMatcherInst.ExtractRGBSeparateColorVector(cloth.Path, 8, SearchConstants.IgnoreColors);
            cloth.RGBColorVector = (useKeyPic && keyCloth.RGBColorVector != null)
                ? keyCloth.RGBColorVector : ClothUtil.ImageMatcherInst.ExtractRGBColorVector(cloth.Path, 3, SearchConstants.IgnoreColors);
            cloth.HSVAynsColorVector = (useKeyPic && keyCloth.HSVAynsColorVector != null)
                ? keyCloth.HSVAynsColorVector : ClothUtil.ImageMatcherInst.ExtractHSVAynsColorVector(cloth.Path, 0, SearchConstants.IgnoreColors);
            cloth.HSVColorVector = (useKeyPic && keyCloth.HSVColorVector != null)
                ? keyCloth.HSVColorVector : ClothUtil.ImageMatcherInst.ExtractHSVColorVector(cloth.Path, 3, SearchConstants.IgnoreColors);
            if (cloth.HSVColorVector != null)
            {
                cloth.ColorNum = ClothUtil.getColorNumber(cloth.HSVColorVector, 0.07f);
            }

            cloth.DaubechiesWaveletVector = (useKeyPic && keyCloth.DaubechiesWaveletVector != null)
                ? keyCloth.DaubechiesWaveletVector : ClothUtil.ImageMatcherInst.ExtractDaubechiesWaveletVector(cloth.Path);
            //cloth.GaborVector = (useKeyPic && keyCloth.GaborVector != null)
            //    ? keyCloth.GaborVector : ClothUtil.ImageMatcherInst.ExtractGaborVector(cloth.Path);
            //cloth.CooccurrenceVector = (useKeyPic && keyCloth.CooccurrenceVector != null)
            //    ? keyCloth.CooccurrenceVector : ClothUtil.ImageMatcherInst.ExtractCooccurrenceVector(cloth.Path);

            clothLibService.Insert(cloth);

            // close the window.
            this.Close();
        }