64mp - What is the quickest way to grab an image in python?

Hello, I am building a machine that needs to take an image from the 64mp hawkeye camera.

I am happy to initialize the camera once before the machine needs to take a picture, but I need to get a picture/frame as quickly as possible once the user presses the start button. I am currently using the libcamera library. With this code it takes around 5 seconds to get a picture. Does anybody know of a wat to get an image much quicker ? Thanks.

Here is a sample of the code I am following:

import os,time
import libcamera

def init_cameras(cv2):

width = 4626 #9152     had to lower the resolution due to insufficient buffer errors !
height = 3472 #6944 

# Instantiate the libcamera class
cam = libcamera.libcamera()

ret = cam.initCamera(width, height, libcamera.PixelFormat.RGB888, buffercount=1 , rotation=0)

# Turn on the camera
ret = cam.startCamera()

def take_picture(cv2,ret,cam,save):
print(“in take_picture”)
# Capture frame-by-frame

while True:

        Read image information
        :returns ret: Whether the image is successfully read
        :returns data: Image data information
        ret, data = cam.readFrame()

        if not ret:

        # Get image data
        # At present, only RGB888, BGR888, XRGB8888 can be displayed directly, no conversion
        frame = data.imageData

        if (save):
            print("Picture taken")

        Return image buffer

        :param data: Send image data back


you can use picamera2.
But it takes time for the camera to start up.


Many thanks for the reply.

Could you show me what is in line 1 to 27 of your code please.

I have tried copying your code but I am getting an error.



The previous code is other processing I did, it doesn’t affect the code itself, can you show me the error report?


Many thanks for your quick reply.

I have now got the code working. It seems to work very well and I think it will be acceptable for my project.

Many thanks.