File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -703,6 +703,25 @@ def continuous_capture_start(self):
703
703
"""Switch the camera to continuous-capture mode"""
704
704
pass # pylint: disable=unnecessary-pass
705
705
706
+ def capture_into_jpeg (self ):
707
+ """Captures an image and returns it in JPEG format.
708
+
709
+ Returns:
710
+ bytes: The captured image in JPEG format, otherwise None if the capture failed.
711
+ """
712
+ self .camera .reconfigure (
713
+ pixel_format = espcamera .PixelFormat .JPEG ,
714
+ frame_size = self .resolution_to_frame_size [self ._resolution ],
715
+ )
716
+ time .sleep (0.1 )
717
+ jpeg = self .camera .take (1 )
718
+ if jpeg is not None :
719
+ print (f"Captured { len (jpeg )} bytes of jpeg data" )
720
+ print ("Resolution %d x %d" % (self .camera .width , self .camera .height ))
721
+ else :
722
+ print ("JPEG capture failed" )
723
+ return jpeg
724
+
706
725
def capture_into_bitmap (self , bitmap ):
707
726
"""Capture an image and blit it into the given bitmap"""
708
727
bitmaptools .blit (bitmap , self .continuous_capture (), 0 , 0 )
You can’t perform that action at this time.
0 commit comments