-
Where did you get the camera module(s)?
Robu.in -
Model number of the product(s)?
IMX519 16MP AutoFocus -
What hardware/platform were you working on?
Raspberry Pi 2, headless raspbian-lite -
Instructions you have followed. (link/manual/etc.)
16MP IMX519 - Arducam Wiki -
Problems you were having?
Getting very low FPS(5fps) using PiCamera2 library -
The dmesg log from your hardware?
-
Troubleshooting attempts you’ve made?
Running capture_array() method in separate thread but 5FPS seems to be the fastest it can go. Currently I set the resolution at 1920x1080 with RGB format. -
What help do you need?
Specifications from camera make it clear that FPS of the cam can go as fast as 80fps. I am probably using a slower method to fetch the frames. I want help in figuring out how to increase FPS as my application needs to be real-time. I timed Picamera2.capture_buffer() method and it takes 0.17-0.19 seconds consistently to return a frame. I hope its my way of capturing the frame which is slowing the FPS, there must be some better way to take continuous images. Also, I need to have access to each frame and hence, directly recording video is not beneficial.
Code Snippets:
def __init__(self, camID):
"""
Connects to a given arducam at camID and loads default
configuration
"""
self.picam = Picamera2(camera_num=camID) # connects to camID indexed cam
self.ID = camID
self.config = None
# Initialize camera
self.configure()
self.start()
self.setFocus()
# Start reading frames from camera in a new thread
self.bufferQ = deque()
self.bufferSize = 15
self.captureThread = threading.Thread(target=self.buffering)
self.captureThread.start()
def configure(self):
"""
TODO: Loads given configuration for the camera:
"""
self.picam.still_configuration.main.size=(1920,1080)
self.picam.still_configuration.main.format="RGB888"
self.picam.still_configuration.align()
self.picam.configure("still")
def buffering(self, checkFPS=False):
"""
This function will continuously read frames and put it into a buffer queue.
"""
imageCounter = 0
startTime = time.time()
while True:
if len(self.bufferQ) < self.bufferSize:
self.bufferQ.append(self.imread())
else:
self.bufferQ.popleft()
self.bufferQ.append(self.imread())
imageCounter += 1
if checkFPS and imageCounter % 100 == 0:
endTime = time.time()
self.realFPS = imageCounter/(endTime-startTime)
# print(f"[ArduCAM]:[buffering]: Real FPS: {self.realFPS}: {imageCounter}/{endTime-startTime}")
# Reset
startTime = time.time()
imageCounter = 0
def imread(self):
"""
Similar to OpenCV's imread. Returns frame. TODO: Overload
with meta-data yeild
"""
s = time.time()
frame = self.picam.capture_array() # Returns a np-array type frame.
# print(f"[ArduCAM]:[Capturing Time]: {time.time()-s} seconds")
return frame