Exemplo n.º 1
0
        public void StartExposure(double Duration, bool Light)
        {
            if (!IsLiveViewMode)
            {
                InitSettings();

                _duration  = Duration;
                _startTime = DateTime.Now;
                _canceledFlag.IsCanceled = false;

                if (Duration >= 1)
                {
                    MainCamera.SetSetting(PropertyID.Tv, TvValues.GetValue("Bulb").IntValue);
                    MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                }
                else
                {
                    CameraValue tvCameraValue = GetSelectedTv(Duration);
                    MainCamera.SetSetting(PropertyID.Tv, tvCameraValue.IntValue);
                    MainCamera.TakePhoto();
                }
            }
            else
            {
                Thread.Sleep(100);
                _lvCapture = true;
            }
        }
Exemplo n.º 2
0
        public bool TakePhoto(string[] camSettings)  //where cS[0] is ISO(sensitivity), cS[1] is Tv(exposition), cS[2] is Tv in bulb mode and cS[3] is Av(apperture)
        {
            try
            {
                APIHandler = new CanonAPI();
                if (OpenSession())
                {
                    if (!Error)
                    {
                        ImageSaveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                        MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
                        MainCamera.SetSetting(PropertyID.ISO, ISOValues.GetValue(camSettings[0]).IntValue);
                        MainCamera.SetSetting(PropertyID.Av, AvValues.GetValue(camSettings[3]).IntValue);
                        MainCamera.SetCapacity(4096, int.MaxValue);
                        Console.WriteLine($"Set image output path to: {ImageSaveDirectory}");

                        Console.WriteLine("Taking photo with special settings...");
                        CameraValue tv = TvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Tv));
                        if (tv == TvValues.Bulb)
                        {
                            MainCamera.TakePhotoBulb(int.Parse(camSettings[2]));
                        }
                        else
                        {
                            MainCamera.SetSetting(PropertyID.Tv, TvValues.GetValue(camSettings[1]).IntValue);
                            MainCamera.TakePhoto();
                        }
                        WaitEvent.WaitOne();

                        if (!Error)
                        {
                            Console.WriteLine("Photo taken and saved"); return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); return(false); }
            finally
            {
                MainCamera?.Dispose();
                APIHandler.Dispose();
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                APIHandler = new CanonAPI();
                List <Camera> cameras = APIHandler.GetCameraList();
                if (!OpenSession())
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    APIHandler.CameraAdded += APIHandler_CameraAdded;
                    WaitEvent.WaitOne();
                    WaitEvent.Reset();
                }

                if (!Error)
                {
                    ImageSaveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                    MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
                    MainCamera.SetCapacity(4096, int.MaxValue);
                    Console.WriteLine($"Set image output path to: {ImageSaveDirectory}");

                    Console.WriteLine("Taking photo with current settings...");
                    CameraValue tv = TvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Tv));
                    if (tv == TvValues.Bulb)
                    {
                        MainCamera.TakePhotoBulb(2);
                    }
                    else
                    {
                        MainCamera.TakePhoto();
                    }
                    WaitEvent.WaitOne();

                    if (!Error)
                    {
                        Console.WriteLine("Photo taken and saved");
                    }
                }
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
            finally
            {
                MainCamera?.Dispose();
                APIHandler.Dispose();
                Console.WriteLine("Good bye! (press any key to close)");
                Console.ReadKey();
            }
        }
Exemplo n.º 4
0
        private void MainCamera_LiveViewUpdated(EOSDigital.API.Camera sender, Stream img)
        {
            var Evf_Bmp = new Bitmap(img);

            if (_lvInitialized)
            {
                if (MainCamera.IsManualMode())
                {
                    if (lvexposure > 0 && lvexposure <= 30)
                    {
                        CameraValue tvCameraValue = GetSelectedTv(lvexposure);
                        MainCamera.SetSetting(PropertyID.Tv, tvCameraValue.IntValue);
                    }
                }


                var expComp = MainCamera.GetUInt32Setting(PropertyID.ExposureCompensation);
                if (Iso > 0 && Iso <= MaxIso)
                {
                    MainCamera.SetSetting(PropertyID.ExposureCompensation, ExpCompValues.Values[ExpCompValues.Values.Count() - Iso - 1].IntValue);
                }

                if (LiveViewImageReady != null && _lvCapture)
                {
                    //LiveViewImageReady?.Invoke(this, new LiveViewImageReadyEventArgs(Evf_Bmp));
                    LiveViewImageReady(this, new LiveViewImageReadyEventArgs(Evf_Bmp));
                    _lvCapture = false;
                }
            }
            else
            {
                MainCamera.SetSetting(PropertyID.Evf_Zoom, (UInt32)LiveViewZoom);
                var currentZoom = MainCamera.GetUInt32Setting(PropertyID.Evf_Zoom);
                if (currentZoom == (int)LiveViewZoom)
                {
                    _lvInitialized = true;
                    if (LvFrameHeight == 0 || LvFrameWidth == 0)
                    {
                        LvFrameWidth  = Evf_Bmp.Width;
                        LvFrameHeight = Evf_Bmp.Height;
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void InitSettings()
        {
            MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
            MainCamera.SetCapacity(1024, int.MaxValue);

            switch (ImageFormat)
            {
            case ImageFormat.RAW:
                MainCamera.SetSetting(PropertyID.ImageQuality, (int)ImageQuality.RAW);
                break;

            case ImageFormat.JPEG:
                MainCamera.SetSetting(PropertyID.ImageQuality, (int)ImageQuality.LargeJpegFine);
                break;
            }

            CameraValue selectedIsoValue = GetSelectedIsoValue();

            MainCamera.SetSetting(PropertyID.ISO, selectedIsoValue.IntValue);
        }
Exemplo n.º 6
0
        public void StartExposure(double Duration, bool Light)
        {
            OpenSession();
            InitSettings();

            _duration  = Duration;
            _startTime = DateTime.Now;
            _canceledFlag.IsCanceled = false;

            if (Duration >= 1)
            {
                MainCamera.SetSetting(PropertyID.Tv, TvValues.GetValue("Bulb").IntValue);
                MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
            }
            else
            {
                CameraValue tvCameraValue = GetSelectedTv(Duration);
                MainCamera.SetSetting(PropertyID.Tv, tvCameraValue.IntValue);
                MainCamera.TakePhoto();
            }
        }
Exemplo n.º 7
0
        public void StartExposure(double Duration, bool Light)
        {
            if (!IsLiveViewMode)
            {
                InitSettings();

                _duration  = Duration;
                _startTime = DateTime.Now;
                _canceledFlag.IsCanceled = false;

                MainCamera.IsOldCanon();

                if (MainCamera.IsManualMode())
                {
                    if (Duration > 30)
                    {
                        Logger.WriteTraceMessage("ManualMode and > 30.0");
                        MainCamera.SetSetting(PropertyID.Tv, TvValues.GetValue("Bulb").IntValue);
                        MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                    }
                    else
                    {
                        Logger.WriteTraceMessage("ManualMode and < 30.0");
                        CameraValue tvCameraValue = GetSelectedTv(Duration);
                        MainCamera.SetSetting(PropertyID.Tv, tvCameraValue.IntValue);
                        MainCamera.TakePhoto();
                    }
                }
                else
                {
                    if (MainCamera.IsBulbMode())
                    {
                        if (Duration >= 1)
                        {
                            Logger.WriteTraceMessage("BulbMode and > 1.0");
                            MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                        }
                        else
                        {
                            Logger.WriteTraceMessage("BulbMode and < 1.0");
                            MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                        }
                    }
                    else
                    {
                        Logger.WriteTraceMessage("For old cameras the wheel needs to be (M) position and for newer cameras the wheel needs to be (B) position");
                        throw new InvalidOperationException("For old cameras the wheel needs to be (M) position and for newer cameras the wheel needs to be (B) position");
                    }
                }

                /* Old Code when I was trobleshooting
                 * if (Duration >= 1 )
                 * {
                 *      if (MainCamera.IsManualMode() || MainCamera.IsOldCanon()) {
                 *      Logger.WriteTraceMessage(">= 1 ManualMode or Oldcanon");
                 *      MainCamera.SetSetting(PropertyID.Tv, TvValues.GetValue("Bulb").IntValue);
                 *      }
                 *      MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                 *
                 * }
                 * else
                 * {
                 *  Logger.WriteTraceMessage("< 1");
                 *
                 *  if (MainCamera.IsOldCanon() || MainCamera.IsManualMode())
                 *  {
                 *      CameraValue tvCameraValue = GetSelectedTv(Duration);
                 *      Logger.WriteTraceMessage("< 1 ManualMode or Oldcanon");
                 *      MainCamera.SetSetting(PropertyID.Tv, tvCameraValue.IntValue);
                 *      MainCamera.TakePhoto();
                 *  }
                 *  else
                 *  {
                 *      Logger.WriteTraceMessage("Not Old or Manual");
                 *      if (MainCamera.IsBulbMode())
                 *      {
                 *          Logger.WriteTraceMessage("New Canon BulbMode");
                 *          MainCamera.TakePhotoBulbAsync((int)(Duration * 1000), _canceledFlag);
                 *      }
                 *
                 *  }
                 *
                 * }*/
            }
            else
            {
                Thread.Sleep(100);
                _lvCapture = true;
            }
        }
Exemplo n.º 8
0
        public async Task <object> TakePhoto(dynamic input)
        {
            NodeResult result = new NodeResult();

            try
            {
                Console.WriteLine("Called C# method from node.");
                APIHandler = new CanonAPI();

                Console.WriteLine("APIHandler initialised");
                List <Camera> cameras = APIHandler.GetCameraList();
                foreach (var camera in cameras)
                {
                    Console.WriteLine("APIHandler GetCameraList:" + camera);
                }

                if (cameras.Count > 0)
                {
                    MainCamera = cameras[0];
                    MainCamera.DownloadReady += MainCamera_DownloadReady;
                    MainCamera.OpenSession();
                    Console.WriteLine($"Opened session with camera: {MainCamera.DeviceName}");
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    APIHandler.CameraAdded += APIHandler_CameraAdded;
                    WaitEvent.WaitOne();
                    WaitEvent.Reset();
                }
                Console.WriteLine("OpenSession");
                if (!Error)
                {
                    if (ImageSaveDirectory == null)
                    {
                        ImageSaveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                    }
                    MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
                    MainCamera.SetCapacity(4096, int.MaxValue);
                    Console.WriteLine($"Set image output path to: {ImageSaveDirectory}");

                    Console.WriteLine("Taking photo with current settings...");
                    CameraValue tv = TvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Tv));
                    if (tv == TvValues.Bulb)
                    {
                        MainCamera.TakePhotoBulb(2);
                    }
                    else
                    {
                        MainCamera.TakePhoto();
                    }
                    WaitEvent.WaitOne();

                    if (!Error)
                    {
                        Console.WriteLine("Photo taken and saved");
                    }
                    result.message = "Photo taken and saved";
                    result.success = true;
                }
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
            finally
            {
                MainCamera?.Dispose();
                APIHandler.Dispose();
                Console.WriteLine("Program exited.");
            }

            return(result);
        }