AdjustCameraControl.cs 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PaintDotNet.Base.SettingModel;
  11. using System.Collections;
  12. using PaintDotNet.ImageCollect.CameraManager;
  13. using TUCAMAPI;
  14. using TUCamera;
  15. using OpenCvSharp;
  16. using System.Threading;
  17. using OpenCvSharp.Extensions;
  18. namespace PaintDotNet.Setting.LabelComponent
  19. {
  20. /// <summary>
  21. /// 相机设置,调节界面
  22. /// </summary>
  23. public class AdjustCameraControl : UserControl
  24. {
  25. #region 控件
  26. private Label label5;
  27. private TrackBar lightTBar;
  28. private TrackBar ExposureTBar;
  29. private GroupBox groupBox1;
  30. private Label label6;
  31. private GroupBox groupBox2;
  32. private GroupBox groupBox3;
  33. private CheckBox xianshiColourCheckBox;
  34. private Button button5;
  35. private Button button4;
  36. private Button button3;
  37. private Button button2;
  38. private TrackBar blueChannelTB;
  39. private Label label9;
  40. private Label label8;
  41. private TrackBar greenChannelTB;
  42. private Label label7;
  43. private TrackBar redChannelTB;
  44. private Label label12;
  45. private Label label11;
  46. private Label label10;
  47. private GroupBox groupBox4;
  48. private Label label13;
  49. private Label lblBaoGuangMaxVal;
  50. private Label lblBaoGuangMinVal;
  51. private Label label3;
  52. private Label label4;
  53. private TextBox ExposureBox;
  54. private TextBox LightBox;
  55. private PictureBox lanlvpictureBox;
  56. private PictureBox lansepictureBox;
  57. private PictureBox huangsepictureBox;
  58. private PictureBox lvsepictureBox;
  59. private PictureBox yanghongsepictureBox;
  60. private PictureBox hongsepictureBox;
  61. private Label lblSaturationMinVal;
  62. private TextBox baoheduTBox;
  63. private Label lblSaturationMaxVal;
  64. private TrackBar baoheduTBar;
  65. /// <summary>
  66. /// 增益值下拉选
  67. /// </summary>
  68. string[] gainArray = new string[] { PdnResources.GetString("Menu.Highgai.Text"), PdnResources.GetString("Menu.Lowgain.Text") };
  69. /// <summary>
  70. /// 相机参数的Model
  71. /// </summary>
  72. private CameraParamModel m_cameraParamModel;
  73. private CheckBox checkBoxAutoExposure;
  74. private bool m_immediately;
  75. private bool m_toAddExtraButtons = false;
  76. private TUCamera.TUCamera m_camera;
  77. private Label lblGainMin;
  78. private Label lblGainMax;
  79. private TrackBar trbGain;
  80. private TextBox txtGain;
  81. private Button button1;
  82. private Button btnAutoExposureOnce;
  83. private Button button6;
  84. private Button button7;
  85. private Label unitLabel;
  86. private System.Timers.Timer m_Timer;
  87. #endregion
  88. public AdjustCameraControl(CameraParamModel model, bool immediately, bool toAddExtraButtons = false)
  89. {
  90. m_cameraParamModel = model;
  91. m_immediately = immediately;
  92. m_toAddExtraButtons = toAddExtraButtons;
  93. m_camera = TUCameraManager.GetInstance().GetCurrentCamera();
  94. InitializeComponent();
  95. InitializeLanguageText();
  96. InitColorAdjustRange();
  97. InitializeControlData();
  98. }
  99. public void ResetCameraParamModel(CameraParamModel model)
  100. {
  101. m_cameraParamModel = model;
  102. InitColorAdjustRange();
  103. InitializeControlData();
  104. }
  105. int resolution_width = 2448;
  106. int resolution_height = 2048;
  107. private void InitColorAdjustRange()
  108. {
  109. if (m_camera.IsOpen())
  110. {
  111. // 曝光时间
  112. double aeMinVal = 0;
  113. double aeMaxVal = 0;
  114. double aeDftVal = 0;
  115. m_camera.GetExposureTimeRange(ref aeMinVal, ref aeMaxVal, ref aeDftVal);
  116. SetExposureBarRange(aeMinVal, aeMaxVal);
  117. lblBaoGuangMinVal.Text = ((int)aeMinVal).ToString() + "μs";
  118. lblBaoGuangMaxVal.Text = UpdateExposureTime((UInt64)aeMaxVal);
  119. // Get red channel range
  120. int minVal = 0;
  121. int maxVal = 0;
  122. m_camera.GetColorChannelRang(ColorChannel.RED, ref minVal, ref maxVal);
  123. redChannelTB.SetRange(minVal, maxVal);
  124. // Get green channel range
  125. m_camera.GetColorChannelRang(ColorChannel.GREEN, ref minVal, ref maxVal);
  126. greenChannelTB.SetRange(minVal, maxVal);
  127. // Get blue channel range
  128. m_camera.GetColorChannelRang(ColorChannel.BLUE, ref minVal, ref maxVal);
  129. blueChannelTB.SetRange(minVal, maxVal);
  130. // Get gain range
  131. TUCAM_PROP_ATTR attrProp;
  132. attrProp = m_camera.GetGlobalGainRange();
  133. trbGain.SetRange((int)attrProp.dbValMin, (int)attrProp.dbValMax);
  134. lblGainMin.Text = trbGain.Minimum.ToString();
  135. lblGainMax.Text = trbGain.Maximum.ToString();
  136. // 饱和度
  137. minVal = 0;
  138. maxVal = 0;
  139. m_camera.GetSaturationRange(ref minVal, ref maxVal);
  140. baoheduTBar.SetRange(minVal, maxVal);
  141. lblSaturationMinVal.Text = ((int)minVal).ToString();
  142. lblSaturationMaxVal.Text = ((int)maxVal).ToString();
  143. var bitmap = m_camera.OneShoot();
  144. if (bitmap == null) return;
  145. showHistImg(BitmapConverter.ToMat(bitmap));
  146. }
  147. }
  148. Mat[] oldHists = new Mat[] { new Mat(), new Mat(), new Mat() };
  149. private void showHistImg(Mat BoxMat)
  150. {
  151. Mat[] mats = Cv2.Split(BoxMat);//一张图片,将panda拆分成3个图片装进mat
  152. if (mats.Count() == 1)
  153. {
  154. Mat[] mats011 = new Mat[] { mats[0] };//panda的第一个通道,也就是B
  155. int[] channels011 = new int[] { 0 };//一个通道,初始化为通道0,这些东西可以共用设置一个就行
  156. int[] histsize11 = new int[] { 256 };//一个通道,初始化为256箱子
  157. Rangef[] range11 = new Rangef[1];//一个通道,范围
  158. range11[0].Start = 0.0F;//从0开始(含)
  159. range11[0].End = 256.0F;//到256结束(不含)
  160. Mat mask11 = new Mat();//不做掩码
  161. Cv2.CalcHist(mats011, channels011, mask11, oldHists[0], 1, histsize11, range11);//对被拆分的图片单独进行计算
  162. return;
  163. }
  164. Mat[] mats0 = new Mat[] { mats[0] };//panda的第一个通道,也就是B
  165. Mat[] mats1 = new Mat[] { mats[1] };//panda的第二个通道,也就是G
  166. Mat[] mats2 = new Mat[] { mats[2] };//panda的第三个通道,也就是R
  167. int[] channels0 = new int[] { 0 };//一个通道,初始化为通道0,这些东西可以共用设置一个就行
  168. int[] channels1 = new int[] { 0 };
  169. int[] channels2 = new int[] { 0 };
  170. int[] histsize = new int[] { 256 };//一个通道,初始化为256箱子
  171. Rangef[] range = new Rangef[1];//一个通道,范围
  172. range[0].Start = 0.0F;//从0开始(含)
  173. range[0].End = 256.0F;//到256结束(不含)
  174. Mat mask = new Mat();//不做掩码
  175. Cv2.CalcHist(mats0, channels0, mask, oldHists[0], 1, histsize, range);//对被拆分的图片单独进行计算
  176. Cv2.CalcHist(mats1, channels1, mask, oldHists[1], 1, histsize, range);//对被拆分的图片单独进行计算
  177. Cv2.CalcHist(mats2, channels2, mask, oldHists[2], 1, histsize, range);//对被拆分的图片单独进行计算
  178. }
  179. private string UpdateExposureTime(UInt64 exposureTime)
  180. {
  181. string str = "";
  182. int sec = 0;
  183. int msec = 0;
  184. int usec = 0;
  185. m_camera.UpdateExposureTime(ref sec, ref msec, ref usec, exposureTime);
  186. if (sec > 0)
  187. {
  188. str += sec + "s";
  189. }
  190. else if (msec > 0)
  191. {
  192. str += msec + "ms";
  193. }
  194. else if (usec > 0)
  195. {
  196. str += usec + "μs";
  197. }
  198. return str;
  199. }
  200. private void UpdateExposureUI(int autoExposure)
  201. {
  202. m_Timer.Enabled = autoExposure == 1;
  203. if (autoExposure == 1)
  204. {
  205. checkBoxAutoExposure.Checked = true;
  206. ExposureTBar.Enabled = false;
  207. ExposureBox.Enabled = false;
  208. trbGain.Enabled = false;
  209. txtGain.Enabled = false;
  210. m_camera.SetExposureMode(ExposureMode.AUTO);
  211. }
  212. else
  213. {
  214. checkBoxAutoExposure.Checked = false;
  215. ExposureTBar.Enabled = true;
  216. ExposureBox.Enabled = true;
  217. trbGain.Enabled = true;
  218. txtGain.Enabled = true;
  219. m_camera.SetExposureMode(ExposureMode.MANUAL);
  220. }
  221. }
  222. /// <summary>
  223. /// 设置下拉等数据源
  224. /// </summary>
  225. private void InitializeControlData()
  226. {
  227. m_Timer = new System.Timers.Timer(1000);
  228. m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerAutoExposure);
  229. m_Timer.AutoReset = true;
  230. m_Timer.SynchronizingObject = this;
  231. // 曝光时间
  232. int value = (int)(m_cameraParamModel.parame.LNExposure);
  233. SetExposureBarValue(value);
  234. DisplayExposureText(value);
  235. // 曝光百分比
  236. value = m_cameraParamModel.parame.Light;
  237. value = value < 0 ? 0 : value > 255 ? 255 : value;
  238. lightTBar.Value = value;
  239. LightBox.Text = value.ToString();
  240. UpdateExposureUI(m_cameraParamModel.parame.ATExposure);
  241. // 增益值调整
  242. int gainValue = m_cameraParamModel.parame.GlobalGain;
  243. if (gainValue >= this.trbGain.Minimum && gainValue <= this.trbGain.Maximum)
  244. {
  245. this.trbGain.Value = gainValue;
  246. txtGain.Text = gainValue.ToString();
  247. }
  248. // 颜色值
  249. int redChannelValue = (int)m_cameraParamModel.parame.RedChannel;
  250. if (redChannelValue >= this.redChannelTB.Minimum && redChannelValue <= this.redChannelTB.Maximum)
  251. {
  252. this.redChannelTB.Value = redChannelValue;
  253. }
  254. int greenChannelValue = (int)m_cameraParamModel.parame.GreenChannel;
  255. if (greenChannelValue >= this.greenChannelTB.Minimum && greenChannelValue <= this.greenChannelTB.Maximum)
  256. {
  257. this.greenChannelTB.Value = greenChannelValue;
  258. }
  259. int blueChannelValue = (int)m_cameraParamModel.parame.BlueChannel;
  260. if (blueChannelValue >= this.blueChannelTB.Minimum && blueChannelValue <= this.blueChannelTB.Maximum)
  261. {
  262. this.blueChannelTB.Value = blueChannelValue;
  263. }
  264. // 白平衡
  265. if (m_cameraParamModel.parame.WhiteBalance == 1)
  266. {
  267. AutoWhiteBalance(true);
  268. }
  269. else
  270. {
  271. if (m_cameraParamModel.parame.FMExposure == 1)
  272. {
  273. m_camera.SetColorTemperatureByString("3200K");
  274. }
  275. else if (m_cameraParamModel.parame.FMExposure == 2)
  276. {
  277. m_camera.SetColorTemperatureByString("5500K");
  278. }
  279. AutoWhiteBalance(false);
  280. }
  281. // 显示颜色值通道
  282. if (m_cameraParamModel.parame.ShowColorPBoxFlag == 1)
  283. {
  284. this.xianshiColourCheckBox.Checked = true;
  285. }
  286. else
  287. {
  288. this.xianshiColourCheckBox.Checked = false;
  289. }
  290. // 饱和度
  291. int baoheduTBarValue = this.m_cameraParamModel.parame.Saturation;
  292. if (baoheduTBarValue >= this.baoheduTBar.Minimum && baoheduTBarValue <= this.baoheduTBar.Maximum)
  293. {
  294. this.baoheduTBar.Value = this.m_cameraParamModel.parame.Saturation;
  295. }
  296. if (m_toAddExtraButtons)
  297. {
  298. this.button6.Visible = true;
  299. this.button7.Visible = true;
  300. }
  301. }
  302. private void InitializeLanguageText()
  303. {
  304. this.label5.Text = PdnResources.GetString("Menu.timeofexposure.text") + ":";
  305. this.groupBox1.Text = PdnResources.GetString("Menu.timeofexposure.text");
  306. this.btnAutoExposureOnce.Text = PdnResources.GetString("Menu.Oneautomaticexposure.Text");
  307. this.checkBoxAutoExposure.Text = PdnResources.GetString("Menu.auto-exposure.text");
  308. this.label6.Text = PdnResources.GetString("Menu.Exposurepercentage.text") + ":";
  309. this.groupBox2.Text = PdnResources.GetString("Menu.Gainvalueadjustment.text");
  310. this.groupBox3.Text = PdnResources.GetString("Menu.Image.WhiteBalance.Text");
  311. this.button1.Text = PdnResources.GetString("Menu.Primarywhitebalance.Text");
  312. this.label12.Text = PdnResources.GetString("Menu.Blue.text");
  313. this.label11.Text = PdnResources.GetString("Menu.green.text");
  314. this.label10.Text = PdnResources.GetString("Menu.red.text");
  315. this.label9.Text = PdnResources.GetString("Menu.yellow.text");
  316. this.label8.Text = PdnResources.GetString("Menu.Magenta.text");
  317. this.label7.Text = PdnResources.GetString("Menu.aqua.text");
  318. this.xianshiColourCheckBox.Text = PdnResources.GetString("Menu.Displaycolorvaluechannel.text");
  319. this.button3.Text = PdnResources.GetString("Menu.auto.text");
  320. this.button2.Text = PdnResources.GetString("Menu.Manual.text");
  321. this.groupBox4.Text = PdnResources.GetString("Menu.Colorandsaturation.Text");
  322. this.label13.Text = PdnResources.GetString("Menu.saturation.text") + ":";
  323. }
  324. private void InitializeComponent()
  325. {
  326. this.label5 = new System.Windows.Forms.Label();
  327. this.lightTBar = new System.Windows.Forms.TrackBar();
  328. this.ExposureTBar = new System.Windows.Forms.TrackBar();
  329. this.groupBox1 = new System.Windows.Forms.GroupBox();
  330. this.unitLabel = new System.Windows.Forms.Label();
  331. this.btnAutoExposureOnce = new System.Windows.Forms.Button();
  332. this.checkBoxAutoExposure = new System.Windows.Forms.CheckBox();
  333. this.ExposureBox = new System.Windows.Forms.TextBox();
  334. this.LightBox = new System.Windows.Forms.TextBox();
  335. this.label3 = new System.Windows.Forms.Label();
  336. this.label4 = new System.Windows.Forms.Label();
  337. this.lblBaoGuangMaxVal = new System.Windows.Forms.Label();
  338. this.lblBaoGuangMinVal = new System.Windows.Forms.Label();
  339. this.label6 = new System.Windows.Forms.Label();
  340. this.groupBox2 = new System.Windows.Forms.GroupBox();
  341. this.txtGain = new System.Windows.Forms.TextBox();
  342. this.lblGainMin = new System.Windows.Forms.Label();
  343. this.lblGainMax = new System.Windows.Forms.Label();
  344. this.trbGain = new System.Windows.Forms.TrackBar();
  345. this.groupBox3 = new System.Windows.Forms.GroupBox();
  346. this.button6 = new System.Windows.Forms.Button();
  347. this.button7 = new System.Windows.Forms.Button();
  348. this.button1 = new System.Windows.Forms.Button();
  349. this.lansepictureBox = new System.Windows.Forms.PictureBox();
  350. this.huangsepictureBox = new System.Windows.Forms.PictureBox();
  351. this.lvsepictureBox = new System.Windows.Forms.PictureBox();
  352. this.yanghongsepictureBox = new System.Windows.Forms.PictureBox();
  353. this.hongsepictureBox = new System.Windows.Forms.PictureBox();
  354. this.lanlvpictureBox = new System.Windows.Forms.PictureBox();
  355. this.label12 = new System.Windows.Forms.Label();
  356. this.label11 = new System.Windows.Forms.Label();
  357. this.label10 = new System.Windows.Forms.Label();
  358. this.blueChannelTB = new System.Windows.Forms.TrackBar();
  359. this.label9 = new System.Windows.Forms.Label();
  360. this.label8 = new System.Windows.Forms.Label();
  361. this.greenChannelTB = new System.Windows.Forms.TrackBar();
  362. this.label7 = new System.Windows.Forms.Label();
  363. this.redChannelTB = new System.Windows.Forms.TrackBar();
  364. this.xianshiColourCheckBox = new System.Windows.Forms.CheckBox();
  365. this.button5 = new System.Windows.Forms.Button();
  366. this.button4 = new System.Windows.Forms.Button();
  367. this.button3 = new System.Windows.Forms.Button();
  368. this.button2 = new System.Windows.Forms.Button();
  369. this.groupBox4 = new System.Windows.Forms.GroupBox();
  370. this.lblSaturationMinVal = new System.Windows.Forms.Label();
  371. this.baoheduTBox = new System.Windows.Forms.TextBox();
  372. this.label13 = new System.Windows.Forms.Label();
  373. this.lblSaturationMaxVal = new System.Windows.Forms.Label();
  374. this.baoheduTBar = new System.Windows.Forms.TrackBar();
  375. ((System.ComponentModel.ISupportInitialize)(this.lightTBar)).BeginInit();
  376. ((System.ComponentModel.ISupportInitialize)(this.ExposureTBar)).BeginInit();
  377. this.groupBox1.SuspendLayout();
  378. this.groupBox2.SuspendLayout();
  379. ((System.ComponentModel.ISupportInitialize)(this.trbGain)).BeginInit();
  380. this.groupBox3.SuspendLayout();
  381. ((System.ComponentModel.ISupportInitialize)(this.lansepictureBox)).BeginInit();
  382. ((System.ComponentModel.ISupportInitialize)(this.huangsepictureBox)).BeginInit();
  383. ((System.ComponentModel.ISupportInitialize)(this.lvsepictureBox)).BeginInit();
  384. ((System.ComponentModel.ISupportInitialize)(this.yanghongsepictureBox)).BeginInit();
  385. ((System.ComponentModel.ISupportInitialize)(this.hongsepictureBox)).BeginInit();
  386. ((System.ComponentModel.ISupportInitialize)(this.lanlvpictureBox)).BeginInit();
  387. ((System.ComponentModel.ISupportInitialize)(this.blueChannelTB)).BeginInit();
  388. ((System.ComponentModel.ISupportInitialize)(this.greenChannelTB)).BeginInit();
  389. ((System.ComponentModel.ISupportInitialize)(this.redChannelTB)).BeginInit();
  390. this.groupBox4.SuspendLayout();
  391. ((System.ComponentModel.ISupportInitialize)(this.baoheduTBar)).BeginInit();
  392. this.SuspendLayout();
  393. //
  394. // label5
  395. //
  396. this.label5.AutoSize = true;
  397. this.label5.Location = new System.Drawing.Point(18, 31);
  398. this.label5.Name = "label5";
  399. this.label5.Size = new System.Drawing.Size(59, 12);
  400. this.label5.TabIndex = 12;
  401. this.label5.Text = "曝光时间:";
  402. //
  403. // lightTBar
  404. //
  405. this.lightTBar.Location = new System.Drawing.Point(89, 66);
  406. this.lightTBar.Maximum = 255;
  407. this.lightTBar.Name = "lightTBar";
  408. this.lightTBar.Size = new System.Drawing.Size(274, 45);
  409. this.lightTBar.TabIndex = 13;
  410. this.lightTBar.TickStyle = System.Windows.Forms.TickStyle.None;
  411. this.lightTBar.Value = 64;
  412. this.lightTBar.Scroll += new System.EventHandler(this.Light_ValueChanged);
  413. //
  414. // ExposureTBar
  415. //
  416. this.ExposureTBar.Location = new System.Drawing.Point(89, 31);
  417. this.ExposureTBar.Maximum = 148;
  418. this.ExposureTBar.Name = "ExposureTBar";
  419. this.ExposureTBar.Size = new System.Drawing.Size(274, 45);
  420. this.ExposureTBar.TabIndex = 14;
  421. this.ExposureTBar.TickStyle = System.Windows.Forms.TickStyle.None;
  422. this.ExposureTBar.Scroll += new System.EventHandler(this.Exposure_ValueChanged);
  423. //
  424. // groupBox1
  425. //
  426. this.groupBox1.Controls.Add(this.unitLabel);
  427. this.groupBox1.Controls.Add(this.btnAutoExposureOnce);
  428. this.groupBox1.Controls.Add(this.checkBoxAutoExposure);
  429. this.groupBox1.Controls.Add(this.ExposureBox);
  430. this.groupBox1.Controls.Add(this.LightBox);
  431. this.groupBox1.Controls.Add(this.label3);
  432. this.groupBox1.Controls.Add(this.label4);
  433. this.groupBox1.Controls.Add(this.lblBaoGuangMaxVal);
  434. this.groupBox1.Controls.Add(this.lblBaoGuangMinVal);
  435. this.groupBox1.Controls.Add(this.label6);
  436. this.groupBox1.Controls.Add(this.label5);
  437. this.groupBox1.Controls.Add(this.lightTBar);
  438. this.groupBox1.Controls.Add(this.ExposureTBar);
  439. this.groupBox1.Location = new System.Drawing.Point(13, 14);
  440. this.groupBox1.Name = "groupBox1";
  441. this.groupBox1.Size = new System.Drawing.Size(464, 154);
  442. this.groupBox1.TabIndex = 15;
  443. this.groupBox1.TabStop = false;
  444. this.groupBox1.Text = "曝光时间";
  445. //
  446. // unitLabel
  447. //
  448. this.unitLabel.AutoSize = true;
  449. this.unitLabel.Location = new System.Drawing.Point(429, 37);
  450. this.unitLabel.Name = "unitLabel";
  451. this.unitLabel.Size = new System.Drawing.Size(41, 12);
  452. this.unitLabel.TabIndex = 37;
  453. this.unitLabel.Text = "label1";
  454. //
  455. // btnAutoExposureOnce
  456. //
  457. this.btnAutoExposureOnce.Location = new System.Drawing.Point(122, 111);
  458. this.btnAutoExposureOnce.Margin = new System.Windows.Forms.Padding(2);
  459. this.btnAutoExposureOnce.Name = "btnAutoExposureOnce";
  460. this.btnAutoExposureOnce.Size = new System.Drawing.Size(102, 25);
  461. this.btnAutoExposureOnce.TabIndex = 36;
  462. this.btnAutoExposureOnce.Text = "一次自动曝光";
  463. this.btnAutoExposureOnce.UseVisualStyleBackColor = true;
  464. this.btnAutoExposureOnce.Click += new System.EventHandler(this.btnAutoExposureOnce_Click);
  465. //
  466. // checkBoxAutoExposure
  467. //
  468. this.checkBoxAutoExposure.AutoSize = true;
  469. this.checkBoxAutoExposure.Location = new System.Drawing.Point(21, 117);
  470. this.checkBoxAutoExposure.Margin = new System.Windows.Forms.Padding(2);
  471. this.checkBoxAutoExposure.Name = "checkBoxAutoExposure";
  472. this.checkBoxAutoExposure.Size = new System.Drawing.Size(72, 16);
  473. this.checkBoxAutoExposure.TabIndex = 34;
  474. this.checkBoxAutoExposure.Text = "自动曝光";
  475. this.checkBoxAutoExposure.UseVisualStyleBackColor = true;
  476. this.checkBoxAutoExposure.Click += new System.EventHandler(this.checkBoxAutoExposure_CheckedChanged);
  477. //
  478. // ExposureBox
  479. //
  480. this.ExposureBox.Location = new System.Drawing.Point(370, 31);
  481. this.ExposureBox.Name = "ExposureBox";
  482. this.ExposureBox.Size = new System.Drawing.Size(55, 21);
  483. this.ExposureBox.TabIndex = 31;
  484. this.ExposureBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.baoGuangTBox_KeyPress);
  485. //
  486. // LightBox
  487. //
  488. this.LightBox.Location = new System.Drawing.Point(371, 66);
  489. this.LightBox.Name = "LightBox";
  490. this.LightBox.Size = new System.Drawing.Size(55, 21);
  491. this.LightBox.TabIndex = 30;
  492. this.LightBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.baoGuangPertBox_KeyPress);
  493. //
  494. // label3
  495. //
  496. this.label3.AutoSize = true;
  497. this.label3.Location = new System.Drawing.Point(327, 91);
  498. this.label3.Name = "label3";
  499. this.label3.Size = new System.Drawing.Size(23, 12);
  500. this.label3.TabIndex = 22;
  501. this.label3.Text = "255";
  502. //
  503. // label4
  504. //
  505. this.label4.AutoSize = true;
  506. this.label4.Location = new System.Drawing.Point(93, 91);
  507. this.label4.Name = "label4";
  508. this.label4.Size = new System.Drawing.Size(11, 12);
  509. this.label4.TabIndex = 21;
  510. this.label4.Text = "0";
  511. //
  512. // lblBaoGuangMaxVal
  513. //
  514. this.lblBaoGuangMaxVal.AutoSize = true;
  515. this.lblBaoGuangMaxVal.Location = new System.Drawing.Point(321, 53);
  516. this.lblBaoGuangMaxVal.Name = "lblBaoGuangMaxVal";
  517. this.lblBaoGuangMaxVal.Size = new System.Drawing.Size(35, 12);
  518. this.lblBaoGuangMaxVal.TabIndex = 20;
  519. this.lblBaoGuangMaxVal.Text = "1000s";
  520. //
  521. // lblBaoGuangMinVal
  522. //
  523. this.lblBaoGuangMinVal.AutoSize = true;
  524. this.lblBaoGuangMinVal.Location = new System.Drawing.Point(93, 53);
  525. this.lblBaoGuangMinVal.Name = "lblBaoGuangMinVal";
  526. this.lblBaoGuangMinVal.Size = new System.Drawing.Size(41, 12);
  527. this.lblBaoGuangMinVal.TabIndex = 19;
  528. this.lblBaoGuangMinVal.Text = "250μs";
  529. //
  530. // label6
  531. //
  532. this.label6.AutoSize = true;
  533. this.label6.Location = new System.Drawing.Point(18, 66);
  534. this.label6.Name = "label6";
  535. this.label6.Size = new System.Drawing.Size(35, 12);
  536. this.label6.TabIndex = 15;
  537. this.label6.Text = "亮度:";
  538. //
  539. // groupBox2
  540. //
  541. this.groupBox2.Controls.Add(this.txtGain);
  542. this.groupBox2.Controls.Add(this.lblGainMin);
  543. this.groupBox2.Controls.Add(this.lblGainMax);
  544. this.groupBox2.Controls.Add(this.trbGain);
  545. this.groupBox2.Location = new System.Drawing.Point(13, 182);
  546. this.groupBox2.Name = "groupBox2";
  547. this.groupBox2.Size = new System.Drawing.Size(464, 84);
  548. this.groupBox2.TabIndex = 16;
  549. this.groupBox2.TabStop = false;
  550. this.groupBox2.Text = "增益值调整";
  551. //
  552. // txtGain
  553. //
  554. this.txtGain.Location = new System.Drawing.Point(369, 21);
  555. this.txtGain.Name = "txtGain";
  556. this.txtGain.Size = new System.Drawing.Size(55, 21);
  557. this.txtGain.TabIndex = 36;
  558. this.txtGain.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtGain_KeyPress);
  559. //
  560. // lblGainMin
  561. //
  562. this.lblGainMin.AutoSize = true;
  563. this.lblGainMin.Location = new System.Drawing.Point(97, 54);
  564. this.lblGainMin.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  565. this.lblGainMin.Name = "lblGainMin";
  566. this.lblGainMin.Size = new System.Drawing.Size(11, 12);
  567. this.lblGainMin.TabIndex = 17;
  568. this.lblGainMin.Text = "0";
  569. //
  570. // lblGainMax
  571. //
  572. this.lblGainMax.AutoSize = true;
  573. this.lblGainMax.Location = new System.Drawing.Point(340, 54);
  574. this.lblGainMax.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
  575. this.lblGainMax.Name = "lblGainMax";
  576. this.lblGainMax.Size = new System.Drawing.Size(23, 12);
  577. this.lblGainMax.TabIndex = 16;
  578. this.lblGainMax.Text = "255";
  579. //
  580. // trbGain
  581. //
  582. this.trbGain.Location = new System.Drawing.Point(89, 21);
  583. this.trbGain.Maximum = 255;
  584. this.trbGain.Name = "trbGain";
  585. this.trbGain.Size = new System.Drawing.Size(280, 45);
  586. this.trbGain.TabIndex = 15;
  587. this.trbGain.TickStyle = System.Windows.Forms.TickStyle.None;
  588. this.trbGain.Value = 10;
  589. this.trbGain.Scroll += new System.EventHandler(this.trbGain_ValueChanged);
  590. this.trbGain.ValueChanged += new System.EventHandler(this.trbGain_ValueChanged);
  591. //
  592. // groupBox3
  593. //
  594. this.groupBox3.Controls.Add(this.button6);
  595. this.groupBox3.Controls.Add(this.button7);
  596. this.groupBox3.Controls.Add(this.button1);
  597. this.groupBox3.Controls.Add(this.lansepictureBox);
  598. this.groupBox3.Controls.Add(this.huangsepictureBox);
  599. this.groupBox3.Controls.Add(this.lvsepictureBox);
  600. this.groupBox3.Controls.Add(this.yanghongsepictureBox);
  601. this.groupBox3.Controls.Add(this.hongsepictureBox);
  602. this.groupBox3.Controls.Add(this.lanlvpictureBox);
  603. this.groupBox3.Controls.Add(this.label12);
  604. this.groupBox3.Controls.Add(this.label11);
  605. this.groupBox3.Controls.Add(this.label10);
  606. this.groupBox3.Controls.Add(this.blueChannelTB);
  607. this.groupBox3.Controls.Add(this.label9);
  608. this.groupBox3.Controls.Add(this.label8);
  609. this.groupBox3.Controls.Add(this.greenChannelTB);
  610. this.groupBox3.Controls.Add(this.label7);
  611. this.groupBox3.Controls.Add(this.redChannelTB);
  612. this.groupBox3.Controls.Add(this.xianshiColourCheckBox);
  613. this.groupBox3.Controls.Add(this.button5);
  614. this.groupBox3.Controls.Add(this.button4);
  615. this.groupBox3.Controls.Add(this.button3);
  616. this.groupBox3.Controls.Add(this.button2);
  617. this.groupBox3.Location = new System.Drawing.Point(13, 283);
  618. this.groupBox3.Name = "groupBox3";
  619. this.groupBox3.Size = new System.Drawing.Size(464, 211);
  620. this.groupBox3.TabIndex = 17;
  621. this.groupBox3.TabStop = false;
  622. this.groupBox3.Text = "白平衡";
  623. //
  624. // button6
  625. //
  626. this.button6.Location = new System.Drawing.Point(105, 58);
  627. this.button6.Name = "button6";
  628. this.button6.Size = new System.Drawing.Size(75, 23);
  629. this.button6.TabIndex = 39;
  630. this.button6.Text = "原图取色";
  631. this.button6.UseVisualStyleBackColor = true;
  632. this.button6.Visible = false;
  633. this.button6.Click += new System.EventHandler(this.button6_Click);
  634. //
  635. // button7
  636. //
  637. this.button7.Location = new System.Drawing.Point(20, 58);
  638. this.button7.Name = "button7";
  639. this.button7.Size = new System.Drawing.Size(75, 23);
  640. this.button7.TabIndex = 38;
  641. this.button7.Text = "区域选择";
  642. this.button7.UseVisualStyleBackColor = true;
  643. this.button7.Visible = false;
  644. this.button7.Click += new System.EventHandler(this.button7_Click);
  645. //
  646. // button1
  647. //
  648. this.button1.Location = new System.Drawing.Point(191, 29);
  649. this.button1.Name = "button1";
  650. this.button1.Size = new System.Drawing.Size(75, 23);
  651. this.button1.TabIndex = 37;
  652. this.button1.Text = "一次白平衡";
  653. this.button1.UseVisualStyleBackColor = true;
  654. this.button1.Click += new System.EventHandler(this.button1_Click);
  655. //
  656. // lansepictureBox
  657. //
  658. this.lansepictureBox.BackColor = System.Drawing.Color.Blue;
  659. this.lansepictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  660. this.lansepictureBox.Location = new System.Drawing.Point(412, 175);
  661. this.lansepictureBox.Name = "lansepictureBox";
  662. this.lansepictureBox.Size = new System.Drawing.Size(12, 12);
  663. this.lansepictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  664. this.lansepictureBox.TabIndex = 36;
  665. this.lansepictureBox.TabStop = false;
  666. //
  667. // huangsepictureBox
  668. //
  669. this.huangsepictureBox.BackColor = System.Drawing.Color.Yellow;
  670. this.huangsepictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  671. this.huangsepictureBox.Location = new System.Drawing.Point(33, 175);
  672. this.huangsepictureBox.Name = "huangsepictureBox";
  673. this.huangsepictureBox.Size = new System.Drawing.Size(12, 12);
  674. this.huangsepictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  675. this.huangsepictureBox.TabIndex = 35;
  676. this.huangsepictureBox.TabStop = false;
  677. //
  678. // lvsepictureBox
  679. //
  680. this.lvsepictureBox.BackColor = System.Drawing.Color.Lime;
  681. this.lvsepictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  682. this.lvsepictureBox.Location = new System.Drawing.Point(412, 145);
  683. this.lvsepictureBox.Name = "lvsepictureBox";
  684. this.lvsepictureBox.Size = new System.Drawing.Size(12, 12);
  685. this.lvsepictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  686. this.lvsepictureBox.TabIndex = 34;
  687. this.lvsepictureBox.TabStop = false;
  688. //
  689. // yanghongsepictureBox
  690. //
  691. this.yanghongsepictureBox.BackColor = System.Drawing.Color.Fuchsia;
  692. this.yanghongsepictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  693. this.yanghongsepictureBox.Location = new System.Drawing.Point(33, 145);
  694. this.yanghongsepictureBox.Name = "yanghongsepictureBox";
  695. this.yanghongsepictureBox.Size = new System.Drawing.Size(12, 12);
  696. this.yanghongsepictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  697. this.yanghongsepictureBox.TabIndex = 33;
  698. this.yanghongsepictureBox.TabStop = false;
  699. //
  700. // hongsepictureBox
  701. //
  702. this.hongsepictureBox.BackColor = System.Drawing.Color.Red;
  703. this.hongsepictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  704. this.hongsepictureBox.Location = new System.Drawing.Point(412, 116);
  705. this.hongsepictureBox.Name = "hongsepictureBox";
  706. this.hongsepictureBox.Size = new System.Drawing.Size(12, 12);
  707. this.hongsepictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  708. this.hongsepictureBox.TabIndex = 32;
  709. this.hongsepictureBox.TabStop = false;
  710. //
  711. // lanlvpictureBox
  712. //
  713. this.lanlvpictureBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
  714. this.lanlvpictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  715. this.lanlvpictureBox.Location = new System.Drawing.Point(33, 116);
  716. this.lanlvpictureBox.Name = "lanlvpictureBox";
  717. this.lanlvpictureBox.Size = new System.Drawing.Size(12, 12);
  718. this.lanlvpictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  719. this.lanlvpictureBox.TabIndex = 31;
  720. this.lanlvpictureBox.TabStop = false;
  721. //
  722. // label12
  723. //
  724. this.label12.AutoSize = true;
  725. this.label12.Location = new System.Drawing.Point(368, 175);
  726. this.label12.Name = "label12";
  727. this.label12.Size = new System.Drawing.Size(29, 12);
  728. this.label12.TabIndex = 30;
  729. this.label12.Text = "蓝色";
  730. //
  731. // label11
  732. //
  733. this.label11.AutoSize = true;
  734. this.label11.Location = new System.Drawing.Point(368, 145);
  735. this.label11.Name = "label11";
  736. this.label11.Size = new System.Drawing.Size(29, 12);
  737. this.label11.TabIndex = 29;
  738. this.label11.Text = "绿色";
  739. //
  740. // label10
  741. //
  742. this.label10.AutoSize = true;
  743. this.label10.Location = new System.Drawing.Point(368, 116);
  744. this.label10.Name = "label10";
  745. this.label10.Size = new System.Drawing.Size(29, 12);
  746. this.label10.TabIndex = 28;
  747. this.label10.Text = "红色";
  748. //
  749. // blueChannelTB
  750. //
  751. this.blueChannelTB.Location = new System.Drawing.Point(104, 175);
  752. this.blueChannelTB.Maximum = 1366;
  753. this.blueChannelTB.Name = "blueChannelTB";
  754. this.blueChannelTB.Size = new System.Drawing.Size(246, 45);
  755. this.blueChannelTB.TabIndex = 27;
  756. this.blueChannelTB.TickStyle = System.Windows.Forms.TickStyle.None;
  757. this.blueChannelTB.ValueChanged += new System.EventHandler(this.blueChannelTB_ValueChanged);
  758. //
  759. // label9
  760. //
  761. this.label9.AutoSize = true;
  762. this.label9.Location = new System.Drawing.Point(58, 175);
  763. this.label9.Name = "label9";
  764. this.label9.Size = new System.Drawing.Size(29, 12);
  765. this.label9.TabIndex = 26;
  766. this.label9.Text = "黄色";
  767. //
  768. // label8
  769. //
  770. this.label8.AutoSize = true;
  771. this.label8.Location = new System.Drawing.Point(58, 145);
  772. this.label8.Name = "label8";
  773. this.label8.Size = new System.Drawing.Size(29, 12);
  774. this.label8.TabIndex = 25;
  775. this.label8.Text = "洋红";
  776. //
  777. // greenChannelTB
  778. //
  779. this.greenChannelTB.Location = new System.Drawing.Point(104, 145);
  780. this.greenChannelTB.Maximum = 1366;
  781. this.greenChannelTB.Name = "greenChannelTB";
  782. this.greenChannelTB.Size = new System.Drawing.Size(246, 45);
  783. this.greenChannelTB.TabIndex = 24;
  784. this.greenChannelTB.TickStyle = System.Windows.Forms.TickStyle.None;
  785. this.greenChannelTB.Scroll += new System.EventHandler(this.greenChannelTB_Scroll);
  786. //
  787. // label7
  788. //
  789. this.label7.AutoSize = true;
  790. this.label7.Location = new System.Drawing.Point(58, 116);
  791. this.label7.Name = "label7";
  792. this.label7.Size = new System.Drawing.Size(29, 12);
  793. this.label7.TabIndex = 23;
  794. this.label7.Text = "青色";
  795. //
  796. // redChannelTB
  797. //
  798. this.redChannelTB.Location = new System.Drawing.Point(104, 116);
  799. this.redChannelTB.Maximum = 1366;
  800. this.redChannelTB.Name = "redChannelTB";
  801. this.redChannelTB.Size = new System.Drawing.Size(246, 45);
  802. this.redChannelTB.TabIndex = 22;
  803. this.redChannelTB.TickStyle = System.Windows.Forms.TickStyle.None;
  804. this.redChannelTB.ValueChanged += new System.EventHandler(this.redChannelTB_ValueChanged);
  805. //
  806. // xianshiColourCheckBox
  807. //
  808. this.xianshiColourCheckBox.AutoSize = true;
  809. this.xianshiColourCheckBox.Checked = true;
  810. this.xianshiColourCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
  811. this.xianshiColourCheckBox.Location = new System.Drawing.Point(20, 87);
  812. this.xianshiColourCheckBox.Name = "xianshiColourCheckBox";
  813. this.xianshiColourCheckBox.Size = new System.Drawing.Size(108, 16);
  814. this.xianshiColourCheckBox.TabIndex = 21;
  815. this.xianshiColourCheckBox.Text = "显示颜色值通道";
  816. this.xianshiColourCheckBox.UseVisualStyleBackColor = true;
  817. this.xianshiColourCheckBox.CheckedChanged += new System.EventHandler(this.xianshiColourCheckBox_CheckedChanged);
  818. //
  819. // button5
  820. //
  821. this.button5.Location = new System.Drawing.Point(362, 29);
  822. this.button5.Name = "button5";
  823. this.button5.Size = new System.Drawing.Size(75, 23);
  824. this.button5.TabIndex = 20;
  825. this.button5.Text = "5500K";
  826. this.button5.UseVisualStyleBackColor = true;
  827. this.button5.Click += new System.EventHandler(this.button5_Click);
  828. //
  829. // button4
  830. //
  831. this.button4.Location = new System.Drawing.Point(277, 29);
  832. this.button4.Name = "button4";
  833. this.button4.Size = new System.Drawing.Size(75, 23);
  834. this.button4.TabIndex = 19;
  835. this.button4.Text = "3200K";
  836. this.button4.UseVisualStyleBackColor = true;
  837. this.button4.Click += new System.EventHandler(this.button4_Click);
  838. //
  839. // button3
  840. //
  841. this.button3.Location = new System.Drawing.Point(106, 29);
  842. this.button3.Name = "button3";
  843. this.button3.Size = new System.Drawing.Size(75, 23);
  844. this.button3.TabIndex = 18;
  845. this.button3.Text = "自动";
  846. this.button3.UseVisualStyleBackColor = true;
  847. this.button3.Click += new System.EventHandler(this.button3_Click);
  848. //
  849. // button2
  850. //
  851. this.button2.Location = new System.Drawing.Point(20, 29);
  852. this.button2.Name = "button2";
  853. this.button2.Size = new System.Drawing.Size(75, 23);
  854. this.button2.TabIndex = 17;
  855. this.button2.Text = "手动";
  856. this.button2.UseVisualStyleBackColor = true;
  857. this.button2.Click += new System.EventHandler(this.button2_Click);
  858. //
  859. // groupBox4
  860. //
  861. this.groupBox4.Controls.Add(this.lblSaturationMinVal);
  862. this.groupBox4.Controls.Add(this.baoheduTBox);
  863. this.groupBox4.Controls.Add(this.label13);
  864. this.groupBox4.Controls.Add(this.lblSaturationMaxVal);
  865. this.groupBox4.Controls.Add(this.baoheduTBar);
  866. this.groupBox4.Location = new System.Drawing.Point(13, 510);
  867. this.groupBox4.Name = "groupBox4";
  868. this.groupBox4.Size = new System.Drawing.Size(464, 81);
  869. this.groupBox4.TabIndex = 18;
  870. this.groupBox4.TabStop = false;
  871. this.groupBox4.Text = "色彩和饱和度";
  872. //
  873. // lblSaturationMinVal
  874. //
  875. this.lblSaturationMinVal.AutoSize = true;
  876. this.lblSaturationMinVal.Location = new System.Drawing.Point(99, 53);
  877. this.lblSaturationMinVal.Name = "lblSaturationMinVal";
  878. this.lblSaturationMinVal.Size = new System.Drawing.Size(29, 12);
  879. this.lblSaturationMinVal.TabIndex = 33;
  880. this.lblSaturationMinVal.Text = "-1.0";
  881. //
  882. // baoheduTBox
  883. //
  884. this.baoheduTBox.Location = new System.Drawing.Point(389, 28);
  885. this.baoheduTBox.Name = "baoheduTBox";
  886. this.baoheduTBox.Size = new System.Drawing.Size(55, 21);
  887. this.baoheduTBox.TabIndex = 35;
  888. this.baoheduTBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.baoheduTBox_KeyPress);
  889. //
  890. // label13
  891. //
  892. this.label13.AutoSize = true;
  893. this.label13.Location = new System.Drawing.Point(18, 28);
  894. this.label13.Name = "label13";
  895. this.label13.Size = new System.Drawing.Size(53, 12);
  896. this.label13.TabIndex = 24;
  897. this.label13.Text = "饱和度:";
  898. //
  899. // lblSaturationMaxVal
  900. //
  901. this.lblSaturationMaxVal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  902. this.lblSaturationMaxVal.AutoSize = true;
  903. this.lblSaturationMaxVal.Location = new System.Drawing.Point(333, 53);
  904. this.lblSaturationMaxVal.Name = "lblSaturationMaxVal";
  905. this.lblSaturationMaxVal.RightToLeft = System.Windows.Forms.RightToLeft.No;
  906. this.lblSaturationMaxVal.Size = new System.Drawing.Size(23, 12);
  907. this.lblSaturationMaxVal.TabIndex = 34;
  908. this.lblSaturationMaxVal.Text = "1.0";
  909. this.lblSaturationMaxVal.TextAlign = System.Drawing.ContentAlignment.TopRight;
  910. //
  911. // baoheduTBar
  912. //
  913. this.baoheduTBar.Location = new System.Drawing.Point(95, 28);
  914. this.baoheduTBar.Maximum = 20;
  915. this.baoheduTBar.Name = "baoheduTBar";
  916. this.baoheduTBar.Size = new System.Drawing.Size(274, 45);
  917. this.baoheduTBar.TabIndex = 32;
  918. this.baoheduTBar.TickStyle = System.Windows.Forms.TickStyle.None;
  919. this.baoheduTBar.Value = 10;
  920. this.baoheduTBar.ValueChanged += new System.EventHandler(this.baoheduTBar_ValueChanged);
  921. this.baoheduTBar.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TBar_MouseWheel);
  922. //
  923. // AdjustCameraControl
  924. //
  925. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  926. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  927. this.Controls.Add(this.groupBox4);
  928. this.Controls.Add(this.groupBox3);
  929. this.Controls.Add(this.groupBox2);
  930. this.Controls.Add(this.groupBox1);
  931. this.Name = "AdjustCameraControl";
  932. this.Size = new System.Drawing.Size(490, 605);
  933. ((System.ComponentModel.ISupportInitialize)(this.lightTBar)).EndInit();
  934. ((System.ComponentModel.ISupportInitialize)(this.ExposureTBar)).EndInit();
  935. this.groupBox1.ResumeLayout(false);
  936. this.groupBox1.PerformLayout();
  937. this.groupBox2.ResumeLayout(false);
  938. this.groupBox2.PerformLayout();
  939. ((System.ComponentModel.ISupportInitialize)(this.trbGain)).EndInit();
  940. this.groupBox3.ResumeLayout(false);
  941. this.groupBox3.PerformLayout();
  942. ((System.ComponentModel.ISupportInitialize)(this.lansepictureBox)).EndInit();
  943. ((System.ComponentModel.ISupportInitialize)(this.huangsepictureBox)).EndInit();
  944. ((System.ComponentModel.ISupportInitialize)(this.lvsepictureBox)).EndInit();
  945. ((System.ComponentModel.ISupportInitialize)(this.yanghongsepictureBox)).EndInit();
  946. ((System.ComponentModel.ISupportInitialize)(this.hongsepictureBox)).EndInit();
  947. ((System.ComponentModel.ISupportInitialize)(this.lanlvpictureBox)).EndInit();
  948. ((System.ComponentModel.ISupportInitialize)(this.blueChannelTB)).EndInit();
  949. ((System.ComponentModel.ISupportInitialize)(this.greenChannelTB)).EndInit();
  950. ((System.ComponentModel.ISupportInitialize)(this.redChannelTB)).EndInit();
  951. this.groupBox4.ResumeLayout(false);
  952. this.groupBox4.PerformLayout();
  953. ((System.ComponentModel.ISupportInitialize)(this.baoheduTBar)).EndInit();
  954. this.ResumeLayout(false);
  955. }
  956. private void TBar_MouseWheel(object sender, MouseEventArgs e)
  957. {
  958. ((HandledMouseEventArgs)e).Handled = true;
  959. }
  960. private bool m_autoExposureComplete;
  961. private int m_exposureTimes = 0;
  962. private double m_exposureValue;
  963. protected override void Dispose(bool disposing = true)
  964. {
  965. m_Timer.Stop();
  966. base.Dispose(disposing);
  967. }
  968. /// <summary>
  969. /// 手动白平衡
  970. /// </summary>
  971. /// <param name="sender"></param>
  972. /// <param name="e"></param>
  973. private void button2_Click(object sender, EventArgs e)
  974. {
  975. m_cameraParamModel.parame.FMExposure = 0;
  976. AutoWhiteBalance(false);
  977. Form form = Application.OpenForms["CameraPreviewDialog"];
  978. if (form != null)
  979. {
  980. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  981. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  982. }
  983. }
  984. /// <summary>
  985. /// 自动白平衡按钮点击
  986. /// </summary>
  987. /// <param name="sender"></param>
  988. /// <param name="e"></param>
  989. private void button3_Click(object sender, EventArgs e)
  990. {
  991. AutoWhiteBalance(true);
  992. Thread.Sleep(1500);
  993. UpdateColorTemperature();
  994. Form form = Application.OpenForms["CameraPreviewDialog"];
  995. if (form != null)
  996. {
  997. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  998. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  999. }
  1000. }
  1001. /// <summary>
  1002. /// 自动白平衡一次
  1003. /// </summary>
  1004. /// <param name="sender"></param>
  1005. /// <param name="e"></param>
  1006. private void button1_Click(object sender, EventArgs e)
  1007. {
  1008. AutoWhiteBalance(true);
  1009. new Task(() =>
  1010. {
  1011. Thread.Sleep(1500);
  1012. m_cameraParamModel.parame.FMExposure = 0;
  1013. AutoWhiteBalance(false);
  1014. Form form = Application.OpenForms["CameraPreviewDialog"];
  1015. if (form != null)
  1016. {
  1017. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1018. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1019. }
  1020. }).Start();
  1021. }
  1022. /// <summary>
  1023. /// 色温3200K
  1024. /// </summary>
  1025. /// <param name="sender"></param>
  1026. /// <param name="e"></param>
  1027. private void button4_Click(object sender, EventArgs e)
  1028. {
  1029. m_cameraParamModel.parame.FMExposure = 1;
  1030. m_camera.SetColorTemperatureByString("3200K");
  1031. AutoWhiteBalance(false);
  1032. Form form = Application.OpenForms["CameraPreviewDialog"];
  1033. if (form != null)
  1034. {
  1035. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1036. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1037. }
  1038. }
  1039. /// <summary>
  1040. /// 色温5500K
  1041. /// </summary>
  1042. /// <param name="sender"></param>
  1043. /// <param name="e"></param>
  1044. private void button5_Click(object sender, EventArgs e)
  1045. {
  1046. m_cameraParamModel.parame.FMExposure = 2;
  1047. m_camera.SetColorTemperatureByString("5500K");
  1048. AutoWhiteBalance(false);
  1049. Form form = Application.OpenForms["CameraPreviewDialog"];
  1050. if (form != null)
  1051. {
  1052. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1053. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1054. }
  1055. }
  1056. private void UpdateColorTemperature()
  1057. {
  1058. button2.Enabled = true;
  1059. button3.Enabled = true;
  1060. button4.Enabled = true;
  1061. button5.Enabled = true;
  1062. uint cct = 0;
  1063. double redChannel = 0;
  1064. double greenChannel = 0;
  1065. double blueChannel = 0;
  1066. m_camera.GetColorTemperature(ref redChannel, ref greenChannel, ref blueChannel, ref cct);
  1067. m_cameraParamModel.parame.RedChannel = redChannel;
  1068. m_cameraParamModel.parame.GreenChannel = greenChannel;
  1069. m_cameraParamModel.parame.BlueChannel = blueChannel;
  1070. // 颜色值
  1071. this.redChannelTB.Value = (int)m_cameraParamModel.parame.RedChannel;
  1072. this.greenChannelTB.Value = (int)m_cameraParamModel.parame.GreenChannel;
  1073. this.blueChannelTB.Value = (int)m_cameraParamModel.parame.BlueChannel;
  1074. //string colorTemperatureString = m_camera.GetColorTemperatureString(cct);
  1075. this.redChannelTB.Enabled = false;
  1076. this.greenChannelTB.Enabled = false;
  1077. this.blueChannelTB.Enabled = false;
  1078. if (m_cameraParamModel.parame.WhiteBalance == 1)
  1079. {
  1080. button3.Enabled = false;
  1081. }
  1082. else
  1083. {
  1084. switch (m_cameraParamModel.parame.FMExposure)
  1085. {
  1086. case 0:
  1087. button2.Enabled = false;
  1088. this.redChannelTB.Enabled = true;
  1089. this.greenChannelTB.Enabled = true;
  1090. this.blueChannelTB.Enabled = true;
  1091. break;
  1092. case 1:
  1093. button4.Enabled = false;
  1094. break;
  1095. case 2:
  1096. button5.Enabled = false;
  1097. break;
  1098. }
  1099. }
  1100. xianshiColourCheckBox.Focus();
  1101. }
  1102. /// <summary>
  1103. /// 是否自动白平衡 修改显示样式
  1104. /// </summary>
  1105. /// <param name="s"></param>
  1106. private void AutoWhiteBalance(Boolean isWhiteBalance)
  1107. {
  1108. if (isWhiteBalance)
  1109. {
  1110. this.redChannelTB.Enabled = false;
  1111. this.greenChannelTB.Enabled = false;
  1112. this.blueChannelTB.Enabled = false;
  1113. m_cameraParamModel.parame.WhiteBalance = 1;
  1114. if (m_immediately)
  1115. {
  1116. // 自动白平衡
  1117. m_camera.SetWhiteBalanceMode(WhiteBalanceMode.AUTO);
  1118. }
  1119. }
  1120. else
  1121. {
  1122. m_cameraParamModel.parame.WhiteBalance = 0;
  1123. if (m_immediately)
  1124. {
  1125. // 手动白平衡
  1126. m_camera.SetWhiteBalanceMode(WhiteBalanceMode.MANUAL);
  1127. }
  1128. }
  1129. UpdateColorTemperature();
  1130. }
  1131. #region 曝光
  1132. double _log = 1.1;
  1133. int _min;
  1134. int _max;
  1135. private int GetExposureBarValue()
  1136. {
  1137. var value = ExposureTBar.Value;
  1138. if (ExposureTBar.Value == ExposureTBar.Minimum) return _min;
  1139. if (ExposureTBar.Value == ExposureTBar.Maximum) return _max;
  1140. return (int)Math.Pow(_log, value);
  1141. }
  1142. private void SetExposureBarValue(double value)
  1143. {
  1144. var ival = (int)Math.Log(Math.Max(_min, value), _log);
  1145. ExposureTBar.Value = Math.Min(ival, ExposureTBar.Maximum);
  1146. }
  1147. private void SetExposureBarRange(double min, double max)
  1148. {
  1149. _min = (int)min;
  1150. ExposureTBar.Minimum = (int)Math.Log(min, _log);
  1151. _max = (int)max;
  1152. ExposureTBar.Maximum = (int)Math.Log(max, _log); ;
  1153. }
  1154. public void OnTimerAutoExposure(object source, System.Timers.ElapsedEventArgs e)
  1155. {
  1156. if (m_autoExposureOnce)
  1157. {
  1158. m_autoExposureComplete = true;
  1159. m_autoExposureOnce = false;
  1160. ExposureTBar.Enabled = true;
  1161. ExposureBox.Enabled = true;
  1162. trbGain.Enabled = true;
  1163. txtGain.Enabled = true;
  1164. m_camera.SetExposureMode(ExposureMode.MANUAL);
  1165. m_Timer.Stop();
  1166. }
  1167. else if (!checkBoxAutoExposure.Checked)
  1168. {
  1169. return;
  1170. }
  1171. double us = m_camera.GetExposureTime() * 1000;
  1172. SetExposureBarValue(us);
  1173. DisplayExposureText((int)us);
  1174. }
  1175. /// <summary>
  1176. /// 曝光百分比滑块滑动事件
  1177. /// </summary>
  1178. /// <param name="sender"></param>
  1179. /// <param name="e"></param>
  1180. private void Light_ValueChanged(object sender, System.EventArgs e)
  1181. {
  1182. m_camera.Light = lightTBar.Value;
  1183. m_cameraParamModel.parame.Light = lightTBar.Value;
  1184. LightBox.Text = lightTBar.Value + "";
  1185. }
  1186. /// <summary>
  1187. /// 曝光时间滑块滑动事件
  1188. /// </summary>
  1189. /// <param name="sender"></param>
  1190. /// <param name="e"></param>
  1191. private void Exposure_ValueChanged(object sender, System.EventArgs e)
  1192. {
  1193. int exposureTimeUSec = GetExposureBarValue();
  1194. this.m_cameraParamModel.parame.LNExposure = exposureTimeUSec;
  1195. DisplayExposureText(exposureTimeUSec);
  1196. m_camera.SetExposureTime((ulong)(exposureTimeUSec));
  1197. }
  1198. private void checkBoxAutoExposure_CheckedChanged(object sender, EventArgs e)
  1199. {
  1200. int autoExposure = checkBoxAutoExposure.Checked ? 1 : 0;
  1201. m_cameraParamModel.parame.ATExposure = autoExposure;
  1202. if (autoExposure == 0)
  1203. {
  1204. Light_ValueChanged(null, null);
  1205. }
  1206. else
  1207. {
  1208. m_autoExposureOnce = false;
  1209. }
  1210. UpdateExposureUI(autoExposure);
  1211. }
  1212. private bool m_autoExposureOnce;
  1213. /// <summary>
  1214. /// 一次自动曝光
  1215. /// </summary>
  1216. /// <param name="sender"></param>
  1217. /// <param name="e"></param>
  1218. private void btnAutoExposureOnce_Click(object sender, EventArgs e)
  1219. {
  1220. if (m_autoExposureComplete && checkBoxAutoExposure.Checked)
  1221. {
  1222. checkBoxAutoExposure.Checked = false;
  1223. }
  1224. else
  1225. {
  1226. if (checkBoxAutoExposure.Checked)
  1227. {
  1228. checkBoxAutoExposure.Checked = false;
  1229. }
  1230. m_autoExposureOnce = true;
  1231. UpdateExposureOnceUI();
  1232. }
  1233. }
  1234. private void UpdateExposureOnceUI()
  1235. {
  1236. m_autoExposureComplete = false;
  1237. ExposureTBar.Enabled = false;
  1238. ExposureBox.Enabled = false;
  1239. trbGain.Enabled = false;
  1240. txtGain.Enabled = false;
  1241. //lightTBar.Value = 64;
  1242. //Light_ValueChanged(null, null);
  1243. // 设置到相机
  1244. if (m_immediately)
  1245. {
  1246. // 自动曝光
  1247. m_camera.SetExposureMode(ExposureMode.AUTO);
  1248. m_Timer.Start();
  1249. }
  1250. }
  1251. /// <summary>
  1252. /// 曝光时间内容输入后校验
  1253. /// </summary>
  1254. /// <param name="sender"></param>
  1255. /// <param name="e"></param>
  1256. private void baoGuangTBox_KeyPress(object sender, KeyPressEventArgs e)
  1257. {
  1258. if (!char.IsDigit(e.KeyChar) && (e.KeyChar != (char)Keys.Enter) && (e.KeyChar != (char)Keys.Back)) // 非数字键, 放弃该输入
  1259. {
  1260. e.Handled = true;
  1261. return;
  1262. }
  1263. if (e.KeyChar == (char)Keys.Enter)
  1264. {
  1265. try
  1266. {
  1267. double value = Convert.ToDouble(ExposureBox.Text);
  1268. switch (unitLabel.Text)
  1269. {
  1270. case "s":
  1271. value = value * 1000 * 1000;
  1272. break;
  1273. case "ms":
  1274. value = value * 1000;
  1275. break;
  1276. }
  1277. SetExposureBarValue(value);
  1278. Exposure_ValueChanged(null, null);
  1279. }
  1280. catch (Exception ex)
  1281. {
  1282. MessageBox.Show(ex.Message);
  1283. }
  1284. }
  1285. }
  1286. private void DisplayExposureText(int exposureTimeUSec)
  1287. {
  1288. decimal txtVale = 0;
  1289. int sec = 0;
  1290. int msec = 0;
  1291. int usec = 0;
  1292. m_camera.UpdateExposureTime(ref sec, ref msec, ref usec, (UInt64)exposureTimeUSec);
  1293. if (sec > 0)
  1294. {
  1295. this.unitLabel.Text = "s";
  1296. txtVale += sec;
  1297. }
  1298. if (msec > 0)
  1299. {
  1300. if (txtVale > 0)
  1301. {
  1302. txtVale += ((decimal)msec / 1000);
  1303. this.unitLabel.Text = "s";
  1304. usec = 0; // 微秒舍掉不显示了
  1305. }
  1306. else
  1307. {
  1308. this.unitLabel.Text = "ms";
  1309. txtVale += msec;
  1310. }
  1311. }
  1312. if (usec > 0)
  1313. {
  1314. if (txtVale > 0)
  1315. {
  1316. txtVale += ((decimal)usec / 1000);
  1317. }
  1318. else
  1319. {
  1320. this.unitLabel.Text = "μs";
  1321. txtVale = usec;
  1322. }
  1323. }
  1324. this.ExposureBox.Text = txtVale.ToString();
  1325. }
  1326. #endregion
  1327. /// <summary>
  1328. /// 饱和度滑块滑动
  1329. /// </summary>
  1330. /// <param name="sender"></param>
  1331. /// <param name="e"></param>
  1332. private void baoheduTBar_ValueChanged(object sender, System.EventArgs e)
  1333. {
  1334. this.m_cameraParamModel.parame.Saturation = this.baoheduTBar.Value;
  1335. //this.baoheduTBox.Text = ((this.baoheduTBar.Value - 10) / 10.0).ToString("0.0");
  1336. this.baoheduTBox.Text = this.baoheduTBar.Value.ToString();
  1337. // 设置到相机
  1338. if (m_immediately)
  1339. {
  1340. m_camera.SetSaturation(this.m_cameraParamModel.parame.Saturation); //usec
  1341. }
  1342. }
  1343. /// <summary>
  1344. /// 显示颜色通道值
  1345. /// </summary>
  1346. /// <param name="sender"></param>
  1347. /// <param name="e"></param>
  1348. private void xianshiColourCheckBox_CheckedChanged(object sender, EventArgs e)
  1349. {
  1350. CheckBox cb = (CheckBox)sender;
  1351. this.yanghongsepictureBox.Visible = cb.Checked;
  1352. this.yanghongsepictureBox.Visible = cb.Checked; ;
  1353. this.lansepictureBox.Visible = cb.Checked;
  1354. this.hongsepictureBox.Visible = cb.Checked;
  1355. this.lansepictureBox.Visible = cb.Checked;
  1356. this.huangsepictureBox.Visible = cb.Checked;
  1357. this.lanlvpictureBox.Visible = cb.Checked;
  1358. this.lvsepictureBox.Visible = cb.Checked;
  1359. this.m_cameraParamModel.parame.ShowColorPBoxFlag = cb.Checked ? 1 : 0;
  1360. }
  1361. private void baoGuangPertBox_KeyPress(object sender, KeyPressEventArgs e)
  1362. {
  1363. if (!char.IsDigit(e.KeyChar) && (e.KeyChar != (char)Keys.Enter) && (e.KeyChar != (char)Keys.Back)) // 非数字键, 放弃该输入
  1364. {
  1365. e.Handled = true;
  1366. return;
  1367. }
  1368. if (e.KeyChar == (char)Keys.Enter)
  1369. {
  1370. try
  1371. {
  1372. int value = Convert.ToInt32(LightBox.Text);
  1373. value = Math.Max(lightTBar.Minimum, value);
  1374. value = Math.Min(lightTBar.Maximum, value);
  1375. lightTBar.Value = value;
  1376. Light_ValueChanged(null, null);
  1377. }
  1378. catch (Exception ex)
  1379. {
  1380. MessageBox.Show(ex.Message);
  1381. }
  1382. }
  1383. }
  1384. private void txtGain_KeyPress(object sender, KeyPressEventArgs e)
  1385. {
  1386. if (!char.IsDigit(e.KeyChar) && (e.KeyChar != (char)Keys.Enter) && (e.KeyChar != (char)Keys.Back)) // 非数字键, 放弃该输入
  1387. {
  1388. e.Handled = true;
  1389. return;
  1390. }
  1391. if (e.KeyChar == (char)Keys.Enter)
  1392. {
  1393. try
  1394. {
  1395. int trbGainVal = Convert.ToInt32(txtGain.Text);
  1396. if (trbGainVal < trbGain.Minimum)
  1397. {
  1398. trbGainVal = trbGain.Minimum;
  1399. }
  1400. if (trbGainVal > trbGain.Maximum)
  1401. {
  1402. trbGainVal = trbGain.Maximum;
  1403. }
  1404. trbGain.Value = trbGainVal;
  1405. }
  1406. catch (Exception ex)
  1407. {
  1408. MessageBox.Show(ex.Message);
  1409. }
  1410. }
  1411. }
  1412. private void redChannelTB_ValueChanged(object sender, EventArgs e)
  1413. {
  1414. Form form = Application.OpenForms["CameraPreviewDialog"];
  1415. if (form != null)
  1416. {
  1417. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1418. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1419. }
  1420. m_cameraParamModel.parame.RedChannel = ((TrackBar)sender).Value;
  1421. // 设置到相机
  1422. if (m_immediately)
  1423. {
  1424. m_camera.SetRedGain(m_cameraParamModel.parame.RedChannel); //usec
  1425. }
  1426. }
  1427. private void greenChannelTB_Scroll(object sender, EventArgs e)
  1428. {
  1429. Form form = Application.OpenForms["CameraPreviewDialog"];
  1430. if (form != null)
  1431. {
  1432. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1433. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1434. }
  1435. m_cameraParamModel.parame.GreenChannel = ((TrackBar)sender).Value;
  1436. // 设置到相机
  1437. if (m_immediately)
  1438. {
  1439. m_camera.SetGreeGain(m_cameraParamModel.parame.GreenChannel); //usec
  1440. }
  1441. }
  1442. private void blueChannelTB_ValueChanged(object sender, EventArgs e)
  1443. {
  1444. Form form = Application.OpenForms["CameraPreviewDialog"];
  1445. if (form != null)
  1446. {
  1447. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1448. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1449. }
  1450. m_cameraParamModel.parame.BlueChannel = ((TrackBar)sender).Value;
  1451. // 设置到相机
  1452. if (m_immediately)
  1453. {
  1454. m_camera.SetBlueGain(m_cameraParamModel.parame.BlueChannel); //usec
  1455. }
  1456. }
  1457. private void trbGain_ValueChanged(object sender, EventArgs e)
  1458. {
  1459. txtGain.Text = trbGain.Value.ToString();
  1460. m_cameraParamModel.parame.GlobalGain = trbGain.Value;
  1461. m_camera.SetGlobalGain(m_cameraParamModel.parame.GlobalGain);
  1462. }
  1463. /// <summary>
  1464. /// 白平衡区域选择
  1465. /// </summary>
  1466. /// <param name="sender"></param>
  1467. /// <param name="e"></param>
  1468. private void button7_Click(object sender, EventArgs e)
  1469. {
  1470. Form form = Application.OpenForms["CameraPreviewDialog"];
  1471. if (form != null)
  1472. {
  1473. ((ImageCollect.CameraPreviewDialog)form).o_use = false;
  1474. ((ImageCollect.CameraPreviewDialog)form).m_use = !((ImageCollect.CameraPreviewDialog)form).m_use;
  1475. }
  1476. }
  1477. /// <summary>
  1478. /// 白平衡原图取色
  1479. /// </summary>
  1480. /// <param name="sender"></param>
  1481. /// <param name="e"></param>
  1482. private void button6_Click(object sender, EventArgs e)
  1483. {
  1484. Form form = Application.OpenForms["CameraPreviewDialog"];
  1485. if (form != null)
  1486. {
  1487. ((ImageCollect.CameraPreviewDialog)form).m_use = false;
  1488. ((ImageCollect.CameraPreviewDialog)form).o_use = !((ImageCollect.CameraPreviewDialog)form).o_use;
  1489. ((ImageCollect.CameraPreviewDialog)form).m_startP = new System.Drawing.Point(-1, -1);
  1490. }
  1491. }
  1492. private void baoheduTBox_KeyPress(object sender, KeyPressEventArgs e)
  1493. {
  1494. if (!char.IsDigit(e.KeyChar) && (e.KeyChar != (char)Keys.Enter) && (e.KeyChar != (char)Keys.Back)) // 非数字键, 放弃该输入
  1495. {
  1496. e.Handled = true;
  1497. return;
  1498. }
  1499. if (e.KeyChar == (char)Keys.Enter)
  1500. {
  1501. try
  1502. {
  1503. int value = Convert.ToInt32(baoheduTBox.Text);
  1504. baoheduTBar.Value = value;
  1505. }
  1506. catch
  1507. {
  1508. baoheduTBox.Text = baoheduTBar.Value + "";
  1509. }
  1510. }
  1511. }
  1512. }
  1513. }