// InitializeCamera() opens the camera session via the canon sdk wrapper, sets the right modes and starts the live view image feed private bool InitializeCamera(Camera camera) { try { CameraWrapper.OpenSession(camera); Console.Write("Done.\nAdjusting settings..."); CameraWrapper.SetSetting(EDSDK.PropID_Av, CameraValues.AV(Settings.Av)); CameraWrapper.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(Settings.Tv)); CameraWrapper.SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO(Settings.ISO)); CameraWrapper.SetSetting(EDSDK.PropID_WhiteBalance, (uint)Settings.WB); Console.Write("Done.\nStarting LiveView..."); LiveViewUpdating = false; CameraWrapper.StartLiveView(); if (CameraWrapper.IsLiveViewOn) { Console.WriteLine("Done."); return(true); } Console.WriteLine("Error!\n-> LiveView dit not start for some reason."); } catch (Exception e) { Console.WriteLine("Error!\n-> " + e.Message); } return(false); }
private void OpenSession() { if (FInDeviceID[0] >= 0) { Refresh(); if (CamList.Count > 0) { CameraHandler.OpenSession(CamList[FInDeviceID[0]]); string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription; FOutError[0] = (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Mamual) ? "Camera is not in manual mode. Some features might not work!" : ""; FOutName.SliceCount = 1; FOutPort.SliceCount = 1; FOutName[0] = CamList[FInDeviceID[0]].Info.szDeviceDescription; FOutPort[0] = CamList[FInDeviceID[0]].Info.szPortName; TvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv); AvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av); ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed); List <string> tv = new List <string>(); List <string> av = new List <string>(); List <string> iso = new List <string>(); tv.Add("None"); av.Add("None"); iso.Add("None"); foreach (int Tv in TvList) { tv.Add(CameraValues.TV((uint)Tv)); } foreach (int Av in AvList) { av.Add(CameraValues.AV((uint)Av)); } foreach (int ISO in ISOList) { iso.Add(CameraValues.ISO((uint)ISO)); } EnumManager.UpdateEnum("Tv", tv[0], tv.ToArray()); EnumManager.UpdateEnum("Av", av[0], av.ToArray()); EnumManager.UpdateEnum("ISO", iso[0], iso.ToArray()); //isChanged = true; } else { FOutError[0] = ""; FOutName.SliceCount = 0; FOutPort.SliceCount = 0; } } }
private void OpenSession() { if (CameraListBox.SelectedIndex >= 0) { camera_connected = true; CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]); SessionButton.Text = "Close Session"; string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription; SessionLabel.Text = cameraname; if (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Manual) { MessageBox.Show("Camera is not in manual mode. Some features might not work!"); } AvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av); TvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv); ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed); foreach (int Av in AvList) { AvCoBox.Items.Add(CameraValues.AV((uint)Av)); } foreach (int Tv in TvList) { TvCoBox.Items.Add(CameraValues.TV((uint)Tv)); } foreach (int ISO in ISOList) { ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO)); } AvCoBox.SelectedIndex = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av))); TvCoBox.SelectedIndex = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv))); ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed))); int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance); switch (wbidx) { case EDSDK.WhiteBalance_Auto: WBCoBox.SelectedIndex = 0; break; case EDSDK.WhiteBalance_Daylight: WBCoBox.SelectedIndex = 1; break; case EDSDK.WhiteBalance_Cloudy: WBCoBox.SelectedIndex = 2; break; case EDSDK.WhiteBalance_Tangsten: WBCoBox.SelectedIndex = 3; break; case EDSDK.WhiteBalance_Fluorescent: WBCoBox.SelectedIndex = 4; break; case EDSDK.WhiteBalance_Strobe: WBCoBox.SelectedIndex = 5; break; case EDSDK.WhiteBalance_WhitePaper: WBCoBox.SelectedIndex = 6; break; case EDSDK.WhiteBalance_Shade: WBCoBox.SelectedIndex = 7; break; default: WBCoBox.SelectedIndex = -1; break; } SettingsGroupBox.Enabled = true; LiveViewGroupBox.Enabled = true; this.STComputerButton.Select(); } }
private void AvCoBox_SelectedIndexChanged(object sender, EventArgs e) { try { CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV((string)AvCoBox.SelectedItem)); } catch (Exception ex) { ReportError(ex.Message, false); } this.serial_lost_focus(this.serial_number, EventArgs.Empty); }
private void AvCoBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (AvCoBox.SelectedIndex < 0) { return; } CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV((string)AvCoBox.SelectedItem)); } catch (Exception ex) { ReportError(ex.Message, false); } }
/** * 打开会话 */ public void OpenSession() { LiveViewGroupBox.Enabled = true; //如果当前相机里表中有选中项,则打开 if (CameraListBox.SelectedIndex >= 0) { //利用相机的驱动打开选中的相机 CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]); //CameraHandler.OpenSession(null); //设置会话按钮 SessionButton.Text = "关闭会话"; SessionLabel.Text = CameraHandler.MainCamera.Info.szDeviceDescription; AvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av); TvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv); ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed); foreach (int Av in AvList) { AvCoBox.Items.Add(CameraValues.AV((uint)Av)); } foreach (int Tv in TvList) { TvCoBox.Items.Add(CameraValues.TV((uint)Tv)); } foreach (int ISO in ISOList) { ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO)); } AvCoBox.SelectedIndex = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av))); TvCoBox.SelectedIndex = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv))); ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed))); int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance); WBCoBox.SelectedIndex = (wbidx > 8) ? wbidx - 1 : wbidx; try { WBUpDo.Value = CameraHandler.GetSetting((uint)EDSDK.PropID_ColorTemperature); } catch (Exception e) { } SettingsGroupBox.Enabled = true; LiveViewGroupBox.Enabled = true; } }
//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!"); }
private void AvCoBox_SelectedIndexChanged(object sender, EventArgs e) { CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV((string)AvCoBox.SelectedItem)); }
private void OpenSession() { if (CameraListBox.SelectedIndex >= 0) { CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]); string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription; SessionLabel.Text = cameraname; try { if (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Manual) { MessageBox.Show("相机不在手动模式(manual mode)!"); } } catch { MessageBox.Show("连接相机出错。请重试。"); return; } AvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av); TvList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv); ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed); foreach (int Av in AvList) { AvCoBox.Items.Add(CameraValues.AV((uint)Av)); } foreach (int Tv in TvList) { TvCoBox.Items.Add(CameraValues.TV((uint)Tv)); } foreach (int ISO in ISOList) { ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO)); } AvCoBox.SelectedIndex = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av))); TvCoBox.SelectedIndex = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv))); ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed))); int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance); switch (wbidx) { case EDSDK.WhiteBalance_Auto: WBCoBox.SelectedIndex = 0; break; case EDSDK.WhiteBalance_Daylight: WBCoBox.SelectedIndex = 1; break; case EDSDK.WhiteBalance_Cloudy: WBCoBox.SelectedIndex = 2; break; case EDSDK.WhiteBalance_Tangsten: WBCoBox.SelectedIndex = 3; break; case EDSDK.WhiteBalance_Fluorescent: WBCoBox.SelectedIndex = 4; break; case EDSDK.WhiteBalance_Strobe: WBCoBox.SelectedIndex = 5; break; case EDSDK.WhiteBalance_WhitePaper: WBCoBox.SelectedIndex = 6; break; case EDSDK.WhiteBalance_Shade: WBCoBox.SelectedIndex = 7; break; default: WBCoBox.SelectedIndex = -1; break; } SettingsGroupBox.Enabled = true; LiveViewGroupBox.Enabled = true; LiveViewButton.Enabled = true; cameraConnectFlag = true; updateRecordReadyControls(); //if (recordReadyFlag) // TakePhotoButton.Enabled = true; //added to initialize save-to options at session opening CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both); CameraHandler.SetCapacity(); SessionButton.Enabled = false; RefreshButton.Enabled = false; //SessionButton.Text = "断开相机"; } }