@@ -495,31 +495,38 @@ def capture(self):
495
495
self .last_capture_time = ts
496
496
497
497
# Retrieve the next image from the camera
498
- image = self .camera .GetNextImage (1000 )
499
-
500
- while image .IsIncomplete ():
501
- time .sleep (0.001 )
498
+ try :
499
+ image = self .camera .GetNextImage (1000 )
500
+ if image .IsIncomplete ():
501
+ logger .error (f"Image incomplete: { self .name (sn_only = True )} , Status: { image .GetImageStatus ()} " )
502
+ print (f"{ self .name (sn_only = True )} Image incomplete: \n \t { image .GetImageStatus ()} " )
503
+ else :
504
+ # Release the previous image from the buffer if it exists
505
+ if self .last_image is not None :
506
+ self .last_image .Release ()
502
507
503
- # Release the previous image from the buffer if it exists
504
- if self .last_image is not None :
505
- try :
506
- self .last_image .Release ()
507
- except PySpin .SpinnakerException :
508
- print ("Spinnaker Exception: Couldn't release last image" )
508
+ # Update the last captured image reference
509
+ self .last_image = image
510
+ self .last_image_filled .set ()
509
511
510
- # Update the last captured image reference
511
- self .last_image = image
512
- self .last_image_filled . set ( )
512
+ except PySpin . SpinnakerException as e :
513
+ logger . error ( f" { self .name ( sn_only = True ) } Couldn't get image \n \t { e } " )
514
+ print ( f" { self .name ( sn_only = True ) } Couldn't get image \n \t { e } " )
513
515
514
- # Record the image if video recording is active
515
- if self .video_recording_on .is_set ():
516
- self .video_recording_idle .clear ()
516
+ # If video recording is active, record the image
517
+ try :
518
+ # Record the image if video recording is active
519
+ if self .video_recording_on .is_set ():
520
+ self .video_recording_idle .clear ()
517
521
518
- frame = self .get_last_image_data ()
519
- frame = cv2 .cvtColor (frame , cv2 .COLOR_RGB2BGR )
522
+ frame = self .get_last_image_data ()
523
+ frame = cv2 .cvtColor (frame , cv2 .COLOR_RGB2BGR )
520
524
521
- self .video_output .write (frame )
522
- self .video_recording_idle .set ()
525
+ self .video_output .write (frame )
526
+ self .video_recording_idle .set ()
527
+ except Exception as e :
528
+ logger .error ("An error occurred while recording the video: " , e )
529
+ print (f"Error { self .name (sn_only = True )} : An error occurred while recording the video." )
523
530
524
531
def get_last_capture_time (self , millisecond = False ):
525
532
"""
0 commit comments