Exemple #1
0
        public MainForm()
        {
            //初始化界面信息
            InitializeComponent();

            //设置拖动截取框的透明显示对象,显示实时取景的窗口
            pictureBox.Parent = LiveViewPicBox;

            //初始化照相SDK驱动信息
            CameraHandler = new SDKHandler();

            CameraHandler.CameraAdded      += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
            CameraHandler.FrameRateUpdated += new SDKHandler.FloatUpdate(SDK_FrameRateUpdated);
            CameraHandler.LiveViewUpdated  += new SDKHandler.ImageUpdate(SDK_LiveViewUpdated);
            CameraHandler.ProgressChanged  += new SDKHandler.ProgressHandler(SDK_ProgressChanged);


            //设置图片保存路径,默认的是系统照片文件夹下的RemotePhoto目录下
            SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");

            SaveNameTextBox.Text = "CS.JPG";
            //SavePathTextBox.Text = "C:\\Users\\ITF\\Pictures\\RemotePhotoasasdf.JPG";

            RefreshCamera();
        }
        public CameraForm()
        {
            try
            {
                InitializeComponent();
                CameraHandler                        = new SDKHandler();
                CameraHandler.CameraAdded           += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
                CameraHandler.LiveViewUpdated       += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CameraHandler.ProgressChanged       += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
                CameraHandler.ImageDownloaded       += new SDKHandler.BitmapUpdate(SDK_ImageDownloaded);
                CameraHandler.ImageSavedToDirectory += new EventHandler(SDK_ImageSavedToDirectory);
                CameraHandler.CameraHasShutdown     += SDK_CameraHasShutdown;
                SavePathTextBox.Text                 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                LVBw = LiveViewPicBox.Width;
                LVBh = LiveViewPicBox.Height;
                RefreshCamera();
            }
            catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
            catch (Exception ex) { ReportError(ex.Message, true); }

            try
            {
                InitSerialPorts();
            }
            catch (Exception ex)
            {
                ReportError(ex.Message, true);
            }

            InitColorModes();
            InitImageSaveModes();
            InitializeDefaultValues();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
                List <Camera> cameras = CameraHandler.GetCameraList();
                if (cameras.Count > 0)
                {
                    CameraHandler.OpenSession(cameras[0]);
                    Console.WriteLine("Opened session with camera: " + cameras[0].Info.szDeviceDescription);
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    CameraHandler.CameraAdded += handler_CameraAdded;
                    CallEvent();
                }

                int StartPhotos = 0;
                while (true)
                {
                    string text = CheckTextFile().ToLower();
                    if (text == "ready")
                    {
                        do
                        {
                            for (StartPhotos = 0; StartPhotos < 5; StartPhotos++)
                            {
                                Console.WriteLine("Taking photo with current settings...");
                                CameraHandler.SetCapacity();
                                CameraHandler.TakePhoto();
                                Thread.Sleep(2000);
                            }
                        } while (StartPhotos < 5);
                        StartBuggy();
                    }

                    else
                    {
                        Thread.Sleep(2000);
                        Console.WriteLine("I have stopped checking now");
                    }

                    CallEvent();
                    Console.WriteLine("Photo taken and saved");
                }
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
            finally
            {
                CameraHandler.CloseSession();
                CameraHandler.Dispose();
                Console.WriteLine("Good bye! (press any key to close)");
                Console.ReadKey();
            }
        }
 protected override void Close()
 {
     if (CameraHandler != null)
     {
         EDSDK.EdsGetEvent();
         CameraHandler.CloseSession();
         CameraHandler.Dispose();
         CameraHandler = null;
     }
 }
 /// <summary>
 /// рубильник
 /// </summary>
 public void Terminate()
 {
     if (_handler == null)
     {
         return;
     }
     _handler.LiveViewUpdated -= Handler_LiveViewUpdated;
     _handler.CloseSession();
     _handler.Dispose();
     _handler = null;
 }
Exemple #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            SDKHandler    handler = new SDKHandler();
            List <Camera> cameras = handler.GetCameraList();

            handler.OpenSession(cameras.First());
            handler.LiveViewUpdated += Handler_LiveViewUpdated;
            handler.StartLiveView();
        }
Exemple #7
0
 public PaymentCmdCallbackWraper(PaymentService paymentService, int sdkCode, int productId, string sdkProductId, int productNum, string currency, SDKHandler sdkHandler, ReqPayOrderReturn reqPayOrderReturn, CmdCallback cmdCallback) : base(cmdCallback)
 {
     this.paymentService    = paymentService;
     this.sdkCode           = sdkCode;
     this.productId         = productId;
     this.sdkProductId      = sdkProductId;
     this.productNum        = productNum;
     this.currency          = currency;
     this.sdkHandler        = sdkHandler;
     this.reqPayOrderReturn = reqPayOrderReturn;
 }
Exemple #8
0
 public MainForm()
 {
     InitializeComponent();
     CameraHandler = new SDKHandler();
     CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
     LVBw = LiveViewPicBox.Width;
     LVBh = LiveViewPicBox.Height;
     RefreshCamera();
 }
Exemple #9
0
 public MainForm()
 {
     InitializeComponent();
     CameraHandler                    = new SDKHandler();
     CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
     LVBw = LiveViewPicBox.Width;
     LVBh = LiveViewPicBox.Height;
     RefreshCamera();
 }
 public MainForm()
 {
     InitializeComponent();
     CameraHandler = new SDKHandler();
     CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
     SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
     LVBw = LiveViewPicBox.Width;
     LVBh = LiveViewPicBox.Height;
     RefreshCamera();
 }
Exemple #11
0
 public MainForm()
 {
     InitializeComponent();
     CameraHandler                    = new SDKHandler();
     CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += CameraHandler_CameraHasShutdown;
     SavePathTextBox.Text             = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
     LVBw = LiveViewPicBox.Width;
     LVBh = LiveViewPicBox.Height;
     RefreshCamera();
 }
Exemple #12
0
 public MainWindow()
 {
     InitializeComponent();
     CameraHandler                    = new SDKHandler();
     CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
     SavePathTextBox.Text             = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
     SetImageAction                   = new ThreadStart(delegate { bgbrush.ImageSource = EvfImage; });
     SaveFolderBrowser.Description    = "Save Images To...";
     RefreshCamera();
     IsInit = true;
 }
Exemple #13
0
 public MainWindow()
 {
     InitializeComponent();
     CameraHandler = new SDKHandler();
     CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
     CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
     CameraHandler.ProgressChanged += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
     CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
     SavePathTextBox.Text = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
     SetImageAction = new ThreadStart(delegate { bgbrush.ImageSource = EvfImage; });
     SaveFolderBrowser.Description = "Save Images To...";
     RefreshCamera();
     IsInit = true;
 }
 /// <summary>
 /// Инициализируем SDK
 /// </summary>
 public void Init()
 {
     try
     {
         _handler = new SDKHandler();
         _handler.LiveViewUpdated   += Handler_LiveViewUpdated;
         _handler.CameraHasShutdown += CameraHasShutdown;
         _handler.CameraAdded       += CameraAdded;
         RefreshCam();
     }
     catch (Exception ex)
     {
         NLog.LogManager.GetCurrentClassLogger().Error(ex);
     }
 }
Exemple #15
0
        public MainForm()
        {
            //AcquirePatientRecordFromWebService("SP-15-4155");
            InitializeComponent();
            initFromConfig();


            initControlsExtra();
            CameraHandler                    = new SDKHandler();
            CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
            CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
            CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
            CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
            //SDKHandler.
            // SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
            // DateTime dt;
            string year_str  = DateTime.Now.ToString("yyyy");
            string month_str = DateTime.Now.ToString("MM");

            //string image_folder = "C:\\pis\\image\\gross\\" + year_str + "\\" + month_str;
            imageOutputFolder = Path.Combine(taskOutputFolder, year_str, month_str);
            if (!Directory.Exists(imageOutputFolder))
            {
                Directory.CreateDirectory(imageOutputFolder);
            }
            if (!Directory.Exists(taskOutputFolder))
            {
                Directory.CreateDirectory(taskOutputFolder);
            }
            if (!Directory.Exists(taskFolder))
            {
                Directory.CreateDirectory(taskFolder);
            }
            if (!Directory.Exists(taskImageTempFolder))
            {
                Directory.CreateDirectory(taskImageTempFolder);
            }
            //empty image temp folder
            CleanupImageTempFolder();
            RefreshTasks();

            SavePathTextBox.Text = imageOutputFolder;
            LVBw = LiveViewPicBox.Width;
            LVBh = LiveViewPicBox.Height;
            RefreshCamera();
            // TakePhotoButton.Enabled = recordReadyFlag;
        }
Exemple #16
0
        public void InitCamera()
        {
            handler = new SDKHandler();
            List <Camera> cameras = handler.GetCameraList();

            if (cameras.Count != 0)
            {
                handler.OpenSession(cameras.First());
                handler.SetSetting(0x0000000b, 2);
                Directory.CreateDirectory("./temp");
                handler.ImageSaveDirectory = "./temp";
            }
            else
            {
                throw new SystemException("No Camera");
            }
        }
Exemple #17
0
 public MainForm()
 {
     try
     {
         InitializeComponent();
         CameraHandler                    = new SDKHandler();
         CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
         CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
         CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
         CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
         SavePathTextBox.Text             = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
         LVBw = LiveViewPicBox.Width;
         LVBh = LiveViewPicBox.Height;
         RefreshCamera();
     }
     catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
     catch (Exception ex) { ReportError(ex.Message, true); }
 }
Exemple #18
0
 public MainWindow()
 {
     try
     {
         InitializeComponent();
         CameraHandler                    = new SDKHandler();
         CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
         CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
         CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
         CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
         SavePathTextBox.Text             = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
         SetImageAction                   = (BitmapImage img) => { bgbrush.ImageSource = img; };
         SaveFolderBrowser.Description    = "Save Images To...";
         RefreshCamera();
         IsInit = true;
     }
     catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
     catch (Exception ex) { ReportError(ex.Message, true); }
 }
        protected override void Setup()
        {
            if (!String.IsNullOrWhiteSpace(CurrentDataFileDirectory) && !Directory.Exists(CurrentDataFileDirectory))
            {
                Directory.CreateDirectory(CurrentDataFileDirectory);
            }

            CameraHandler = new SDKHandler();
            //CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
            CameraHandler.CameraAdded        += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
            CameraHandler.CameraHasShutdown  += SDK_CameraHasShutdown;
            CameraHandler.NewImageDownloaded += CameraHandler_NewImageDownloaded;
            CameraHandler.CameraError        += CameraHandler_CameraError;

            // Tell the handler where to save the images.
            CameraHandler.ImageSaveDirectory = CurrentDataFileDirectory;

            TryOpenSession();
        }
        public void Activate(IWorkSpace controller)
        {
            if (!IsActivated)
            {
                _cameraHandler = new SDKHandler();
                //CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
                //CameraHandler.FrameRateUpdated += new SDKHandler.FloatUpdate(SDK_FrameRateUpdated);
                _cameraHandler.LiveViewUpdated += new SDKHandler.ImageUpdate(SDK_LiveViewUpdated);
                //CameraHandler.ProgressChanged += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
                _cameraHandler.CameraHasShutdown += CameraHandler_CameraHasShutdown;

                CloseSession();

                IsActivated = OpenSession();
            }
            else
            {
                throw new Exception("Повторная активация сервиса камеры не возможна");
            }
        }
Exemple #21
0
        public void Activate(IWorkSpace controller)
        {
            if (!IsActivated)
            {
                _cameraHandler = new SDKHandler();
                //CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
                //CameraHandler.FrameRateUpdated += new SDKHandler.FloatUpdate(SDK_FrameRateUpdated);
                _cameraHandler.LiveViewUpdated += new SDKHandler.ImageUpdate(SDK_LiveViewUpdated);
                //CameraHandler.ProgressChanged += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
                _cameraHandler.CameraHasShutdown += CameraHandler_CameraHasShutdown;

                CloseSession();

                IsActivated = OpenSession();
            }
            else
            {
                throw new Exception("Повторная активация сервиса камеры не возможна");
            }
        }
Exemple #22
0
        private void StartLiveViewCaptureBtn(object sender, RoutedEventArgs e)
        {
            ToggleCaptureBtn(false);

            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CamList = CameraHandler.GetCameraList();
                CameraHandler.OpenSession(CamList[0]);
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
                CameraHandler.SetCapacity();
                Console.WriteLine(Environment.UserName);
                CameraHandler.ImageSaveDirectory = imageDirectory;
                SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
            }
            catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
            catch (Exception ex) { ReportError(ex.Message, true); }

            LiveViewController();
        }
        /// <summary>
        /// 初始化
        /// </summary>
        public CanonSDKUserControl()
        {
            InitializeComponent();
            //设置校正框的父窗体
            pictureBox.Parent = LiveViewPicBox;
            //初始化照相SDK驱动信息
            CameraHandler = new SDKHandler();

            CameraHandler.CameraAdded      += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
            CameraHandler.FrameRateUpdated += new SDKHandler.FloatUpdate(SDK_FrameRateUpdated);
            CameraHandler.LiveViewUpdated  += new SDKHandler.ImageUpdate(SDK_LiveViewUpdated);
            CameraHandler.ProgressChanged  += new SDKHandler.ProgressHandler(SDK_ProgressChanged);


            //设置照片保存的位置,相机或者电脑
            //CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);

            //设置图片保存路径,默认的是系统照片文件夹下的RemotePhoto目录下
            savePathText = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
            RefreshCamera();
        }
        private int initCamera()
        {
            CameraHandler                    = new SDKHandler();
            CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
            CameraHandler.CameraHasShutdown += CameraHandler_CameraHasShutdown;

            ImageSaveFolder = "D:\\pis\\image\\gross\\";
            ImageSaveName   = "gross.jpg";
            String   sDate     = DateTime.Now.ToString();
            DateTime datevalue = (Convert.ToDateTime(sDate.ToString()));
            String   year      = datevalue.Year.ToString();

            ImageSaveFolder += (year + '\\');
            //Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
            if (!Directory.Exists(ImageSaveFolder))
            {
                Directory.CreateDirectory(ImageSaveFolder);
            }

            //RefreshCamera();


            int err = RefreshCamera();

            OpenSession();
            CameraHandler.ImageSaveDirectory = ImageSaveFolder;
            CameraHandler.ImageSaveName      = ImageSaveName;
            System.Threading.Thread.Sleep(500);
            CameraHandler.TakePhoto();

            /*
             * if (err >= 0)
             *  SetSaveTo(1); // save to 0 camera, 1 host, 2 both
             * else
             *  return -1;
             */
            return(0);
        }
Exemple #25
0
        static void Main(string[] args)
        {
            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
                List <Camera> cameras = CameraHandler.GetCameraList();
                if (cameras.Count > 0)
                {
                    CameraHandler.OpenSession(cameras[0]);
                    Console.WriteLine("Opened session with camera: " + cameras[0].Info.szDeviceDescription);
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    CameraHandler.CameraAdded += handler_CameraAdded;
                    CallEvent();
                }

                CameraHandler.ImageSaveDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);

                Console.WriteLine("Taking photo with current settings...");
                CameraHandler.TakePhoto();

                CallEvent();
                Console.WriteLine("Photo taken and saved");
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
            finally
            {
                CameraHandler.CloseSession();
                CameraHandler.Dispose();
                Console.WriteLine("Good bye! (press any key to close)");
                Console.ReadKey();
            }
        }
        static void Main(string[] args)
        {
            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
                List<Camera> cameras = CameraHandler.GetCameraList();
                if (cameras.Count > 0)
                {
                    CameraHandler.OpenSession(cameras[0]);
                    Console.WriteLine("Opened session with camera: " + cameras[0].Info.szDeviceDescription);
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    CameraHandler.CameraAdded += handler_CameraAdded;
                    CallEvent();
                }

                CameraHandler.ImageSaveDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);

                Console.WriteLine("Taking photo with current settings...");
                CameraHandler.TakePhoto();

                CallEvent();
                Console.WriteLine("Photo taken and saved");
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
            finally
            {
                CameraHandler.CloseSession();
                CameraHandler.Dispose();
                Console.WriteLine("Good bye! (press any key to close)");
                Console.ReadKey();
            }
        }
Exemple #27
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ParseConfigFile();
            ImageWidth  = this.Width * 0.99;
            ImageHeight = this.Height * 0.99;

            tbText.Text = "Insert Coin to begin!";
            tbText.VerticalAlignment = VerticalAlignment.Center;

            tbSelect.Width = ImageWidth / 3;


            handler = new SDKHandler();
            List <Camera> cameras = handler.GetCameraList();

            if (cameras.Count != 0)
            {
                handler.OpenSession(cameras.First());
                handler.StartLiveView();
                handler.LiveViewUpdated += Handler_LiveViewUpdated;
                handler.SetSetting(0x0000000b, 2);
                handler.ImageSaveDirectory = PictureLocation;
            }
        }
Exemple #28
0
 public MainForm()
 {
     try
     {
         InitializeComponent();
         this.accept_btn.Enabled        = false;
         this.reject_btn.Enabled        = false;
         this.TakePhotoButton.Enabled   = false;
         this.RecordVideoButton.Enabled = false;
         CameraHandler                    = new SDKHandler();
         CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
         CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
         CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
         CameraHandler.ImageDownloaded   += new SDKHandler.BitmapUpdate(SDK_ImageDownloaded);
         CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
         SavePathTextBox.Text             = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
         LVBw = LiveViewPicBox.Width;
         LVBh = LiveViewPicBox.Height;
         RefreshCamera();
         camera_connected = false;
     }
     catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
     catch (Exception ex) { ReportError(ex.Message, true); }
 }
Exemple #29
0
 public ImageProcessor()
 {
     Cameras       = new ObservableCollection <EDSDKLib.Camera>();
     CameraHandler = new SDKHandler();
 }
Exemple #30
0
 // GET CAMERA FILES
 private void initializeCamera()
 {
     /* The camera will be initialized, when the neccessary dll's are available!
      * Otherwise the camera function will be disabled.
      */
     if (File.Exists(DLLPath))
     {
         try
         {
             CameraHandler = new SDKHandler();
             CameraHandler.CameraAdded += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
             CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
             LVBw = pictureBoxLiveView.Width;
             LVBh = pictureBoxLiveView.Height;
             refreshCamera();
         }
         catch (DllNotFoundException)
         {
             reportError("Canon DLLs not found!", false);
         }
         catch (Exception ex)
         {
             reportError(ex.Message, false);
         }
     }
 }
        /*unused variables for poorly timed autofocus method
        static private long currentSum;
        static private long prevSum;
        static private long locMaxSum;
        static Bitmap bmp;*/
        static int initialize()
        {
            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
                CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
                List<Camera> cameras = CameraHandler.GetCameraList();
                Console.WriteLine("List of connected camers:");
                foreach (Camera cam in cameras)
                {
                    Console.WriteLine(cam.Info.szDeviceDescription);
                }
                if (cameras.Count > 0)
                {
                    CameraHandler.OpenSession(cameras[0]);
                    Console.WriteLine("Opened session with camera: " + cameras[0].Info.szDeviceDescription);
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    CameraHandler.CameraAdded += handler_CameraAdded;
                    CallEvent();
                }

                CameraHandler.ImageSaveDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);

                //create a buffer in memory to capture images
                uint memory_alloc_error = EDSDK.EdsCreateMemoryStream(buffer_size, out frame_stream);

                img_array = new int[1, 1];

                matlab = new MLApp.MLApp();

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return 0;
            }

            //MTB Initiailization Protocol
            INIT:
            try
            {
                m_MTBConnection = new MTBConnection(); //establish a connection to the MTB server
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Try again?(y/n): "); //connection unsuccessful
                string command = Console.ReadLine();
                switch (command)
                {
                    case "y":
                        goto INIT;
                    default:
                        return 0;
                }
            }

            // no ID yet
            m_ID = "";

            // create event sink helper class for base events
            baseEvents = new MTBBaseEventSink();

            // connect event handler with helper class
            baseEvents.MTBErrorEvent += new MTBBaseErrorHandler(OnMtbError);

            return 1;
        }
        static void initialize()
        {
            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;
                CameraHandler.SDKObjectEvent += handler_SDKObjectEvent;
                List<Camera> cameras = CameraHandler.GetCameraList();
                Console.WriteLine("List of connected camers:");
                foreach (Camera cam in cameras)
                {
                    Console.WriteLine(cam.Info.szDeviceDescription);
                }
                if (cameras.Count > 0)
                {
                    CameraHandler.OpenSession(cameras[0]);
                    Console.WriteLine("Opened session with camera: " + cameras[0].Info.szDeviceDescription);
                }
                else
                {
                    Console.WriteLine("No camera found. Please plug in camera");
                    CameraHandler.CameraAdded += handler_CameraAdded;
                    CallEvent();
                }

                CameraHandler.ImageSaveDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);

                //create a buffer in memory to capture images
                uint memory_alloc_error = EDSDK.EdsCreateMemoryStream(buffer_size, out frame_stream);

                img_array = new int[1,1];

                matlab = new MLApp.MLApp();

                /*
                Console.WriteLine("Taking photo with current settings...");
                CameraHandler.TakePhoto();

                CallEvent();
                Console.WriteLine("Photo taken and saved");

                 */
            }
            catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); }
        }
        public ImageProcessor()
        {
            Cameras = new ObservableCollection<EDSDKLib.Camera>();

            CameraHandler = new SDKHandler();
        }
Exemple #34
0
        private void StartLiveViewCaptureBtn(object sender, RoutedEventArgs e)
        {
            ToggleCaptureBtn(false);

            try
            {
                CameraHandler = new SDKHandler();
                CameraHandler.LiveViewUpdated += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CamList = CameraHandler.GetCameraList();
                CameraHandler.OpenSession(CamList[0]);
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
                CameraHandler.SetCapacity();
                Console.WriteLine(Environment.UserName);
                CameraHandler.ImageSaveDirectory = imageDirectory;
                SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
            }
            catch (DllNotFoundException) { ReportError("Canon DLLs not found!", true); }
            catch (Exception ex) { ReportError(ex.Message, true); }

            LiveViewController();

        }
Exemple #35
0
 public void OnReqPayOrderReturn(Msg msg, string orderid, int sdkCode, int productId, string sdkProductId, int productNum, float price, string currency, SDKHandler sdkHandler)
 {
     logReport.OnLogReport("reqPayOrderReturn,save oder,order id:" + orderid);
     sdkHandler.DoPay(msg, orderid, sdkCode, productId, sdkProductId, productNum, price, OnSDKPayReturn);
 }
Exemple #36
0
 public CameraController(SDKHandler sdkHandler, Form1 mainForm)
 {
     this.CameraHandler = sdkHandler;
     this.MainForm      = mainForm;
 }
Exemple #37
0
 public void ReqPay(int sdkCode, int productId, string sdkProductId, int productNum, float price, string currency, SDKHandler sdkHandler, ReqPayOrderReturn reqPayOrderReturn)
 {
     ReqPay(sdkCode, null, productId, sdkProductId, productNum, price, currency, sdkHandler, reqPayOrderReturn);
 }
Exemple #38
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            for (int i = 0; i < this.FTextureOutput.SliceCount; i++)
            {
                if (this.FTextureOutput[i] == null)
                {
                    this.FTextureOutput[i] = new DX11Resource <DX11DynamicTexture2D>();
                }
            }

            if (!init)
            {
                CameraHandler = new SDKHandler();

                CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
                CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
                CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;

                EnumManager.UpdateEnum("Tv", "None", new string[] { "None" });
                EnumManager.UpdateEnum("Av", "None", new string[] { "None" });
                EnumManager.UpdateEnum("ISO", "None", new string[] { "None" });

                init = true;
            }

            if (FInUpdate[0])
            {
                Refresh();
            }

            if (FInEnable.IsChanged)
            {
                if (FInEnable[0] && !CameraHandler.CameraSessionOpen)
                {
                    FLogger.Log(LogType.Debug, "OpenSession"); OpenSession(); isChanged = true;
                }
                if (!FInEnable[0] && CameraHandler.CameraSessionOpen)
                {
                    FLogger.Log(LogType.Debug, "CloseSession"); CloseSession();
                }
            }


            if (CameraHandler.CameraSessionOpen)
            {
                if (FInAv.IsChanged || isChanged)
                {
                    if (FInAv[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV(FInAv[0].Name));
                    }
                }

                if (FInTv.IsChanged || isChanged)
                {
                    if (FInTv[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(FInTv[0].Name));
                    }
                }

                if (FInISO.IsChanged || isChanged)
                {
                    if (FInISO[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(FInISO[0].Name));
                    }
                }

                if (FInFocusSpeed.IsChanged || isChanged)
                {
                    if (FInFocusSpeed[0] != DriveFocus.None)
                    {
                        switch (FInFocusSpeed[0])
                        {
                        case DriveFocus.Far1: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far1); break;

                        case DriveFocus.Far2: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far2); break;

                        case DriveFocus.Far3: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far3); break;

                        case DriveFocus.Near1: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near1); break;

                        case DriveFocus.Near2: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near2); break;

                        case DriveFocus.Near3: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near3); break;
                        }
                    }
                }

                if (FInWB.IsChanged || isChanged)
                {
                    if (FInWB[0] != WB.None)
                    {
                        switch (FInWB[0])
                        {
                        case WB.Auto: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Auto); break;

                        case WB.Daylight: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Daylight); break;

                        case WB.Cloudy: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Cloudy); break;

                        case WB.Tangsten: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Tangsten); break;

                        case WB.Fluorescent: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Fluorescent); break;

                        case WB.Strobe: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Strobe); break;

                        case WB.WhitePaper: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_WhitePaper); break;

                        case WB.Shade: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Shade); break;
                        }
                    }
                }

                if (FInSaveTo.IsChanged || FInSavePath.IsChanged || isChanged)
                {
                    if (FInSaveTo[0] == SaveTo.Camera)
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Camera);
                    }
                    else
                    {
                        if (FInSaveTo[0] == SaveTo.Computer)
                        {
                            CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);
                        }
                        else if (FInSaveTo[0] == SaveTo.Both)
                        {
                            CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
                        }
                        CameraHandler.SetCapacity();

                        try
                        {
                            Directory.CreateDirectory(FInSavePath[0]);
                            CameraHandler.ImageSaveDirectory = FInSavePath[0];
                        }
                        catch (Exception e)
                        {
                            FOutError[0] = e.Message;
                        }
                    }
                }

                if (FInSavePath.IsChanged || isChanged)
                {
                    CameraHandler.ImageSaveDirectory = FInSavePath[0];
                    //CameraHandler.ImageSaveDirectory = "C:\\VVVV\\";
                }

                if (FInTakeVideo.IsChanged || isChanged)
                {
                    if (FInTakeVideo[0] && !CameraHandler.IsFilming)
                    {
                        if (FInSaveTo[0] == SaveTo.Computer || FInSaveTo[0] == SaveTo.Both)
                        {
                            Directory.CreateDirectory(FInSavePath[0]);
                            CameraHandler.StartFilming(FInSavePath[0]);
                        }
                        else
                        {
                            CameraHandler.StartFilming();
                        }
                    }

                    else if (!FInTakeVideo[0] && CameraHandler.IsFilming)
                    {
                        CameraHandler.StopFilming();
                    }
                }

                if (FInForceFocus[0] || FInFocusMode.IsChanged || isChanged)
                {
                    //CameraHandler.SetAFMode((uint)(FInFocusMode[0]-1));
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                    CameraHandler.SetSetting(EDSDK.PropID_Evf_AFMode, (uint)(FInFocusMode[0]));
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_ON);
                }

                if (FInTakePhoto[0])
                {
                    if (FInTv[0].Name.Equals("Bulb"))
                    {
                        CameraHandler.TakePhoto((uint)FInBulb[0]);
                    }
                    else
                    {
                        if (FInUseAutofocus[0]) // manual
                        {
                            CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                            CameraHandler.TakePhoto();
                        }
                        else                         // auto
                        {
                            CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                            CameraHandler.TakePhotoShutterButton();
                        }
                    }
                }

                if (FInLiveView.IsChanged || isChanged)
                {
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);

                    if (FInLiveView[0] && !CameraHandler.IsLiveViewOn)
                    {
                        FLogger.Log(LogType.Debug, "StartLiveView"); CameraHandler.StartLiveView();
                    }
                    if (!FInLiveView[0] && CameraHandler.IsLiveViewOn)
                    {
                        FLogger.Log(LogType.Debug, "StopLiveView"); CameraHandler.StopLiveView();
                    }
                }

                isChanged = false;
            }

            if (CameraHandler.Error != EDSDK.EDS_ERR_OK)
            {
                FOutError[0] = Enum.GetName(typeof(EDSDKError), 0x081) + " (0x" + CameraHandler.Error.ToString("X") + ")";
            }

            FOutSaved[0] = saved;
            if (saved)
            {
                saved = false;
            }

            //FLogger.Log(LogType.Debug, "hi tty!");
        }
Exemple #39
0
        public void ReqPay(int sdkCode, string sdkUid, int productId, string sdkProductId, int productNum, float price, string currency, SDKHandler sdkHandler, ReqPayOrderReturn reqPayOrderReturn)
        {
            Msg reqOrder = new Msg(GameSrvCodeMap.Cmd.CMD_PAY_REQ);

            reqOrder.AddParam(GameSrvCodeMap.Param.PAY_PRODUCT_ID, productId);
            if (sdkUid != null)
            {
                reqOrder.AddParam(GameSrvCodeMap.Param.PAY_SDK_UID, sdkUid);
            }
            reqOrder.AddParam(GameSrvCodeMap.Param.PAY_PRODUCT_NUM, productNum);
            reqOrder.AddParam(GameSrvCodeMap.Param.PAY_PRICE, price);
            reqOrder.AddParam(GameSrvCodeMap.Param.PAY_SDK_CODE, sdkCode);
            reqOrder.AddParam(GameSrvCodeMap.Param.PAY_CURRENCY, currency);
            logReport.OnLogReport("req order->sdkCode:" + sdkCode + ",productId:" + productId + ",sdkProductId:" + sdkProductId + ",productNum:" + productNum + ",currency:" + currency);
            NetService.getInstance().GameSrvClient.Send(reqOrder, new PaymentCmdCallbackWraper(this, sdkCode, productId, sdkProductId, productNum, price, currency, sdkHandler, reqPayOrderReturn, null));
        }