steveyin commited on
Commit
243d1e8
·
verified ·
1 Parent(s): 7dcc0c6

Update webapp.py

Browse files
Files changed (1) hide show
  1. webapp.py +42 -14
webapp.py CHANGED
@@ -280,13 +280,27 @@ class DemoCase:
280
  while True:
281
  if self._is_running:
282
  if self.stream0 is None:
283
- # Start the stream, set desired resolution to be 720p
284
- self.stream0 = CamGear(
285
- source=self.url_dict[self.cam_loc],
286
- colorspace=None,
287
- stream_mode=True,
288
- logging=True,
289
- ).start()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
 
291
  try:
292
  # loop over frames
@@ -386,13 +400,27 @@ class DemoCase:
386
  while True:
387
  if self._is_running:
388
  if self.stream1 is None:
389
- # Start the stream, set desired quality as 720p
390
- self.stream1 = CamGear(
391
- source=self.url_dict[self.cam_loc],
392
- colorspace=None,
393
- stream_mode=True,
394
- logging=True
395
- ).start()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  if (self._is_tracking and self.stream1 is not None):
398
  if self.counter is None or self._roi_changed:
 
280
  while True:
281
  if self._is_running:
282
  if self.stream0 is None:
283
+ try:
284
+ # Start the stream, set desired resolution to be 720p
285
+ options = {"STREAM_RESOLUTION": "720p"}
286
+ self.stream0 = CamGear(
287
+ source=self.url_dict[self.cam_loc],
288
+ colorspace=None,
289
+ stream_mode=True,
290
+ logging=True,
291
+ **options
292
+ ).start()
293
+ except:
294
+ # Start the stream, set best resolution
295
+ self.stream0 = CamGear(
296
+ source=self.url_dict[self.cam_loc],
297
+ colorspace=None,
298
+ stream_mode=True,
299
+ logging=True
300
+ ).start()
301
+ logging.warning(
302
+ "failed to connect {self.url_dict[self.cam_loc]} at 720p resolution, use best resolution"
303
+ )
304
 
305
  try:
306
  # loop over frames
 
400
  while True:
401
  if self._is_running:
402
  if self.stream1 is None:
403
+ try:
404
+ # Start the stream, set desired quality as 720p
405
+ options = {"STREAM_RESOLUTION": "720p"}
406
+ self.stream1 = CamGear(
407
+ source=self.url_dict[self.cam_loc],
408
+ colorspace=None,
409
+ stream_mode=True,
410
+ logging=True,
411
+ **options
412
+ ).start()
413
+ except:
414
+ # Start the stream, use the best resolution
415
+ self.stream1 = CamGear(
416
+ source=self.url_dict[self.cam_loc],
417
+ colorspace=None,
418
+ stream_mode=True,
419
+ logging=True
420
+ ).start()
421
+ logging.warning(
422
+ "failed to connect {self.url_dict[self.cam_loc]} at 720p resolution, use best resolution"
423
+ )
424
 
425
  if (self._is_tracking and self.stream1 is not None):
426
  if self.counter is None or self._roi_changed: