Raspberry Pi takes total 8 seconds to capture the image for two camera. How to reduce time?

98 Views Asked by At

I have two camera connected to RPi (1 USB camera and 1 RPi camera). I need to capture both images to do some processing on them right after image capture

I have this code:

file1 = 'imagecapture' + '_view1.png'
file2 = 'imagecapture'  + '_view2.png'
p1 = subprocess.Popen(
    "sudo raspistill -t 1500 -o {} -w 1920 -h 1080".format(file1), shell=True)

p2 = subprocess.Popen(
    "fswebcam -S 20 --resolution 1920x1080  --rotate -90 --device /dev/video1 {}".format(file2), shell=True)
p1.wait()
p2.wait()
time.sleep(0.2)
GPIO.cleanup()

The sleep I have added to make sure that image is captured and saved in the directory before I read it again and so some processing (I tested it and 2 seconds is sufficient).

This whole process takes 7-8 seconds. How can I make it even quicker? Is it possible to make it 3-4 seconds total (basically 1-2 seconds for image capture)?

RPi Specs:

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

RPi camera: rpi imx477

0

There are 0 best solutions below