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()
cam.set(libcamera.Brightness,0.2)
def take_picture(cv2,ret,cam,save):
#print(“starting”)
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:
continue
# Get image data
# At present, only RGB888, BGR888, XRGB8888 can be displayed directly, no conversion
#print("reading="+str(fflag))
frame = data.imageData
if (save):
cv2.imwrite('/mnt/ramdisk/Camera_output.jpg',frame)
print("Picture taken")
"""
Return image buffer
:param data: Send image data back
"""
cam.returnFrameBuffer(data)
break