Esempio n. 1
0
        static void TestCli()
        {
            List <Camera> cams = Cli.AutoDetect(true);

            foreach (Camera cam in cams)
            {
                Console.Write($"{cam.model} at port {cam.model} - ");
            }
        }
Esempio n. 2
0
        static void TestCliCapture()
        {
            List <Camera> cams = Cli.AutoDetect(false);

            foreach (Camera cam in cams)
            {
                paths.Add(cam.captureImage()[0]);
            }
        }
Esempio n. 3
0
        static void TestCliCaptureD()
        {
            List <Camera> cams = Cli.AutoDetect(false);

            foreach (Camera cam in cams)
            {
                cam.captureImageBytes();
            }
        }
Esempio n. 4
0
        private void cameraWatch_elapsed(object sender, ElapsedEventArgs e)
        {
            if (cameras.Count != Cli.AutoDetect(true).Count)
            {
                RefreshList();

                connBtn.Enabled = false;
            }
        }
Esempio n. 5
0
        private void RefreshList()
        {
            connBtn.Enabled = false;

            cameraList.Items.Clear();
            cameras = Cli.AutoDetect(true);
            foreach (Camera cam in cameras)
            {
                cameraList.Items.Add($"{cam.model} (Port: {cam.port})" + (cam.isLocked ? " (In use)": ""));
            }
        }
Esempio n. 6
0
        public ConnectForm()
        {
            this.Title        = "Select your camera";
            cameraList        = new ListBox();
            cameraList.Width  = 400;
            cameraList.Height = 300;

            cameraList.SelectedIndexChanged += new EventHandler <EventArgs>(cameraList_selectedIndexChanged);
            cameraList.MouseDoubleClick     += new EventHandler <MouseEventArgs>(cameraList_mouseDoubleClick);

            foreach (Camera cam in Cli.AutoDetect(true))
            {
                cameraList.Items.Add($"{cam.model} (Port: {cam.port})" + (cam.isLocked ? " (In use)": ""));
            }

            connBtn = new Button {
                Text = "Connect", Enabled = false
            };
            connBtn.MouseUp += new EventHandler <MouseEventArgs>(connBtn_mouseUp);

            Button cancelBtn = new Button {
                Text = "Cancel"
            };
            Button refreshBtn = new Button {
                Text = "Refresh"
            };

            cancelBtn.MouseUp  += new EventHandler <MouseEventArgs>(cancelBtn_mouseUp);
            refreshBtn.MouseUp += new EventHandler <MouseEventArgs>(refreshBtn_mouseUp);

            DynamicLayout layout = new DynamicLayout();

            layout.Spacing = new Size(8, 8);
            layout.Padding = new Padding(8, 8);

            layout.AddRow(new Label {
                Text = "Cameras:"
            });
            layout.AddSeparateRow(cameraList);
            layout.AddSeparateRow(null, connBtn, null, refreshBtn, null, cancelBtn, null);

            this.Content = layout;

            cameraWatch = new Timer();

            cameraWatch.Interval = 1000;
            cameraWatch.Elapsed += new ElapsedEventHandler(cameraWatch_elapsed);

            cameraWatch.Start();
        }
Esempio n. 7
0
 private void cameraList_selectedIndexChanged(object sender, EventArgs e)
 {
     new System.Threading.Thread(() => {
         cameras = Cli.AutoDetect(true);
         if (cameraList.SelectedIndex != -1 && cameras.Count >= cameraList.SelectedIndex && !cameras[selectedCamera].isLocked)
         {
             selectedCamera  = cameraList.SelectedIndex;
             connBtn.Enabled = true;
         }
         else if (cameraList.SelectedIndex != -1)
         {
             connBtn.Enabled = false;
         }
     }).Start();
 }
Esempio n. 8
0
        private void cameraList_mouseDoubleClick(object sender, MouseEventArgs e)
        {
            List <Camera> cameras = Cli.AutoDetect(true);

            if (cameraList.SelectedIndex != -1 && cameras.Count >= cameraList.SelectedIndex)
            {
                selectedCamera  = cameraList.SelectedIndex;
                connBtn.Enabled = true;
                Console.WriteLine(cameras[selectedCamera].model);

                cameraWatch.Stop();
                this.Close();
            }
            else
            {
                connBtn.Enabled = false;
            }
        }
Esempio n. 9
0
        public static void PerformanceCompare()
        {
            long msLib    = 0;
            long msCli    = 0;
            long msCliDm1 = 0;
            long msCliDm2 = 0;

            int sampleSize = 5;

            Console.WriteLine($"Testing {sampleSize}x libgphoto2");
            for (int i = 0; i < sampleSize; i++)
            {
                Stopwatch sw = new Stopwatch();

                sw.Start();

                TestLibCapture();

                sw.Stop();

                msLib += Convert.ToInt64(sw.Elapsed.TotalMilliseconds);
            }

            Console.WriteLine($"Average libgphoto2 was {msLib / sampleSize}ms");
            Console.WriteLine($"Total libgphoto2 was {msLib / 1000d}s");


            Console.WriteLine();

            Console.WriteLine($"Testing {sampleSize}x gphoto2_ci_binding");
            paths = new List <string>();
            for (int i = 0; i < sampleSize; i++)
            {
                Stopwatch sw = new Stopwatch();

                sw.Start();

                TestCliCapture();

                sw.Stop();

                msCli += Convert.ToInt64(sw.Elapsed.TotalMilliseconds);
            }
            Console.WriteLine($"Average gphoto2_ci_binding was {msCli / sampleSize}ms");
            Console.WriteLine($"Sub-Total gphoto2_ci_binding was {msCli / 1000d}s");
            Console.WriteLine();

            Console.WriteLine($"Downloading Method 1 {sampleSize}x gphoto2_ci_binding");
            List <Camera> cams = Cli.AutoDetect(false);

            Directory.CreateDirectory(Environment.CurrentDirectory + "/temp");
            string folder = "";

            foreach (string path in paths)
            {
                Stopwatch sw = new Stopwatch();

                sw.Start();

                cams[0].DownloadFile(Environment.CurrentDirectory + "/temp/" + Path.GetFileName(path), path);

                sw.Stop();

                folder = Path.GetDirectoryName(path);

                msCliDm1 += Convert.ToInt64(sw.Elapsed.TotalMilliseconds);
            }
            Console.WriteLine($"Average gphoto2_ci_binding was {msCliDm1 / sampleSize}ms");
            Console.WriteLine($"Sub-Total gphoto2_ci_binding was {msCliDm1 / 1000d}s");

            Console.WriteLine($"Downloading Method 2 {sampleSize}x gphoto2_ci_binding");
            Directory.Delete(Environment.CurrentDirectory + "/temp", true);
            Directory.CreateDirectory(Environment.CurrentDirectory + "/temp");

            Stopwatch ssw = new Stopwatch();

            ssw.Start();

            cams[0].DownloadLast(sampleSize, Environment.CurrentDirectory + "/temp", folder);

            ssw.Stop();

            msCliDm2 = Convert.ToInt64(ssw.Elapsed.TotalMilliseconds);
            Console.WriteLine($"Sub-Total gphoto2_ci_binding was {msCliDm2 / 1000d}s");

            Console.WriteLine();
            Console.WriteLine($"Total gphoto2_ci_binding w/download method 1 was {(msCliDm1+msCli) / 1000d}s");
            Console.WriteLine($"Total gphoto2_ci_binding w/download method 2 was {(msCliDm2+msCli) / 1000d}s");
            Console.WriteLine();
            Console.WriteLine($"Difference w/o downloading {(msLib-msCli) / 1000d}s");
            Console.WriteLine();
            Console.WriteLine($"Difference with downloading method 1 {(msLib-(msCliDm1+msCli)) / 1000d}s");
            Console.WriteLine($"Difference with downloading method 2 {(msLib-(msCliDm2+msCli)) / 1000d}s");
        }