@@ -1369,53 +1369,47 @@ def _decode_thread(
13691369 # We don't do any kind of locking here since the worst-case of this being wrong
13701370 # is that we do some extra work, and this function should never mutate any data
13711371 # (all of which should be modified under the GIL).
1372- # TODO(v1.0): This optimization should be removed as it is an uncommon use case and
1373- # greatly increases the complexity of detection algorithms using it.
1374- if self ._is_processing_required (video .position ._frame_num ):
1375- frame_im = video .read ()
1376- if frame_im is False :
1377- break
1378- # Verify the decoded frame size against the video container's reported
1379- # resolution, and also verify that consecutive frames have the correct size.
1380- decoded_size = (frame_im .shape [1 ], frame_im .shape [0 ])
1381- if self ._frame_size is None :
1382- self ._frame_size = decoded_size
1383- if video .frame_size != decoded_size :
1384- logger .warn (
1385- f"WARNING: Decoded frame size ({ decoded_size } ) does not match "
1386- f" video resolution { video .frame_size } , possible corrupt input."
1387- )
1388- elif self ._frame_size != decoded_size :
1389- self ._frame_size_errors += 1
1390- if self ._frame_size_errors <= MAX_FRAME_SIZE_ERRORS :
1391- logger .error (
1392- f"ERROR: Frame at { str (video .position )} has incorrect size and "
1393- f"cannot be processed: decoded size = { decoded_size } , "
1394- f"expected = { self ._frame_size } . Video may be corrupt."
1395- )
1396- if self ._frame_size_errors == MAX_FRAME_SIZE_ERRORS :
1397- logger .warn (
1398- "WARNING: Too many errors emitted, skipping future messages."
1399- )
1400- # Skip processing frames that have an incorrect size.
1401- continue
1402-
1403- if self ._crop :
1404- (x0 , y0 , x1 , y1 ) = self ._crop
1405- frame_im = frame_im [y0 :y1 , x0 :x1 ]
1406-
1407- if downscale_factor > 1.0 :
1408- frame_im = cv2 .resize (
1409- frame_im ,
1410- (
1411- max (1 , round (frame_im .shape [1 ] / downscale_factor )),
1412- max (1 , round (frame_im .shape [0 ] / downscale_factor )),
1413- ),
1414- interpolation = self ._interpolation .value ,
1372+ frame_im = video .read ()
1373+ if frame_im is False :
1374+ break
1375+ # Verify the decoded frame size against the video container's reported
1376+ # resolution, and also verify that consecutive frames have the correct size.
1377+ decoded_size = (frame_im .shape [1 ], frame_im .shape [0 ])
1378+ if self ._frame_size is None :
1379+ self ._frame_size = decoded_size
1380+ if video .frame_size != decoded_size :
1381+ logger .warn (
1382+ f"WARNING: Decoded frame size ({ decoded_size } ) does not match "
1383+ f" video resolution { video .frame_size } , possible corrupt input."
14151384 )
1416- else :
1417- if video .read (decode = False ) is False :
1418- break
1385+ elif self ._frame_size != decoded_size :
1386+ self ._frame_size_errors += 1
1387+ if self ._frame_size_errors <= MAX_FRAME_SIZE_ERRORS :
1388+ logger .error (
1389+ f"ERROR: Frame at { str (video .position )} has incorrect size and "
1390+ f"cannot be processed: decoded size = { decoded_size } , "
1391+ f"expected = { self ._frame_size } . Video may be corrupt."
1392+ )
1393+ if self ._frame_size_errors == MAX_FRAME_SIZE_ERRORS :
1394+ logger .warn (
1395+ "WARNING: Too many errors emitted, skipping future messages."
1396+ )
1397+ # Skip processing frames that have an incorrect size.
1398+ continue
1399+
1400+ if self ._crop :
1401+ (x0 , y0 , x1 , y1 ) = self ._crop
1402+ frame_im = frame_im [y0 :y1 , x0 :x1 ]
1403+
1404+ if downscale_factor > 1.0 :
1405+ frame_im = cv2 .resize (
1406+ frame_im ,
1407+ (
1408+ max (1 , round (frame_im .shape [1 ] / downscale_factor )),
1409+ max (1 , round (frame_im .shape [0 ] / downscale_factor )),
1410+ ),
1411+ interpolation = self ._interpolation .value ,
1412+ )
14191413
14201414 # Set the start position now that we decoded at least the first frame.
14211415 if self ._start_pos is None :
@@ -1505,9 +1499,3 @@ def get_event_list(self, base_timecode: ty.Optional[FrameTimecode] = None) -> Sc
15051499 # TODO(v0.7): Use the warnings module to turn this into a warning.
15061500 logger .error ("`get_event_list()` is deprecated and will be removed in a future release." )
15071501 return self ._get_event_list ()
1508-
1509- def _is_processing_required (self , frame_num : int ) -> bool :
1510- """True if frame metrics not in StatsManager, False otherwise."""
1511- if self .stats_manager is None :
1512- return True
1513- return all ([detector .is_processing_required (frame_num ) for detector in self ._detector_list ])
0 commit comments