1

I am trying to use this script with my raspi to open another script when a button is released, and close the opened script when the button is pressed.

If i hold the button i get a constant feed of "camera is not on" which is good thats what i want it to do, Then when i release the button the script opens as it should and my output says "camera is on" and the camera turns on also good. I need to call this script to open the camera.

This is what I have so far.

from gpiozero import Button
import sys
import os
import subprocess

button = Button(17)
p = subprocess.Popen(['python', 'objectident.py', 'arg1', 'arg2'])


while True:

    if button.is_pressed:
        print("camera is not on")
        p.terminate()
        p.wait()
    else:
        print("camera is on")
        os.system("python objectident.py")
        continue

This is the output that I am getting. Image of output

any help would be greatly appreciated this is my first big python project, and for some reason i cant find the solution i am looking for.

Sam
  • 11
  • 1
  • you should look at this post: https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/ – XxJames07- Feb 04 '22 at 16:23
  • Thank you, the script that I'm calling on is actually already using opencv and coco. – Sam Feb 04 '22 at 16:27

0 Answers0