Posted By

leondunn11 on 02/06/15


Tagged

image software circle detect camera usb c# chsarp


Versions (?)

How to develop circle detection in C#


 / Published in: C#
 

URL: http://www.camera-sdk.com/

After searching a lot in this topic, I finally found the perfect solution for circle detection. I used a prewritten C# code that I found on www.camera-sdk.com. To use this code here, you’ll need to have a Visual C# WPF Application that can be created in Visual Studio and you should add VOIPSDK.dll and NVA.dll (both can be found on the webpage) to the references. Now, the first snippet under Form1.Designer.cs is the code for the GUI of the program. The GUI you can implement with this code will help you to be able to manage your program without any troubles. The second snippet is the code for developing the circle detection function itself. The code contains all the details you need for your program. I hope these codes will be useful for you all! Have fun! :)

  1. // Form1.Designer.cs
  2.  
  3. namespace CircleDetection
  4. {
  5. partial class Form1
  6. {
  7. /// <summary>
  8. /// Required designer variable.
  9. /// </summary>
  10. private System.ComponentModel.IContainer components = null;
  11.  
  12. /// <summary>
  13. /// Clean up any resources being used.
  14. /// </summary>
  15. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  16. protected override void Dispose(bool disposing)
  17. {
  18. if (disposing && (components != null))
  19. {
  20. components.Dispose();
  21. }
  22. base.Dispose(disposing);
  23. }
  24.  
  25. #region Windows Form Designer generated code
  26.  
  27. /// <summary>
  28. /// Required method for Designer support - do not modify
  29. /// the contents of this method with the code editor.
  30. /// </summary>
  31. private void InitializeComponent()
  32. {
  33. this.label1 = new System.Windows.Forms.Label();
  34. this.label2 = new System.Windows.Forms.Label();
  35. this.btn_Set = new System.Windows.Forms.Button();
  36. this.tb_AccumulatorResolution = new System.Windows.Forms.TextBox();
  37. this.tb_CannyThreshold = new System.Windows.Forms.TextBox();
  38. this.tb_CircleAccumulatorThreshold = new System.Windows.Forms.TextBox();
  39. this.tb_MaximumRadius = new System.Windows.Forms.TextBox();
  40. this.tb_MinimumDistance = new System.Windows.Forms.TextBox();
  41. this.tb_MinimumRadius = new System.Windows.Forms.TextBox();
  42. this.groupBox1 = new System.Windows.Forms.GroupBox();
  43. this.label6 = new System.Windows.Forms.Label();
  44. this.label5 = new System.Windows.Forms.Label();
  45. this.label8 = new System.Windows.Forms.Label();
  46. this.label4 = new System.Windows.Forms.Label();
  47. this.label3 = new System.Windows.Forms.Label();
  48. this.label7 = new System.Windows.Forms.Label();
  49. this.groupBox2 = new System.Windows.Forms.GroupBox();
  50. this.btn_HighlightSet = new System.Windows.Forms.Button();
  51. this.label11 = new System.Windows.Forms.Label();
  52. this.label10 = new System.Windows.Forms.Label();
  53. this.tb_DrawThickness = new System.Windows.Forms.TextBox();
  54. this.tb_Blue = new System.Windows.Forms.TextBox();
  55. this.chk_ShowImage = new System.Windows.Forms.CheckBox();
  56. this.tb_Green = new System.Windows.Forms.TextBox();
  57. this.tb_Red = new System.Windows.Forms.TextBox();
  58. this.lb_Detection = new System.Windows.Forms.ListBox();
  59. this.label12 = new System.Windows.Forms.Label();
  60. this.groupBox1.SuspendLayout();
  61. this.groupBox2.SuspendLayout();
  62. this.SuspendLayout();
  63. //
  64. // label1
  65. //
  66. this.label1.AutoSize = true;
  67. this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
  68. this.label1.Location = new System.Drawing.Point(30, 265);
  69. this.label1.Name = "label1";
  70. this.label1.Size = new System.Drawing.Size(87, 13);
  71. this.label1.TabIndex = 0;
  72. this.label1.Text = "Original image";
  73. //
  74. // label2
  75. //
  76. this.label2.AutoSize = true;
  77. this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
  78. this.label2.Location = new System.Drawing.Point(370, 265);
  79. this.label2.Name = "label2";
  80. this.label2.Size = new System.Drawing.Size(103, 13);
  81. this.label2.TabIndex = 1;
  82. this.label2.Text = "Processed image";
  83. //
  84. // btn_Set
  85. //
  86. this.btn_Set.Location = new System.Drawing.Point(189, 368);
  87. this.btn_Set.Name = "btn_Set";
  88. this.btn_Set.Size = new System.Drawing.Size(58, 23);
  89. this.btn_Set.TabIndex = 2;
  90. this.btn_Set.Text = "Set";
  91. this.btn_Set.UseVisualStyleBackColor = true;
  92. this.btn_Set.Click += new System.EventHandler(this.btn_Set_Click);
  93. //
  94. // tb_AccumulatorResolution
  95. //
  96. this.tb_AccumulatorResolution.Location = new System.Drawing.Point(153, 26);
  97. this.tb_AccumulatorResolution.Name = "tb_AccumulatorResolution";
  98. this.tb_AccumulatorResolution.Size = new System.Drawing.Size(87, 20);
  99. this.tb_AccumulatorResolution.TabIndex = 3;
  100. //
  101. // tb_CannyThreshold
  102. //
  103. this.tb_CannyThreshold.Location = new System.Drawing.Point(153, 58);
  104. this.tb_CannyThreshold.Name = "tb_CannyThreshold";
  105. this.tb_CannyThreshold.Size = new System.Drawing.Size(87, 20);
  106. this.tb_CannyThreshold.TabIndex = 4;
  107. //
  108. // tb_CircleAccumulatorThreshold
  109. //
  110. this.tb_CircleAccumulatorThreshold.Location = new System.Drawing.Point(153, 90);
  111. this.tb_CircleAccumulatorThreshold.Name = "tb_CircleAccumulatorThreshold";
  112. this.tb_CircleAccumulatorThreshold.Size = new System.Drawing.Size(87, 20);
  113. this.tb_CircleAccumulatorThreshold.TabIndex = 5;
  114. //
  115. // tb_MaximumRadius
  116. //
  117. this.tb_MaximumRadius.Location = new System.Drawing.Point(153, 122);
  118. this.tb_MaximumRadius.Name = "tb_MaximumRadius";
  119. this.tb_MaximumRadius.Size = new System.Drawing.Size(87, 20);
  120. this.tb_MaximumRadius.TabIndex = 6;
  121. //
  122. // tb_MinimumDistance
  123. //
  124. this.tb_MinimumDistance.Location = new System.Drawing.Point(153, 154);
  125. this.tb_MinimumDistance.Name = "tb_MinimumDistance";
  126. this.tb_MinimumDistance.Size = new System.Drawing.Size(87, 20);
  127. this.tb_MinimumDistance.TabIndex = 7;
  128. //
  129. // tb_MinimumRadius
  130. //
  131. this.tb_MinimumRadius.Location = new System.Drawing.Point(153, 186);
  132. this.tb_MinimumRadius.Name = "tb_MinimumRadius";
  133. this.tb_MinimumRadius.Size = new System.Drawing.Size(87, 20);
  134. this.tb_MinimumRadius.TabIndex = 8;
  135. //
  136. // groupBox1
  137. //
  138. this.groupBox1.Controls.Add(this.label6);
  139. this.groupBox1.Controls.Add(this.label5);
  140. this.groupBox1.Controls.Add(this.label8);
  141. this.groupBox1.Controls.Add(this.label4);
  142. this.groupBox1.Controls.Add(this.label3);
  143. this.groupBox1.Controls.Add(this.label7);
  144. this.groupBox1.Controls.Add(this.tb_MaximumRadius);
  145. this.groupBox1.Controls.Add(this.btn_Set);
  146. this.groupBox1.Controls.Add(this.tb_AccumulatorResolution);
  147. this.groupBox1.Controls.Add(this.tb_MinimumDistance);
  148. this.groupBox1.Controls.Add(this.tb_MinimumRadius);
  149. this.groupBox1.Controls.Add(this.tb_CannyThreshold);
  150. this.groupBox1.Controls.Add(this.tb_CircleAccumulatorThreshold);
  151. this.groupBox1.Location = new System.Drawing.Point(679, 176);
  152. this.groupBox1.Name = "groupBox1";
  153. this.groupBox1.Size = new System.Drawing.Size(258, 397);
  154. this.groupBox1.TabIndex = 12;
  155. this.groupBox1.TabStop = false;
  156. this.groupBox1.Text = "Settings";
  157. //
  158. // label6
  159. //
  160. this.label6.AutoSize = true;
  161. this.label6.Location = new System.Drawing.Point(61, 125);
  162. this.label6.Name = "label6";
  163. this.label6.Size = new System.Drawing.Size(87, 13);
  164. this.label6.TabIndex = 13;
  165. this.label6.Text = "MaximumRadius:";
  166. //
  167. // label5
  168. //
  169. this.label5.AutoSize = true;
  170. this.label5.Location = new System.Drawing.Point(6, 93);
  171. this.label5.Name = "label5";
  172. this.label5.Size = new System.Drawing.Size(142, 13);
  173. this.label5.TabIndex = 12;
  174. this.label5.Text = "CircleAccumulatorThreshold:";
  175. //
  176. // label8
  177. //
  178. this.label8.AutoSize = true;
  179. this.label8.Location = new System.Drawing.Point(64, 189);
  180. this.label8.Name = "label8";
  181. this.label8.Size = new System.Drawing.Size(84, 13);
  182. this.label8.TabIndex = 15;
  183. this.label8.Text = "MinimumRadius:";
  184. //
  185. // label4
  186. //
  187. this.label4.AutoSize = true;
  188. this.label4.Location = new System.Drawing.Point(61, 61);
  189. this.label4.Name = "label4";
  190. this.label4.Size = new System.Drawing.Size(87, 13);
  191. this.label4.TabIndex = 11;
  192. this.label4.Text = "CannyThreshold:";
  193. //
  194. // label3
  195. //
  196. this.label3.AutoSize = true;
  197. this.label3.Location = new System.Drawing.Point(29, 29);
  198. this.label3.Name = "label3";
  199. this.label3.Size = new System.Drawing.Size(119, 13);
  200. this.label3.TabIndex = 10;
  201. this.label3.Text = "AccumulatorResolution:";
  202. //
  203. // label7
  204. //
  205. this.label7.AutoSize = true;
  206. this.label7.Location = new System.Drawing.Point(55, 157);
  207. this.label7.Name = "label7";
  208. this.label7.Size = new System.Drawing.Size(93, 13);
  209. this.label7.TabIndex = 14;
  210. this.label7.Text = "MinimumDistance:";
  211. //
  212. // groupBox2
  213. //
  214. this.groupBox2.Controls.Add(this.btn_HighlightSet);
  215. this.groupBox2.Controls.Add(this.label11);
  216. this.groupBox2.Controls.Add(this.label10);
  217. this.groupBox2.Controls.Add(this.tb_DrawThickness);
  218. this.groupBox2.Controls.Add(this.tb_Blue);
  219. this.groupBox2.Controls.Add(this.chk_ShowImage);
  220. this.groupBox2.Controls.Add(this.tb_Green);
  221. this.groupBox2.Controls.Add(this.tb_Red);
  222. this.groupBox2.Location = new System.Drawing.Point(679, 12);
  223. this.groupBox2.Name = "groupBox2";
  224. this.groupBox2.Size = new System.Drawing.Size(258, 158);
  225. this.groupBox2.TabIndex = 13;
  226. this.groupBox2.TabStop = false;
  227. this.groupBox2.Text = "Highlight";
  228. //
  229. // btn_HighlightSet
  230. //
  231. this.btn_HighlightSet.Location = new System.Drawing.Point(189, 129);
  232. this.btn_HighlightSet.Name = "btn_HighlightSet";
  233. this.btn_HighlightSet.Size = new System.Drawing.Size(58, 23);
  234. this.btn_HighlightSet.TabIndex = 19;
  235. this.btn_HighlightSet.Text = "Set";
  236. this.btn_HighlightSet.UseVisualStyleBackColor = true;
  237. this.btn_HighlightSet.Click += new System.EventHandler(this.btn_HighlightSet_Click);
  238. //
  239. // label11
  240. //
  241. this.label11.AutoSize = true;
  242. this.label11.Location = new System.Drawing.Point(64, 97);
  243. this.label11.Name = "label11";
  244. this.label11.Size = new System.Drawing.Size(84, 13);
  245. this.label11.TabIndex = 18;
  246. this.label11.Text = "DrawThickness:";
  247. //
  248. // label10
  249. //
  250. this.label10.AutoSize = true;
  251. this.label10.Location = new System.Drawing.Point(74, 63);
  252. this.label10.Name = "label10";
  253. this.label10.Size = new System.Drawing.Size(33, 13);
  254. this.label10.TabIndex = 17;
  255. this.label10.Text = "RGB:";
  256. //
  257. // tb_DrawThickness
  258. //
  259. this.tb_DrawThickness.Location = new System.Drawing.Point(153, 95);
  260. this.tb_DrawThickness.Name = "tb_DrawThickness";
  261. this.tb_DrawThickness.Size = new System.Drawing.Size(87, 20);
  262. this.tb_DrawThickness.TabIndex = 17;
  263. //
  264. // tb_Blue
  265. //
  266. this.tb_Blue.Location = new System.Drawing.Point(198, 59);
  267. this.tb_Blue.Name = "tb_Blue";
  268. this.tb_Blue.Size = new System.Drawing.Size(42, 20);
  269. this.tb_Blue.TabIndex = 16;
  270. //
  271. // chk_ShowImage
  272. //
  273. this.chk_ShowImage.AutoSize = true;
  274. this.chk_ShowImage.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
  275. this.chk_ShowImage.Location = new System.Drawing.Point(37, 25);
  276. this.chk_ShowImage.Name = "chk_ShowImage";
  277. this.chk_ShowImage.Size = new System.Drawing.Size(85, 17);
  278. this.chk_ShowImage.TabIndex = 14;
  279. this.chk_ShowImage.Text = "ShowImage:";
  280. this.chk_ShowImage.UseVisualStyleBackColor = true;
  281. //
  282. // tb_Green
  283. //
  284. this.tb_Green.Location = new System.Drawing.Point(153, 59);
  285. this.tb_Green.Name = "tb_Green";
  286. this.tb_Green.Size = new System.Drawing.Size(42, 20);
  287. this.tb_Green.TabIndex = 15;
  288. //
  289. // tb_Red
  290. //
  291. this.tb_Red.Location = new System.Drawing.Point(108, 59);
  292. this.tb_Red.Name = "tb_Red";
  293. this.tb_Red.Size = new System.Drawing.Size(42, 20);
  294. this.tb_Red.TabIndex = 14;
  295. //
  296. // lb_Detection
  297. //
  298. this.lb_Detection.FormattingEnabled = true;
  299. this.lb_Detection.Location = new System.Drawing.Point(10, 322);
  300. this.lb_Detection.Name = "lb_Detection";
  301. this.lb_Detection.Size = new System.Drawing.Size(660, 251);
  302. this.lb_Detection.TabIndex = 14;
  303. //
  304. // label12
  305. //
  306. this.label12.AutoSize = true;
  307. this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
  308. this.label12.Location = new System.Drawing.Point(12, 305);
  309. this.label12.Name = "label12";
  310. this.label12.Size = new System.Drawing.Size(91, 13);
  311. this.label12.TabIndex = 15;
  312. this.label12.Text = "Detection info:";
  313. //
  314. // MainForm
  315. //
  316. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  317. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  318. this.ClientSize = new System.Drawing.Size(947, 581);
  319. this.Controls.Add(this.label12);
  320. this.Controls.Add(this.lb_Detection);
  321. this.Controls.Add(this.groupBox2);
  322. this.Controls.Add(this.groupBox1);
  323. this.Controls.Add(this.label2);
  324. this.Controls.Add(this.label1);
  325. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  326. this.MaximizeBox = false;
  327. this.Name = "MainForm";
  328. this.Text = "Circle Detection";
  329. this.Load += new System.EventHandler(this.MainForm_Load);
  330. this.groupBox1.ResumeLayout(false);
  331. this.groupBox1.PerformLayout();
  332. this.groupBox2.ResumeLayout(false);
  333. this.groupBox2.PerformLayout();
  334. this.ResumeLayout(false);
  335. this.PerformLayout();
  336.  
  337. }
  338.  
  339. #endregion
  340.  
  341. private System.Windows.Forms.Label label1;
  342. private System.Windows.Forms.Label label2;
  343. private System.Windows.Forms.Button btn_Set;
  344. private System.Windows.Forms.TextBox tb_AccumulatorResolution;
  345. private System.Windows.Forms.TextBox tb_CannyThreshold;
  346. private System.Windows.Forms.TextBox tb_CircleAccumulatorThreshold;
  347. private System.Windows.Forms.TextBox tb_MaximumRadius;
  348. private System.Windows.Forms.TextBox tb_MinimumDistance;
  349. private System.Windows.Forms.TextBox tb_MinimumRadius;
  350. private System.Windows.Forms.GroupBox groupBox1;
  351. private System.Windows.Forms.Label label8;
  352. private System.Windows.Forms.Label label7;
  353. private System.Windows.Forms.Label label6;
  354. private System.Windows.Forms.Label label5;
  355. private System.Windows.Forms.Label label4;
  356. private System.Windows.Forms.Label label3;
  357. private System.Windows.Forms.GroupBox groupBox2;
  358. private System.Windows.Forms.CheckBox chk_ShowImage;
  359. private System.Windows.Forms.TextBox tb_Blue;
  360. private System.Windows.Forms.TextBox tb_Green;
  361. private System.Windows.Forms.TextBox tb_Red;
  362. private System.Windows.Forms.Label label11;
  363. private System.Windows.Forms.Label label10;
  364. private System.Windows.Forms.TextBox tb_DrawThickness;
  365. private System.Windows.Forms.ListBox lb_Detection;
  366. private System.Windows.Forms.Button btn_HighlightSet;
  367. private System.Windows.Forms.Label label12;
  368. }
  369. }
  370.  
  371.  
  372. // Form1.cs
  373.  
  374. using System;
  375. using System.Drawing;
  376. using System.Windows.Forms;
  377. using Ozeki.Media.MediaHandlers;
  378. using Ozeki.Media.MediaHandlers.Video;
  379. using Ozeki.Media.MediaHandlers.Video.CV;
  380. using Ozeki.Media.MediaHandlers.Video.CV.Processer;
  381. using Ozeki.Media.Video.Controls;
  382. using Ozeki.Media.MediaHandlers.Video.CV.Data;
  383.  
  384. namespace CircleDetection
  385. {
  386. public partial class Form1 : Form
  387. {
  388. WebCamera _webCamera;
  389. MediaConnector _connector;
  390.  
  391. ImageProcesserHandler _imageProcesserHandler;
  392. ICircleDetector _circleDetector;
  393. FrameCapture _frameCapture;
  394.  
  395. VideoViewerWF _originalView;
  396. VideoViewerWF _processedView;
  397. DrawingImageProvider _originalImageProvider;
  398. DrawingImageProvider _processedImageProvider;
  399.  
  400. public Form1()
  401. {
  402. InitializeComponent();
  403. }
  404.  
  405. void MainForm_Load(object sender, EventArgs e)
  406. {
  407. Init();
  408.  
  409. SetVideoViewers();
  410.  
  411. InitDetectorFields();
  412.  
  413. ConnectWebcam();
  414.  
  415. Start();
  416. }
  417.  
  418. void Init()
  419. {
  420. _frameCapture = new FrameCapture();
  421. _frameCapture.SetInterval(5);
  422.  
  423. _webCamera = WebCamera.GetDefaultDevice();
  424. _connector = new MediaConnector();
  425. _originalImageProvider = new DrawingImageProvider();
  426. _processedImageProvider = new DrawingImageProvider();
  427.  
  428. _circleDetector = ImageProcesserFactory.CreateCircleDetector();
  429. _circleDetector.DetectionOccurred += _circleDetector_DetectionOccurred;
  430.  
  431. _imageProcesserHandler = new ImageProcesserHandler();
  432. _imageProcesserHandler.AddProcesser(_circleDetector);
  433. }
  434.  
  435. void SetVideoViewers()
  436. {
  437. _originalView = new VideoViewerWF
  438. {
  439. BackColor = Color.Black,
  440. Location = new Point(10, 20),
  441. Size = new Size(320, 240)
  442. };
  443.  
  444. _originalView.SetImageProvider(_originalImageProvider);
  445. Controls.Add(_originalView);
  446.  
  447. _processedView = new VideoViewerWF
  448. {
  449. BackColor = Color.Black,
  450. Location = new Point(350, 20),
  451. Size = new Size(320, 240)
  452. };
  453.  
  454. _processedView.SetImageProvider(_processedImageProvider);
  455. Controls.Add(_processedView);
  456. }
  457.  
  458. void InitDetectorFields()
  459. {
  460. InvokeGUIThread(() =>
  461. {
  462. chk_ShowImage.Checked = _circleDetector.ShowImage;
  463. tb_Red.Text = _circleDetector.DrawColor.R.ToString();
  464. tb_Green.Text = _circleDetector.DrawColor.G.ToString();
  465. tb_Blue.Text = _circleDetector.DrawColor.B.ToString();
  466. tb_DrawThickness.Text = _circleDetector.DrawThickness.ToString();
  467.  
  468. tb_AccumulatorResolution.Text = _circleDetector.AccumulatorResolution.ToString();
  469. tb_CannyThreshold.Text = _circleDetector.CannyThreshold.ToString();
  470. tb_CircleAccumulatorThreshold.Text = _circleDetector.CircleAccumulatorThreshold.ToString();
  471. tb_MaximumRadius.Text = _circleDetector.MaximumRadius.ToString();
  472. tb_MinimumDistance.Text = _circleDetector.MinimumDistance.ToString();
  473. tb_MinimumRadius.Text = _circleDetector.MinimumRadius.ToString();
  474. });
  475. }
  476.  
  477. void ConnectWebcam()
  478. {
  479. _connector.Connect(_webCamera, _originalImageProvider);
  480.  
  481. _connector.Connect(_webCamera, _frameCapture);
  482. _connector.Connect(_frameCapture, _imageProcesserHandler);
  483. _connector.Connect(_imageProcesserHandler, _processedImageProvider);
  484. }
  485.  
  486. void Start()
  487. {
  488. _originalView.Start();
  489. _processedView.Start();
  490.  
  491. _frameCapture.Start();
  492. _webCamera.Start();
  493. }
  494.  
  495. void btn_HighlightSet_Click(object sender, EventArgs e)
  496. {
  497. InvokeGUIThread(() =>
  498. {
  499. _circleDetector.ShowImage = chk_ShowImage.Checked;
  500. _circleDetector.DrawColor = Color.FromArgb(Int32.Parse(tb_Red.Text), Int32.Parse(tb_Green.Text), Int32.Parse(tb_Blue.Text));
  501. _circleDetector.DrawThickness = Int32.Parse(tb_DrawThickness.Text);
  502. });
  503. }
  504.  
  505. void btn_Set_Click(object sender, EventArgs e)
  506. {
  507. InvokeGUIThread(() =>
  508. {
  509. _circleDetector.AccumulatorResolution = Double.Parse(tb_AccumulatorResolution.Text);
  510. _circleDetector.CannyThreshold = Double.Parse(tb_CannyThreshold.Text);
  511. _circleDetector.CircleAccumulatorThreshold = Double.Parse(tb_CircleAccumulatorThreshold.Text);
  512. _circleDetector.MaximumRadius = Int32.Parse(tb_MaximumRadius.Text);
  513. _circleDetector.MinimumDistance = Double.Parse(tb_MinimumDistance.Text);
  514. _circleDetector.MinimumRadius = Int32.Parse(tb_MinimumRadius.Text);
  515. });
  516. }
  517.  
  518. void _circleDetector_DetectionOccurred(object sender, CircleDetectedEventArgs e)
  519. {
  520. InvokeGUIThread(() =>
  521. {
  522. lb_Detection.Items.Clear();
  523.  
  524. foreach (var info in e.Info)
  525. {
  526. lb_Detection.Items.Add(info);
  527. }
  528. });
  529. }
  530.  
  531. void InvokeGUIThread(Action action)
  532. {
  533. BeginInvoke(action);
  534. }
  535.  
  536. }
  537. }

Report this snippet  

You need to login to post a comment.