Inheritance: SQLiteDB
Beispiel #1
0
        public static void ClassifyFromWebCam(int imageID, bool show, bool classify, bool deskew, bool autoRotate, ref int date, ref String design)
        {
            date   = 0;
            design = "null";
            String modelDir = "C:/Users/pkrush/Documents/GemHunt/CoinSorter/models";
            IntPtr ptr      = ClassifyFromWebCam(imageID, show, classify, deskew, autoRotate, modelDir);

            //the output result should be a structure, it's hard coded for now:
            double[] result = new double[8];
            if (ptr == IntPtr.Zero)
            {
                return;
            }
            Marshal.Copy(ptr, result, 0, 8);
            ReleaseMemory(ptr);
            if ((int)result[0] == 0)
            {
                design = "Bad Capture";
                return;
            }
            design = LabelsDB.GetLabel((int)result[2]);
            if ((int)result[2] == 1)
            {
                date = (int)result[6];
            }
        }
Beispiel #2
0
        private void cmdGetImages_Click(object sender, EventArgs e)
        {
            listBoxWorkingLabel.Items.Clear();
            listBoxClickList.Items.Clear();
            listBoxLabelAllShown.Items.Clear();

            listBoxWorkingLabel.Items.Add("No Label");
            List <String> labels = new List <String>();

            if (radioDates.Checked)
            {
                labels = LabelsDB.GetDateLabels(radioDecades.Checked);
            }
            if (radioLabelDesigns.Checked)
            {
                labels = LabelsDB.GetDesignLabels();
            }

            foreach (String label in labels)
            {
                listBoxWorkingLabel.Items.Add(label);
            }
            listBoxClickList.Items.AddRange(listBoxWorkingLabel.Items);
            listBoxClickList.Items.Add("Delete");
            listBoxLabelAllShown.Items.AddRange(listBoxWorkingLabel.Items);
            listBoxLabelAllShown.Items.Add("Delete");

            listBoxWorkingLabel.SelectedIndex  = 0;
            listBoxClickList.SelectedIndex     = 1;
            listBoxLabelAllShown.SelectedIndex = 1;

            ImageRefresh(true);
        }
Beispiel #3
0
        public void ClassifyFiles(String oldImageDirectory, String newImageDirectory, String modelDir, bool toClassify, bool addImagesToDataBase, bool moveImage, bool includeSubDir)
        {
            string[] files;
            if (includeSubDir)
            {
                files = Directory.GetFiles(oldImageDirectory, "*.jpg*", SearchOption.AllDirectories);
            }
            else
            {
                files = Directory.GetFiles(oldImageDirectory, "*.jpg*");
            }

            List <ImageResult>    imageResults = new List <ImageResult>();
            Dictionary <int, int> images       = new Dictionary <int, int>();

            foreach (string image_file in files)
            {
                int imageID = Convert.ToInt32(image_file.Substring(image_file.Length - 12, 8));

                if (toClassify)
                {
                    IntPtr ptr = ClassifyImage(modelDir, image_file);
                    //the output result should be a structure, it's hard coded for now:
                    double[] result = new double[8];
                    Marshal.Copy(ptr, result, 0, 8);
                    ReleaseMemory(ptr);
                    imageResults.Add(new ImageResult(imageID, result));

                    if (moveImage)
                    {
                        FileInfo fi = new FileInfo(image_file);
                        String   imageFileDestination = newImageDirectory + "/" + LabelsDB.GetLabel((int)result[0]) + "/" + fi.Name;
                        File.Move(image_file, imageFileDestination);
                    }
                }
            }
            if (addImagesToDataBase)
            {
                ImagesDB.AddImages(imageResults);
            }
        }