@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
114
114
115
115
// ----> Set Video parameters
116
116
sl_oc::video::VideoParams params;
117
- params.res = sl_oc::video::RESOLUTION::VGA ;
117
+ params.res = sl_oc::video::RESOLUTION::HD2K ;
118
118
params.fps = sl_oc::video::FPS::FPS_15;
119
119
params.verbose = verbose;
120
120
// <---- Set Video parameters
@@ -146,12 +146,14 @@ int main(int argc, char *argv[])
146
146
updateAllCtrlValues (cap);
147
147
148
148
uint64_t last_ts=0 ;
149
+ uint16_t not_a_new_frame = 0 ;
150
+ int frame_timeout_msec = 100 ;
149
151
150
152
// Infinite video grabbing loop
151
153
while (1 )
152
154
{
153
155
// 3) Get last available frame
154
- const sl_oc::video::Frame frame = cap.getLastFrame ();
156
+ const sl_oc::video::Frame frame = cap.getLastFrame (frame_timeout_msec );
155
157
img_w = frame.width ;
156
158
img_h = frame.height ;
157
159
@@ -178,6 +180,7 @@ int main(int argc, char *argv[])
178
180
// ----> If the frame is valid we can display it
179
181
if (frame.data !=nullptr && frame.timestamp !=last_ts)
180
182
{
183
+ not_a_new_frame=0 ;
181
184
#if 0
182
185
// ----> Video Debug information
183
186
@@ -201,6 +204,17 @@ int main(int argc, char *argv[])
201
204
// 4.c) Show frame
202
205
showImage ( win_name, frameBGR, params.res );
203
206
}
207
+ else if (frame.timestamp ==last_ts)
208
+ {
209
+ not_a_new_frame++;
210
+ std::cout << " Not a new frame #" << not_a_new_frame << std::endl;
211
+
212
+ if ( not_a_new_frame>=(3000 /frame_timeout_msec)) // Lost connection for 5 seconds
213
+ {
214
+ std::cout << " Camera connection lost. Closing..." << std::endl;
215
+ break ;
216
+ }
217
+ }
204
218
// <---- If the frame is valid we can display it
205
219
206
220
// ----> Keyboard handling
0 commit comments