/
RsThresholdFilter.cs
62 lines (51 loc) · 1.33 KB
/
RsThresholdFilter.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
using Intel.RealSense;
using UnityEngine;
[ProcessingBlockDataAttribute(typeof(ThresholdFilter))]
[HelpURL("https://github.com/IntelRealSense/librealsense/blob/master/doc/post-processing-filters.md#hole-filling-filter")]
public class RsThresholdFilter : RsProcessingBlock
{
/// <summary>
/// Min range in meters
/// </summary>
[Range(0f, 16f)]
public float MinDistance = 0.1f;
/// <summary>
/// Max range in meters
/// </summary>
[Range(0f, 16f)]
public float MaxDistance = 4f;
private ThresholdFilter _pb;
private IOption minOption;
private IOption maxOption;
public void Init()
{
_pb = new ThresholdFilter();
minOption = _pb.Options[Option.MinDistance];
maxOption = _pb.Options[Option.MaxDistance];
}
void OnDisable()
{
if (_pb != null)
_pb.Dispose();
}
public override Frame Process(Frame frame, FrameSource frameSource)
{
if (_pb == null)
{
Init();
}
UpdateOptions();
return _pb.Process(frame);
}
public void SetMinDistance(float v) {
MinDistance = v;
}
public void SetMaxDistance(float v) {
MaxDistance = v;
}
private void UpdateOptions()
{
minOption.Value = MinDistance;
maxOption.Value = MaxDistance;
}
}