@@ -52,7 +52,7 @@ public partial class VisionForm : Form
5252 public int DashThreshold = 600 ;
5353
5454 public bool Auralize = false ;
55- public WaveType WaveForm = WaveType . Square ;
55+ public WaveType WaveForm = WaveType . Triangle ;
5656
5757 private VideoCaptureDevice videoSource ;
5858 private Rectangle [ ] faceRegions ;
@@ -88,14 +88,21 @@ private void PortForm_Load(object sender, EventArgs e)
8888 return ;
8989 }
9090
91+ if ( cmbDevices . Text == "lucidcode INSPEC" )
92+ {
93+ loaded = true ;
94+ ConnectInspecDevice ( ) ;
95+ return ;
96+ }
97+
9198 OpenVideoDevice ( ) ;
9299
93100 loaded = true ;
94101 return ;
95102 }
96103 catch ( Exception ex )
97104 {
98- MessageBox . Show ( ex . Message , "LucidScribe.InitializePlugin()" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
105+ MessageBox . Show ( ex . Message + ex . StackTrace , "LucidScribe.InitializePlugin() 1 " , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
99106 }
100107 }
101108
@@ -107,6 +114,7 @@ private void LoadVideoDevices()
107114 {
108115 cmbDevices . Items . Add ( filterInfo . Name ) ;
109116 }
117+ cmbDevices . Items . Add ( "lucidcode INSPEC" ) ;
110118 cmbDevices . Items . Add ( "lucidcode Halovision Device" ) ;
111119 }
112120
@@ -130,7 +138,7 @@ private void OpenVideoDevice()
130138 private void LoadClassifiers ( )
131139 {
132140 cmbClassifier . Items . Add ( "None" ) ;
133-
141+
134142 if ( ! Directory . Exists ( $ "{ lucidScribeDataPath } \\ Classifiers") )
135143 {
136144 return ;
@@ -172,6 +180,10 @@ public void Disconnect()
172180 {
173181 DisconnectHalovisionDevice ( ) ;
174182 }
183+ else if ( cmbDevices . Text == "lucidcode INSPEC" )
184+ {
185+ DisconnectInspecDevice ( ) ;
186+ }
175187 else
176188 {
177189 videoSource . NewFrame -= video_NewFrame ;
@@ -230,7 +242,7 @@ private void LoadSettings()
230242 defaultSettings += "<DotThreshold>200</DotThreshold>" ;
231243 defaultSettings += "<DashThreshold>600</DashThreshold>" ;
232244 defaultSettings += "<Classifier>None</Classifier>" ;
233- defaultSettings += "<WaveForm>Sqaure </WaveForm>" ;
245+ defaultSettings += "<WaveForm>Triangle </WaveForm>" ;
234246 defaultSettings += "</Plugin>" ;
235247 defaultSettings += "</LucidScribeData>" ;
236248 File . WriteAllText ( settingsFilePath , defaultSettings ) ;
@@ -311,7 +323,7 @@ private void LoadSettings()
311323 if ( xmlSettings . DocumentElement . SelectSingleNode ( "//TossHalfLife" ) != null )
312324 {
313325 tossHalfLifeInput . Value = Convert . ToDecimal ( xmlSettings . DocumentElement . SelectSingleNode ( "//TossHalfLife" ) . InnerText ) ;
314- }
326+ }
315327 else
316328 {
317329 tossHalfLifeInput . Value = TossHalfLife ;
@@ -320,7 +332,7 @@ private void LoadSettings()
320332 if ( xmlSettings . DocumentElement . SelectSingleNode ( "//EyeMoveMin" ) != null )
321333 {
322334 eyeMoveMinInput . Value = Convert . ToDecimal ( xmlSettings . DocumentElement . SelectSingleNode ( "//EyeMoveMin" ) . InnerText ) ;
323- }
335+ }
324336 else
325337 {
326338 eyeMoveMinInput . Value = EyeMoveMin ;
@@ -329,7 +341,7 @@ private void LoadSettings()
329341 if ( xmlSettings . DocumentElement . SelectSingleNode ( "//EyeMoveMax" ) != null )
330342 {
331343 eyeMoveMaxInput . Value = Convert . ToDecimal ( xmlSettings . DocumentElement . SelectSingleNode ( "//EyeMoveMax" ) . InnerText ) ;
332- }
344+ }
333345 else
334346 {
335347 eyeMoveMaxInput . Value = EyeMoveMax ;
@@ -338,7 +350,7 @@ private void LoadSettings()
338350 if ( xmlSettings . DocumentElement . SelectSingleNode ( "//IdleTicks" ) != null )
339351 {
340352 idleTicksInput . Value = Convert . ToDecimal ( xmlSettings . DocumentElement . SelectSingleNode ( "//IdleTicks" ) . InnerText ) ;
341- }
353+ }
342354 else
343355 {
344356 idleTicksInput . Value = IdleTicks ;
@@ -376,7 +388,8 @@ private void LoadSettings()
376388
377389 private void cmbDevices_SelectedIndexChanged ( object sender , EventArgs e )
378390 {
379- if ( cmbDevices . Text == "lucidcode Halovision Device" )
391+ if ( cmbDevices . Text == "lucidcode Halovision Device" ||
392+ cmbDevices . Text == "lucidcode INSPEC" )
380393 {
381394 txtDeviceURL . Enabled = true ;
382395 lblDeviceURL . Enabled = true ;
@@ -396,6 +409,11 @@ private void cmbDevices_SelectedIndexChanged(object sender, EventArgs e)
396409 ConnectHalovisionDevice ( ) ;
397410 return ;
398411 }
412+ if ( cmbDevices . SelectedText == "lucidcode INSPEC" )
413+ {
414+ ConnectInspecDevice ( ) ;
415+ return ;
416+ }
399417 OpenVideoDevice ( ) ;
400418 }
401419
@@ -485,6 +503,37 @@ public void DisconnectHalovisionDevice()
485503 }
486504 }
487505
506+ private void ConnectInspecDevice ( )
507+ {
508+ try
509+ {
510+ Core . Initialize ( ) ;
511+
512+ libvlc = new LibVLC ( enableDebugLogs : false ) ;
513+ using ( Media media = new Media ( libvlc , txtDeviceURL . Text , FromType . FromLocation ) )
514+ {
515+ player = new MediaPlayer ( media ) ;
516+ player . Hwnd = pbDisplay . Handle ;
517+ player . Play ( ) ;
518+ }
519+ }
520+ catch ( Exception ex )
521+ {
522+ MessageBox . Show ( ex . Message , "LucidScribe.InitializePlugin()" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
523+ }
524+ }
525+
526+ public void DisconnectInspecDevice ( )
527+ {
528+ try
529+ {
530+ player . Stop ( ) ;
531+ }
532+ catch ( Exception ex )
533+ {
534+ }
535+ }
536+
488537 private void OnResponseMessageReceived ( object sender , DuplexChannelMessageEventArgs e )
489538 {
490539 byte [ ] aVideoData = ( byte [ ] ) e . Message ;
@@ -842,7 +891,7 @@ private void Difference(ref Bitmap bitmap1, ref Bitmap bitmap2, out int diff)
842891
843892 diff = differences ;
844893
845- double percentage = ( Convert . ToDouble ( changedPixels ) / Convert . ToDouble ( totalPixels ) ) * 100 ;
894+ double percentage = ( changedPixels / totalPixels ) * 100 ;
846895 if ( percentage > IgnorePercentage )
847896 {
848897 diff = 0 ;
@@ -1087,7 +1136,7 @@ private void cmbWaveForm_SelectedIndexChanged(object sender, EventArgs e)
10871136 WaveForm = WaveType . Pink ;
10881137 break ;
10891138 default :
1090- WaveForm = WaveType . Square ;
1139+ WaveForm = WaveType . Triangle ;
10911140 break ;
10921141 }
10931142 SaveSettings ( ) ;
0 commit comments