@@ -19,23 +19,155 @@ VideoCapture_LibRealsense::VideoCapture_LibRealsense(int) : mAlign(RS2_STREAM_CO
19
19
config.enable_stream (RS2_STREAM_DEPTH, 640 , 480 , RS2_FORMAT_Z16);
20
20
config.enable_stream (RS2_STREAM_COLOR, 640 , 480 , RS2_FORMAT_BGR8);
21
21
config.enable_stream (RS2_STREAM_INFRARED, 640 , 480 , RS2_FORMAT_Y8);
22
- mPipe .start ();
22
+ mPipe .start (config );
23
23
}
24
24
catch (const rs2::error&)
25
25
{
26
26
}
27
27
}
28
28
VideoCapture_LibRealsense::~VideoCapture_LibRealsense (){}
29
29
30
- double VideoCapture_LibRealsense::getProperty (int prop ) const
30
+ double VideoCapture_LibRealsense::getProperty (int propIdx ) const
31
31
{
32
- double propValue = 0 ;
32
+ double propValue = 0.0 ;
33
33
34
- if (prop == CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE)
35
- return mPipe .get_active_profile ().get_device ().first <rs2::depth_sensor>().get_depth_scale ();
34
+ const int purePropIdx = propIdx & ~CAP_INTELPERC_GENERATORS_MASK;
35
+ if ((propIdx & CAP_INTELPERC_GENERATORS_MASK) == CAP_INTELPERC_IMAGE_GENERATOR)
36
+ {
37
+ propValue = getImageGeneratorProperty (purePropIdx);
38
+ }
39
+ else if ((propIdx & CAP_INTELPERC_GENERATORS_MASK) == CAP_INTELPERC_DEPTH_GENERATOR)
40
+ {
41
+ propValue = getDepthGeneratorProperty (purePropIdx);
42
+ }
43
+ else if ((propIdx & CAP_INTELPERC_GENERATORS_MASK) == CAP_INTELPERC_IR_GENERATOR)
44
+ {
45
+ propValue = getIrGeneratorProperty (purePropIdx);
46
+ }
47
+ else
48
+ {
49
+ propValue = getCommonProperty (purePropIdx);
50
+ }
36
51
37
52
return propValue;
38
53
}
54
+
55
+ double VideoCapture_LibRealsense::getImageGeneratorProperty (int propIdx) const
56
+ {
57
+ double propValue = 0.0 ;
58
+ const rs2::video_stream_profile profile = mPipe .get_active_profile ().get_stream (RS2_STREAM_COLOR).as <rs2::video_stream_profile>();
59
+ if (!profile)
60
+ {
61
+ return propValue;
62
+ }
63
+
64
+ switch (propIdx)
65
+ {
66
+ case CAP_PROP_FRAME_WIDTH:
67
+ propValue = static_cast <double >(profile.width ());
68
+ break ;
69
+ case CAP_PROP_FRAME_HEIGHT:
70
+ propValue = static_cast <double >(profile.height ());
71
+ break ;
72
+ case CAP_PROP_FPS:
73
+ propValue = static_cast <double >(profile.fps ());
74
+ break ;
75
+ }
76
+
77
+ return propValue;
78
+ }
79
+
80
+ double VideoCapture_LibRealsense::getDepthGeneratorProperty (int propIdx) const
81
+ {
82
+ double propValue = 0.0 ;
83
+ const rs2::video_stream_profile profile = mPipe .get_active_profile ().get_stream (RS2_STREAM_DEPTH).as <rs2::video_stream_profile>();
84
+ const rs2::depth_sensor sensor = mPipe .get_active_profile ().get_device ().first <rs2::depth_sensor>();
85
+ if (!profile || !sensor)
86
+ {
87
+ return propValue;
88
+ }
89
+
90
+ switch (propIdx)
91
+ {
92
+ case CAP_PROP_FRAME_WIDTH:
93
+ propValue = static_cast <double >(profile.width ());
94
+ break ;
95
+ case CAP_PROP_FRAME_HEIGHT:
96
+ propValue = static_cast <double >(profile.height ());
97
+ break ;
98
+ case CAP_PROP_FPS:
99
+ propValue = static_cast <double >(profile.fps ());
100
+ break ;
101
+ case CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
102
+ propValue = static_cast <double >(sensor.get_depth_scale ());
103
+ break ;
104
+ case CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ:
105
+ propValue = static_cast <double >(profile.get_intrinsics ().fx );
106
+ break ;
107
+ case CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT:
108
+ propValue = static_cast <double >(profile.get_intrinsics ().fy );
109
+ break ;
110
+ }
111
+
112
+ return propValue;
113
+ }
114
+
115
+ double VideoCapture_LibRealsense::getIrGeneratorProperty (int propIdx) const
116
+ {
117
+ double propValue = 0.0 ;
118
+ const rs2::video_stream_profile profile = mPipe .get_active_profile ().get_stream (RS2_STREAM_INFRARED).as <rs2::video_stream_profile>();
119
+ if (!profile)
120
+ {
121
+ return propValue;
122
+ }
123
+
124
+ switch (propIdx)
125
+ {
126
+ case CAP_PROP_FRAME_WIDTH:
127
+ propValue = static_cast <double >(profile.width ());
128
+ break ;
129
+ case CAP_PROP_FRAME_HEIGHT:
130
+ propValue = static_cast <double >(profile.height ());
131
+ break ;
132
+ case CAP_PROP_FPS:
133
+ propValue = static_cast <double >(profile.fps ());
134
+ break ;
135
+ }
136
+
137
+ return propValue;
138
+ }
139
+
140
+ double VideoCapture_LibRealsense::getCommonProperty (int propIdx) const
141
+ {
142
+ double propValue = 0.0 ;
143
+ const rs2::video_stream_profile profile = mPipe .get_active_profile ().get_stream (RS2_STREAM_DEPTH).as <rs2::video_stream_profile>();
144
+ const rs2::depth_sensor sensor = mPipe .get_active_profile ().get_device ().first <rs2::depth_sensor>();
145
+ if (!profile || !sensor)
146
+ {
147
+ return propValue;
148
+ }
149
+
150
+ switch (propIdx)
151
+ {
152
+ case CAP_PROP_FRAME_WIDTH:
153
+ case CAP_PROP_FRAME_HEIGHT:
154
+ case CAP_PROP_FPS:
155
+ propValue = getDepthGeneratorProperty (propIdx);
156
+ break ;
157
+ case CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
158
+ propValue = static_cast <double >(sensor.get_depth_scale ());
159
+ break ;
160
+ case CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ:
161
+ propValue = static_cast <double >(profile.get_intrinsics ().fx );
162
+ break ;
163
+ case CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT:
164
+ propValue = static_cast <double >(profile.get_intrinsics ().fy );
165
+ break ;
166
+ }
167
+
168
+ return propValue;
169
+ }
170
+
39
171
bool VideoCapture_LibRealsense::setProperty (int , double )
40
172
{
41
173
bool isSet = false ;
0 commit comments