Exemplo n.º 1
0
        public void StartExposure(double Duration, bool Light)
        {
            _startTime = DateTime.Now;
            _duration  = Duration;

            if (Connected)
            {
                Logger.WriteTraceMessage("Prepare start of exposure: ");
                _downloadExposure = new TaskCompletionSource <object>();

                if (Duration <= 30.0)
                {
                    Logger.WriteTraceMessage("Exposuretime <= 30. Setting automatic shutter speed.");
                    var speed = _shutterSpeeds.Aggregate((x, y) => Math.Abs(x.Value - Duration) < Math.Abs(y.Value - Duration) ? x : y);
                    SetCameraShutterSpeed(speed.Key);

                    Logger.WriteTraceMessage("Start capture");
                    _camera.Capture();
                }
                else
                {
                    Logger.WriteTraceMessage("Use Bulb capture");
                    BulbCapture(Duration, StartBulbCapture, StopBulbCapture);
                }
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            try
            {
                // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/)
                NikonManager manager = new NikonManager("Type0003.md3");

                // Listen for the 'DeviceAdded' event
                manager.DeviceAdded += manager_DeviceAdded;

                // Wait for a device to arrive
                _waitForDevice.WaitOne();

                // Hook up capture events
                _device.ImageReady      += _device_ImageReady;
                _device.CaptureComplete += _device_CaptureComplete;

                // Capture
                _device.Capture();

                // Wait for the capture to complete
                _waitForCaptureComplete.WaitOne();

                // Shutdown
                manager.Shutdown();
            }
            catch (NikonException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        void CountDown(object o, ElapsedEventArgs a)
        {
            CounterItem cItem = counter.CountDown();

            if (cItem.Count == 0)
            {
                timer.Stop();

                if (device == null)
                {
                    return;
                }

                try
                {
                    pictureBox1.Image = ImageProcessing.Properties.Resources.smile;
                    pictureBox2.Image = null;
                    if (ClosingTimerStarted)
                    {
                        closingTimer.Elapsed -= new ElapsedEventHandler(CloseForm);
                        closingTimer.Stop();
                        ClosingTimerStarted = false;
                    }
                    closingTimer.Elapsed += new ElapsedEventHandler(CloseForm);
                    closingTimer.Start();
                    ClosingTimerStarted = true;
                    device.Capture();
                }
                catch (NikonException ex)
                {
                    if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_OutOfFocus)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.focuserror;
                        pictureBox2.Image = null;
                    }
                    else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_BatteryDontWork)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.lowbattery;
                        pictureBox2.Image = null;
                    }
                    else if (ex.ErrorCode == eNkMAIDResult.kNkMAIDResult_UnexpectedError)
                    {
                        pictureBox3.Image = null;
                        pictureBox1.Image = ImageProcessing.Properties.Resources.unknownerror;
                        pictureBox2.Image = null;
                    }
                    counter       = new Counter();
                    timer.Enabled = true;
                    timer.Start();
                }
                return;
            }
            pictureBox1.Image = cItem.Number;
            pictureBox2.Image = cItem.Smile;
        }
Exemplo n.º 4
0
 private void timelapseTimer_Tick(object sender, EventArgs e)
 {
     //check to see if number of pictures has been reached
     if (timelapseCounter == numberOfPictures)
     {
         timelapseTimer.Enabled = false;     //turn off timer to preserve resources
         timeLapseActive        = false;
         ToggleButtons(true);
         buttonTest.Enabled = true;
         return;
     }
     try
     {
         device.Capture();
         timelapseCounter++;
     }
     catch
     {
     }
 }
Exemplo n.º 5
0
 public void Capture()
 {
     if (IsConnected && IsReady && IsSaved)
     {
         IsReady = false;
         if (SaveToPc)
         {
             IsSaved = false;
         }
         dev.Capture();
     }
 }
Exemplo n.º 6
0
        public void StartExposure(double Duration, bool Light)
        {
            _startTime = DateTime.Now;
            _duration  = Duration;

            if (Connected)
            {
                if (!IsLiveViewMode)
                {
                    //liveViewTimer.Stop();
                    Logger.WriteTraceMessage("Prepare start of exposure: ");
                    _downloadExposure = new TaskCompletionSource <object>();

                    if (Duration <= 30.0)
                    {
                        Logger.WriteTraceMessage("Exposuretime <= 30. Setting automatic shutter speed.");
                        var speed = _shutterSpeeds.Aggregate((x, y) => Math.Abs(x.Value - Duration) < Math.Abs(y.Value - Duration) ? x : y);
                        SetCameraShutterSpeed(speed.Key);

                        SetCameraISO(GetSelectedIsoValueIndex());

                        Logger.WriteTraceMessage("Start capture");
                        _camera.Capture();
                    }
                    else
                    {
                        Logger.WriteTraceMessage("Use Bulb capture");
                        Task.Run(() => BulbCapture(Duration));
                    }
                }
                else
                {
                    Thread.Sleep(100);
                    _lvCapture = true;
                    //updateLV();
                }
            }
        }
        void capture_now()
        {
            if (device == null)
            {
                return;
            }
            if (page_in_range(page_no_lbl.Text))
            {
                if (File.Exists(single_path_tb.Text + page_no_lbl.Text + ".jpg"))
                {
                    MessageBox.Show("تم أخذ اللقطة من قبل ... قم بمسح اللقطة أولا لإعادة التصوير");
                }
                else
                {
                    not_tasweer_design(false);

                    live_now_1.Visible = false;
                    live_now_2.Visible = false;

                    try
                    {
                        curr_photo++;
                        if (curr_photo == 1)
                        {
                            auto_focus_now();
                        }

                        //auto_focus_now();

                        device.Capture();
                    }
                    catch (NikonException ex)
                    {
                        MessageBox.Show(ex.Message);
                        not_tasweer_design(true);
                    }

                    pictureBox1.Image = null;
                }
            }
            else
            {
                MessageBox.Show("رقم الصفحة المراد تصويرها خارج المهمة المطلوبة");
            }
        }
Exemplo n.º 8
0
 private void captureButton_Click(object sender, EventArgs e)
 {
     if (device == null)
     {
         return;
     }
     ToggleCameraButtons(false);
     try
     {
         device.Capture();
     }
     catch (NikonException ex)
     {
         MessageBox.Show(ex.Message);
         ToggleCameraButtons(true);
     }
     pictureBox.Image = null;
 }
Exemplo n.º 9
0
        public void Run()
        {
            try
            {
                // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR (see https://sdk.nikonimaging.com/apply/)
                NikonManager manager = new NikonManager("Type0003.md3");

                // Listen for the 'DeviceAdded' event
                manager.DeviceAdded += manager_DeviceAdded;

                // Wait for a device to arrive
                _waitForDevice.WaitOne();

                // Set shooting mode to 'continuous, highspeed'
                NikonEnum shootingMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode);
                shootingMode.Index = (int)eNkMAIDShootingMode.kNkMAIDShootingMode_CH;
                _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode, shootingMode);

                // Set number of continuous captures - in this case we want 5
                _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 5);

                // Hook up capture events
                _device.ImageReady      += _device_ImageReady;
                _device.CaptureComplete += _device_CaptureComplete;

                // Capture
                _device.Capture();

                // Wait for the capture to complete
                _waitForCaptureComplete.WaitOne();

                // Shutdown
                manager.Shutdown();
            }
            catch (NikonException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }