Skip to content

Commit f404c3b

Browse files
authored
Merge pull request #17 from lucidcode/inspec-device
Add support for inspec device
2 parents 97b09fe + 3d5b362 commit f404c3b

5 files changed

Lines changed: 21107 additions & 3741 deletions

File tree

Halovision/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("lucidcode")]
1212
[assembly: AssemblyProduct("Plugin.Halovision")]
13-
[assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2022")]
13+
[assembly: AssemblyCopyright("Copyright © lucidcode 2013 - 2024")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.6.0")]
36-
[assembly: AssemblyFileVersion("1.2.6.0")]
35+
[assembly: AssemblyVersion("1.2.7.0")]
36+
[assembly: AssemblyFileVersion("1.2.7.0")]

Halovision/VisionForm.cs

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

Halovision/VisionForm.designer.cs

Lines changed: 64 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Halovision/VisionForm.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
129129
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
130130
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACW
131-
DQAAAk1TRnQBSQFMAwEBAAEoAQIBKAECAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
131+
DQAAAk1TRnQBSQFMAwEBAAEwAQIBMAECAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
132132
ARwDAAEBAQABGAUAAbABKBIAXf//ABgABv8B6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
133133
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
134134
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6AHX

0 commit comments

Comments
 (0)