I have made a program that uses three webcams and three ultrasonic sensors using raspberry pi 3 and python 3. When each ultrasonic sensors detect stuff in front of them, webcam take a picture of it. In short, one ultrasonic sensor and one webcam work as a unit and there are 3 units. I made this as a class and each instances uses different gpio pins and camera numbers and runs as a thread.

At now I have added one more webcam to raspberry pi 3 to use it as a cctv. I use mjpg-streamer and it also runs as a thread.

I thought it works well but sometimes mjpg-streamer or a webcam being used to mjpg-streamer suddenly stops working.. below code is part of my program that executes mjpg-streamer.

def cctv():
    while True:
        command = 'mjpg_streamer -i "input_uvc.so -d /dev/video6 -r 640x480" -o "output_http.so -p 8000 -w /usr/local/share/mjpg-streamer/www/"'
        output, error = subprocess.Popen(command, universal_newlines=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()

cctv_play = threading.Thread(target=cctv, args=())

And after mjpg-streamer stops working, a webcam that mjpg-streamer uses doesn't work anymore even if other webcams still works well. I have to reboot raspberry pi 3 to use it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.