Exemplo n.º 1
0
        private void useCamera()
        {
            if (!StaticDataBase.isCameraWorking)
            {
                StaticDataBase.isCameraWorking = true;
                CameraButton.Text = "Stop Camera";
            }
            else
            {
                StaticDataBase.isCameraWorking = false;
                CameraButton.Text = "Start Camera";
            }
            ImageViewer viewer  = new ImageViewer();
            Capture     capture = new Capture();
            double      counter = 0;

            while (StaticDataBase.isCameraWorking)
            {
                CommonMethods     Cm  = new CommonMethods();
                SignToLetterClass sC  = new SignToLetterClass();
                StaticDataBase    sDB = new StaticDataBase();

                loadedPictureBox.Image = capture.QueryFrame();
                Image <Bgr, Byte> buffImage = capture.QueryFrame().ToImage <Bgr, Byte>();
                buffImage.ROI = new System.Drawing.Rectangle(StaticDataBase.mouseStartX, StaticDataBase.mouseStartY, Math.Abs(StaticDataBase.mouseStopX - StaticDataBase.mouseStartX), Math.Abs(StaticDataBase.mouseStopY - StaticDataBase.mouseStartY));

                resultImageBox.Image             = (Cm.DropZeros(Cm.UseFilters(buffImage, StaticDataBase.resizeXInPixels, StaticDataBase.resizeYInPixels)));
                StaticDataBase.PictureFromCamera = buffImage;

                if ((double)counter % 10 == 0)
                {
                    lock (StaticDataBase.PictureFromCamera)
                    {
                        sC.CheckItAllCamera();
                    }
                }

                if (StaticDataBase.galleryModeOn)
                {
                    buffImage.Save(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\cameraImg\\" + counter.ToString() + ".jpg");
                }

                Thread.Sleep(50);

                if ((double)counter % 10 == 0)
                {
                    sDB.NameOfBestMatch             = "";
                    StaticDataBase.BestMatchProcent = 0;
                }
                counter++;
            }
        }
Exemplo n.º 2
0
        private void openAndExeButton_Click(object sender, EventArgs e)
        {
            DialogResult originalFile;

            originalFile = openFileDialog.ShowDialog();
            if (originalFile != DialogResult.OK)
            {
                dialogLabel.Text = "no file";
                return;
            }
            SignToLetterClass  sC         = new SignToLetterClass(openFileDialog.FileName);
            Image <Bgr, Byte>  img_colour = new Image <Bgr, Byte>(openFileDialog.FileName);
            Image <Gray, Byte> img_grey   = new Image <Gray, byte>(img_colour.Width, img_colour.Height, new Gray(255));

            loadedPictureBox.Image = img_colour;
            img_grey             = sC.UseFilters(img_colour, StaticDataBase.resizeXInPixels, StaticDataBase.resizeYInPixels);
            img_grey             = sC.DropZeros(img_grey);
            resultImageBox.Image = img_grey;
            sC.CheckItAllCamera();
            img_colour.Dispose();
        }