-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainForm.cs
743 lines (655 loc) · 28.7 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace raw_streams.cs
{
public partial class MainForm : Form
{
private PXCMSession session;
private string filename = null;
private PictureBitmap pictureBitmap = new PictureBitmap();
private int current_device_iuid = 0;
private Dictionary<ToolStripMenuItem, PXCMCapture.DeviceInfo> devices=new Dictionary<ToolStripMenuItem,PXCMCapture.DeviceInfo>();
private Dictionary<ToolStripMenuItem, int> devices_iuid=new Dictionary<ToolStripMenuItem,int>();
private Dictionary<ToolStripMenuItem, PXCMCapture.Device.StreamProfile> profiles=new Dictionary<ToolStripMenuItem,PXCMCapture.Device.StreamProfile>();
private GuiParams guiParams = GuiParams.Default;
private CameraSettings cameraSettings = new CameraSettings();
private TrackBar[] cameraSettingsTrackBars;
private volatile bool closing = false;
private volatile bool stop = false;
public MainForm(PXCMSession session)
{
InitializeComponent();
this.session = session;
PopulateDeviceMenu();
FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
pictureBox1.Paint += new PaintEventHandler(pictureBitmap_Paint);
this.comboBoxQualityEstimator.Items.AddRange(
new object[] {"ColorClusters"
});
this.comboBoxColoringMethod.Items.AddRange(
new object[] {"None"
, "ByScore"
, "ByClusterMeanColor"
, "ByClusterMaxColor"
, "ByClusterDepth"
});
this.cameraSettingsTrackBars = new TrackBar[]
{
this.trackBarCamDepthCofidenceThreshold,
this.trackBarCamIvcamAccuracy,
this.trackBarCamIVCAMFilterOption,
this.trackBarCamIVCAMLaserPower,
this.trackBarCamIVCAMMotionRangeTradeOff
};
this.resetAllParams();
}
private delegate void UpdateFromOtherThreadDelegate();
private delegate void UpdateStatusDelegate(string status);
#region Properies and change state methods
public bool GetStopState()
{
return stop;
}
internal GuiParams GetParams()
{
return guiParams;
}
internal CameraSettings CameraSettings
{
get { return cameraSettings; }
set
{
this.cameraSettings = value;
this.Invoke(
new UpdateFromOtherThreadDelegate(
delegate()
{
cameraSettings.SetupTrackBars(this.cameraSettingsTrackBars);
}
)
);
}
}
internal void SetCameraSettings(CameraSettings cs, PXCMCapture.Device.PropertyInfo[] propInfo)
{
this.cameraSettings = cs;
this.Invoke(
new UpdateFromOtherThreadDelegate(
delegate()
{
cameraSettings.SetupTrackBars(this.cameraSettingsTrackBars, propInfo);
}
)
);
}
public void UpdateStatus(string status)
{
Status2.Invoke(new UpdateStatusDelegate(delegate(string s) { StatusLabel.Text = s; }), new object[] { status });
}
#endregion
#region Menu and device config
private void PopulateDeviceMenu()
{
devices.Clear();
devices_iuid.Clear();
PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
DeviceMenu.DropDownItems.Clear();
for (int i = 0; ; i++)
{
PXCMSession.ImplDesc desc1;
pxcmStatus rc = session.QueryImpl(desc, i, out desc1);
if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
break;
PXCMCapture capture;
rc = session.CreateImpl<PXCMCapture>(desc1, out capture);
if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
continue;
using (capture)
{
for (int j = 0; ; j++)
{
PXCMCapture.DeviceInfo dinfo;
rc = capture.QueryDeviceInfo(j, out dinfo);
if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
break;
ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
devices[sm1] = dinfo;
devices_iuid[sm1] = desc1.iuid;
DeviceMenu.DropDownItems.Add(sm1);
}
}
}
if (DeviceMenu.DropDownItems.Count > 0)
{
(DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
PopulateDepthMenu(DeviceMenu.DropDownItems[0] as ToolStripMenuItem);
}
}
private bool PopulateDeviceFromFileMenu()
{
devices.Clear();
devices_iuid.Clear();
PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
PXCMSession.ImplDesc desc1;
PXCMCapture.DeviceInfo dinfo;
PXCMSenseManager pp = PXCMSenseManager.CreateInstance();
if (pp == null)
{
UpdateStatus("Init Failed");
return false;
}
try
{
if (session.QueryImpl(desc, 0, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
throw null;
if (pp.captureManager.SetFileName(filename, false) < pxcmStatus.PXCM_STATUS_NO_ERROR)
throw null;
if (pp.QueryCaptureManager().LocateStreams() < pxcmStatus.PXCM_STATUS_NO_ERROR)
throw null;
pp.QueryCaptureManager().QueryDevice().QueryDeviceInfo(out dinfo);
}
catch
{
pp.Dispose();
UpdateStatus("Init Failed");
return false;
}
DeviceMenu.DropDownItems.Clear();
ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
devices[sm1] = dinfo;
devices_iuid[sm1] = desc1.iuid;
DeviceMenu.DropDownItems.Add(sm1);
sm1 = new ToolStripMenuItem("playback from the file : ", null);
sm1.Enabled = false;
DeviceMenu.DropDownItems.Add(sm1);
sm1 = new ToolStripMenuItem(filename, null);
sm1.Enabled = false;
DeviceMenu.DropDownItems.Add(sm1);
if (DeviceMenu.DropDownItems.Count > 0)
(DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
// populate depth menu from the file
profiles.Clear();
DepthMenu.DropDownItems.Clear();
PXCMCapture.Device device = pp.QueryCaptureManager().QueryDevice();
PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
if (((int)dinfo.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0)
{
int num = device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_DEPTH);
for (int p = 0; p < num; p++)
{
if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
break;
PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH];
sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click));
profiles[sm1] = sprofile;
DepthMenu.DropDownItems.Add(sm1);
}
}
DepthNone = new ToolStripMenuItem("None", null, new EventHandler(Depth_Item_Click));
profiles[DepthNone] = new PXCMCapture.Device.StreamProfile();
DepthMenu.DropDownItems.Add(DepthNone);
(DepthMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
CheckSelection();
pp.Close();
pp.Dispose();
StatusLabel.Text = "Ok";
return true;
}
private void PopulateDepthMenu(ToolStripMenuItem device_item)
{
PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
desc.iuid = devices_iuid[device_item];
current_device_iuid = desc.iuid;
desc.cuids[0] = PXCMCapture.CUID;
profiles.Clear();
DepthMenu.DropDownItems.Clear();
PXCMCapture capture;
PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
if (session.CreateImpl<PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
{
using (capture)
{
using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
{
if (device != null)
{
PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0)
{
int num = device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_DEPTH);
for (int p = 0; p < num; p++)
{
if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
break;
PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH];
ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click));
profiles[sm1] = sprofile;
DepthMenu.DropDownItems.Add(sm1);
}
}
}
}
}
}
DepthNone = new ToolStripMenuItem("None", null, new EventHandler(Depth_Item_Click));
profiles[DepthNone] = new PXCMCapture.Device.StreamProfile();
DepthMenu.DropDownItems.Add(DepthNone);
(DepthMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
CheckSelection();
}
private static string ProfileToString(PXCMCapture.Device.StreamProfile pinfo)
{
string line = "Unknown ";
if (Enum.IsDefined(typeof(PXCMImage.PixelFormat), pinfo.imageInfo.format))
line = pinfo.imageInfo.format.ToString().Substring(13)+" "+pinfo.imageInfo.width+"x"+pinfo.imageInfo.height+"x";
else
line += pinfo.imageInfo.width + "x" + pinfo.imageInfo.height + "x";
if (pinfo.frameRate.min != pinfo.frameRate.max) {
line += (float)pinfo.frameRate.min + "-" +
(float)pinfo.frameRate.max;
} else {
float fps = (pinfo.frameRate.min!=0)?pinfo.frameRate.min:pinfo.frameRate.max;
line += fps;
}
return line;
}
private void Device_Item_Click(object sender, EventArgs e)
{
foreach (ToolStripMenuItem e1 in DeviceMenu.DropDownItems)
e1.Checked = (sender == e1);
PopulateDepthMenu(sender as ToolStripMenuItem);
}
private void Depth_Item_Click(object sender, EventArgs e)
{
foreach (ToolStripMenuItem e1 in DepthMenu.DropDownItems)
e1.Checked = (sender == e1);
CheckSelection();
}
public PXCMCapture.DeviceInfo GetCheckedDevice()
{
foreach (ToolStripMenuItem e in DeviceMenu.DropDownItems)
{
if (devices.ContainsKey(e))
{
if (e.Checked)
return devices[e];
}
}
return new PXCMCapture.DeviceInfo();
}
private PXCMCapture.Device.StreamProfile GetConfiguration(ToolStripMenuItem m)
{
foreach (ToolStripMenuItem e in m.DropDownItems)
if (e.Checked)
return profiles[e];
return new PXCMCapture.Device.StreamProfile();
}
private ToolStripMenuItem GetMenuItem(PXCMCapture.Device.StreamProfile profile)
{
foreach (ToolStripMenuItem key1 in profiles.Keys)
{
PXCMCapture.Device.StreamProfile profile1 = profiles[key1];
if (ProfileToString(profile1) == ProfileToString(profile))
return key1;
}
return null;
}
public PXCMCapture.Device.StreamProfile GetDepthConfiguration()
{
return GetConfiguration(DepthMenu);
}
private void CheckSelection()
{
PXCMCapture.Device.StreamProfile dprofile = GetDepthConfiguration();
//?DepthNone.Enabled = (cprofile.imageInfo.format != 0 || irprofile.imageInfo.format != 0);
PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
desc.iuid = current_device_iuid;
desc.cuids[0] = PXCMCapture.CUID;
PXCMCapture capture;
PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
if (session.CreateImpl<PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
{
using (capture)
{
using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
{
if (device != null)
{
PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
PXCMCapture.Device.StreamProfileSet test = new PXCMCapture.Device.StreamProfileSet();
/* Loop over all stream types and profiles and enable only compatible in menu */
for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
{
PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_COLOR) != 0)
{
//?test[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = cprofile;
test[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = dprofile;
//?test[PXCMCapture.StreamType.STREAM_TYPE_IR] = irprofile;
int num = device.QueryStreamProfileSetNum(st);
for (int p = 0; p < num; p++)
{
if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
break;
PXCMCapture.Device.StreamProfile sprofile = profile[st];
ToolStripMenuItem sm1 = GetMenuItem(sprofile);
if (sm1 != null)
{
test[st] = sprofile;
sm1.Enabled = device.IsStreamProfileSetValid(test);
}
}
}
}
}
}
}
}
}
#endregion
#region Start, stop, etc
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
stop = true;
e.Cancel = Stop.Enabled;
closing = true;
}
private void Start_Click(object sender, EventArgs e)
{
stop = false;
System.Threading.Thread thread = new System.Threading.Thread(DoRendering);
thread.Start();
System.Threading.Thread.Sleep(5);
}
private void Stop_Click(object sender, EventArgs e)
{
stop = true;
}
#endregion
#region Picture and rendering
public void SetPicture(int width, int height, byte[] pixels)
{
if (pixels == null)
return;
lock (this)
{
pictureBitmap.SetPixels(width, height, pixels);
}
}
public void UpdatePicture()
{
pictureBox1.Invoke(
new UpdateFromOtherThreadDelegate(
delegate()
{
pictureBox1.Invalidate();
}
)
);
}
private void DoRendering()
{
try
{
this.Invoke(new UpdateFromOtherThreadDelegate(
delegate
{
MainMenu.Enabled = false;
Start.Enabled = false;
Stop.Enabled = true;
}
));
RenderStreams rs = new RenderStreams(this);
rs.ShowStream();
}
catch (Exception e)
{
stop = true;
UpdateStatus("Exception: " + e.ToString());
}
this.Invoke(new UpdateFromOtherThreadDelegate(
delegate
{
Start.Enabled = true;
Stop.Enabled = false;
MainMenu.Enabled = true;
if (closing)
Close();
}
));
}
private static Rectangle getScaledRect(Rectangle rc, int w, int h)
{
float xscale = (float)rc.Width / (float)w;
float yscale = (float)rc.Height / (float)h;
float xyscale = (xscale < yscale) ? xscale : yscale;
int width = (int)(w * xyscale);
int height = (int)(h * xyscale);
rc.X = (rc.Width - width) / 2;
rc.Y = (rc.Height - height) / 2;
rc.Width = width;
rc.Height = height;
return rc;
}
private void pictureBitmap_Paint(object sender, PaintEventArgs e)
{
bool scaled = false;
lock (this)
{
try
{
Bitmap bitmap = pictureBitmap.GetBitmap();
if (bitmap == null)
return;
if (scaled)
{
/* Keep the aspect ratio */
Rectangle rc = (sender as Control).ClientRectangle;
rc = getScaledRect(rc, bitmap.Width, bitmap.Height);
e.Graphics.DrawImage(bitmap, rc);
}
else
{
e.Graphics.DrawImageUnscaled(bitmap, 0, 0);
}
}
catch (Exception excpt)
{
stop = true;
UpdateStatus("Exception: " + excpt.GetType().ToString());
}
}
}
private void cleanPictureBitmap()
{
if (pictureBitmap != null)
{
pictureBitmap.Dispose();
pictureBitmap = null;
}
}
#endregion
#region Mode Live/Recorded
public bool IsModeLive()
{
return ModeLive.Checked;
}
public bool IsModeRecorded()
{
return ModeRecord.Checked;
}
private void ModeLive_Click(object sender, EventArgs e)
{
ModeLive.Checked = true;
ModePlayback.Checked = ModeRecord.Checked = false;
PopulateDeviceMenu();
}
private void ModePlayback_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "RSSDK clip|*.rssdk|Old format clip|*.pcsdk|All files|*.*";
ofd.CheckFileExists = true;
ofd.CheckPathExists = true;
filename = (ofd.ShowDialog() == DialogResult.OK) ? ofd.FileName : null;
if (filename == null)
{
ModeLive.Checked = true;
ModePlayback.Checked = ModeRecord.Checked = false;
PopulateDeviceMenu();
}
else
{
ModePlayback.Checked = true;
ModeLive.Checked = ModeRecord.Checked = false;
if (PopulateDeviceFromFileMenu() == false)
{
ModeLive.Checked = true;
ModePlayback.Checked = ModeRecord.Checked = false;
MessageBox.Show("Incorrect file format, switching to live mode");
}
}
}
private void ModeRecord_Click(object sender, EventArgs e)
{
ModeRecord.Checked = true;
ModeLive.Checked = ModePlayback.Checked = false;
PopulateDeviceMenu();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "RSSDK clip|*.rssdk|All files|*.*";
sfd.CheckPathExists = true;
sfd.OverwritePrompt = true;
sfd.AddExtension = true;
filename = (sfd.ShowDialog() == DialogResult.OK) ? sfd.FileName : null;
}
#endregion
#region Common params UI
private void setupAllParamsCtls()
{
this.comboBoxQualityEstimator.SelectedIndex = (int)guiParams.processParams.qualityEstimationMethod;
this.comboBoxColoringMethod.Visible = true;
this.comboBoxColoringMethod.SelectedIndex = (int)guiParams.processParams.colorClustersParams.pixelColoringMethod;
bool isColorClusterParamsRequired = guiParams.processParams.qualityEstimationMethod == managed_obj_detector.QualityEstimationMethod.ColorClusters;
if (isColorClusterParamsRequired)
{
this.label1.Text = "";
this.label2.Text = "Color Clusters deltaDepthThreshold";
this.label3.Text = "Color Clusters halfWindowSize";
this.textBoxMaxDepthChangeFactor1.Text = guiParams.processParams.colorClustersParams.colorDistanceThreshold.ToString();
this.textBoxNormalSmoothingSize1.Text = guiParams.processParams.colorClustersParams.halfWindowSize.ToString();
}
this.textBoxMaxDepthChangeFactor1.Visible = isColorClusterParamsRequired;
this.textBoxNormalSmoothingSize1.Visible = isColorClusterParamsRequired;
this.label1.Visible = isColorClusterParamsRequired;
this.label2.Visible = isColorClusterParamsRequired;
this.label3.Visible = isColorClusterParamsRequired;
this.trackBarMaxBad.Value = (int)(1000f * guiParams.processParams.maxBadPixelQuality);
this.trackBarMinGood.Value = (int)(1000f * guiParams.processParams.minGoodPixelQuality);
}
private void resetAllParams()
{
this.guiParams = GuiParams.Default;
this.setupAllParamsCtls();
}
private void buttonResetAllParams_Click(object sender, EventArgs e)
{
this.resetAllParams();
}
private void comboBoxQualityEstimator_SelectedIndexChanged(object sender, EventArgs e)
{
guiParams.processParams.qualityEstimationMethod = (managed_obj_detector.QualityEstimationMethod)this.comboBoxQualityEstimator.SelectedIndex;
this.setupAllParamsCtls();
}
#endregion
#region First Normal or DepthClusters UI
private void comboBoxColoringMethod_SelectedIndexChanged(object sender, EventArgs e)
{
guiParams.processParams.colorClustersParams.pixelColoringMethod
= (managed_obj_detector.PixelColoringMethodEnum)comboBoxColoringMethod.SelectedIndex;
}
private void textBoxMaxDepthChangeFactor_TextChanged(object sender, EventArgs e)
{
bool isColorClusterParamsRequired = guiParams.processParams.qualityEstimationMethod == managed_obj_detector.QualityEstimationMethod.ColorClusters;
if(isColorClusterParamsRequired)
int.TryParse(textBoxMaxDepthChangeFactor1.Text, out guiParams.processParams.colorClustersParams.colorDistanceThreshold);
}
private void textBoxNormalSmoothingSize_TextChanged(object sender, EventArgs e)
{
bool isColorClusterParamsRequired = guiParams.processParams.qualityEstimationMethod == managed_obj_detector.QualityEstimationMethod.ColorClusters;
if(isColorClusterParamsRequired)
int.TryParse(textBoxNormalSmoothingSize1.Text, out guiParams.processParams.colorClustersParams.halfWindowSize);
}
#endregion
#region Second normal UI
private void comboBoxNormalEstimator2_SelectedIndexChanged(object sender, EventArgs e)
{
//fixme: remove: comboBoxNormalEstimator2.SelectedIndex;
}
private void textBoxMaxDepthChangeFactor2_TextChanged(object sender, EventArgs e)
{
//fixme: textBoxMaxDepthChangeFactor2
}
private void textBoxNormalSmoothingSize2_TextChanged(object sender, EventArgs e)
{
//fixme: textBoxNormalSmoothingSize2.Text, out guiParams.processParams.normalEstimationParams2.normalSmoothingSize);
}
#endregion
#region Camera parameters UI
private void trackBarCamDepthCofidenceThreshold_Scroll(object sender, EventArgs e)
{
this.cameraSettings.DepthConfidenceThreshold = (ushort)trackBarCamDepthCofidenceThreshold.Value;
this.cameraSettings.changed = true;
}
private void trackBarCamIvcamAccuracy_Scroll(object sender, EventArgs e)
{
this.cameraSettings.IVCAMAccuracy = trackBarCamIvcamAccuracy.Value;
this.cameraSettings.changed = true;
}
private void trackBarCamIVCAMFilterOption_Scroll(object sender, EventArgs e)
{
this.cameraSettings.IVCAMFilterOption = trackBarCamIVCAMFilterOption.Value;
this.cameraSettings.changed = true;
}
private void trackBarCamIVCAMLaserPower_Scroll(object sender, EventArgs e)
{
this.cameraSettings.IVCAMLaserPower = trackBarCamIVCAMLaserPower.Value;
this.cameraSettings.changed = true;
}
private void trackBarCamIVCAMMotionRangeTradeOff_Scroll(object sender, EventArgs e)
{
this.cameraSettings.IVCAMMotionRangeTradeOff = trackBarCamIVCAMMotionRangeTradeOff.Value;
this.cameraSettings.changed = true;
}
#endregion
#region Pixel quality range UI
private void trackBarMaxBad_Scroll(object sender, EventArgs e)
{
if (trackBarMinGood.Value < trackBarMaxBad.Value)
trackBarMinGood.Value = trackBarMaxBad.Value;
guiParams.processParams.maxBadPixelQuality = 0.001f * trackBarMaxBad.Value;
}
private void trackBarMinGood_Scroll(object sender, EventArgs e)
{
if (trackBarMinGood.Value < trackBarMaxBad.Value)
trackBarMaxBad.Value = trackBarMinGood.Value;
guiParams.processParams.minGoodPixelQuality = 0.001f * trackBarMinGood.Value;
}
#endregion
}
}