I'm using my raspberry pi to detect when my cats are on the table, and I'm having a bit of trouble with a couple of the image capture pieces. Here's the relevant code I'm running:
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import subprocess
#method 1
with PiCamera() as camera:
capImg = PiRGBArray(camera)
time.sleep(0.1)
camera.capture(capImg,format = 'bgr')
image = capImg.array
cv2.imwrite('image4.bmp',image)
#method 2
callString = 'raspistill -n -w %s -h %s -o /home/pi/python/catcam/image5.bmp --timeout 0' % (640,480)
subprocess.call(callString, shell = True)
Is there a way to keep raspistill images in memory or do something like camera.capture_continuous? Comparing the quality of the picamera image:
the colors are much better with raspistill:
I'd like to capture an image every few seconds, but don't want to be writing to disk for every single image or I'll burn my memory card out quite quickly. Also, raspistill is quite slow.
Any pointers on how to capture better quality images at a constant rate would be much appreciated!
EDIT Thanks to Mark below, I have edited post to current issue at hand.
According to this: How to make a temporary file in RAM?
You should be able to allocate some space in RAM directly as a user (but you need root permissions).
Creating a new mount partition of size 500 MB:
# this is bash, not python
mount -t tmpfs -o size=500m tmpfs /mountpoint
And utilize it as any other space you have
# this too
raspistill -n -w %s -h %s -o /mountpoint/image5.bmp --timeout 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With