예제 #1
0
        private void Calibrate_Click(object sender, RoutedEventArgs e)
        {
            ImageProcessing.SetOvrCamera(3, 0);
            int    cornersX         = int.Parse(CornersXBox.Text);
            int    cornersY         = int.Parse(CornersYBox.Text);
            int    calibImages      = int.Parse(ImageCountBox.Text);
            double patternWidth     = double.Parse(PatternWidthBox.Text);
            double screenSizeMargin = double.Parse(ScreenSizeMarginBox.Text);
            var    filename         = FilenameBox.Text;
            var    currDir          = Directory.GetCurrentDirectory();
            var    dataDir          = Path.Combine(currDir, "../../../../data/");

            ImageProcessing.PerformArToolkitCalibration(Path.Combine(dataDir, filename), cornersX, cornersY, calibImages, patternWidth, screenSizeMargin);
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var camera = (CameraSelectionBox.SelectedItem as ComboBoxItem).Content as string;

            Task.Run(() =>
            {
                if (camera == "OVRVision")
                {
                    ImageProcessing.SetOvrCamera(2, 0);
                }
                else if (camera == "OpenCV")
                {
                    ImageProcessing.SetOpenCVCamera();
                }
                else if (camera == "File")
                {
                    ImageProcessing.SetFileCamera("C:/code/img/4.png");
                }
                else if (camera == "Null")
                {
                    ImageProcessing.SetEmptyCamera();
                }

                ImageProcessing.StartImageProcessing();

                ImageProcessing.GetCamJsonProperties(GetPropertiesCallback);

                int pipeline = ImageProcessing.CreatePipeline();
                int output   = ImageProcessing.AddOpenCvOutput(pipeline, "Test");
                //int output2 = ImageProcessing.AddJsonOutput(pipeline, JsonMsg);
                //int processor = ImageProcessing.AddArucoProcessor(pipeline, @" { ""marker_size_m"": 0.29, ""use_tracker"": false } ");
                var currDir = Directory.GetCurrentDirectory();
                var dataDir = Path.Combine(currDir, "../../../../data/");

                dynamic config            = new JObject();
                config.calibration_left   = Path.Combine(dataDir, "calib_ovrvision_left.dat");
                config.calibration_right  = Path.Combine(dataDir, "calib_ovrvision_right.dat");
                config.calibration_stereo = Path.Combine(dataDir, "ovrvision_transL2R.dat");
                config.marker_size        = 24.0;

                //int processor = ImageProcessing.AddArToolkitStereoProcessor(pipeline, config.ToString());

                char keyPressed;
                int counter          = 0;
                bool useAutoContrast = true;

                while (true)
                {
                    ImageProcessing.ManualUpdate();
                    keyPressed = (char)ImageProcessing.OpenCvWaitKey(5);

                    if (keyPressed == 'c')
                    {
                        dynamic camConfig      = new JObject();
                        useAutoContrast        = !useAutoContrast;
                        camConfig.AutoContrast = useAutoContrast;
                        ImageProcessing.SetCamJsonProperties(camConfig.ToString());
                    }

                    if (keyPressed == 's')
                    {
                        counter = (counter + 1) % 2;

                        switch (counter)
                        {
                        case 0:
                            //ImageProcessing.SetOvrCamera(2, 0);
                            ImageProcessing.SetFileCamera("C:/code/resources/dummy2.jpg");
                            break;

                        case 1:
                            ImageProcessing.SetFileCamera("C:/code/resources/dummy3.jpg");
                            break;
                        }
                    }

                    if (keyPressed == 'q')
                    {
                        //ImageProcessing.RemoveProcessor(pipeline, processor);
                        ImageProcessing.RemoveOutput(pipeline, output);
                        //ImageProcessing.RemoveOutput(pipeline, output2);
                        ImageProcessing.RemovePipeline(pipeline);
                        ImageProcessing.StopImageProcessing();
                        break;
                    }
                }
            });
        }