0
Good afternoon. I am developing a project where I need to make two cameras to take sequences of photos and stop only after a pre-defined command.
In my current code you need to decide the number of photos you want to be taken, but I wanted him to continue taking photos endlessly until I told him to stop.
thank you and thank you in advance
my cogido acts:
import cv2
import sys
camera1 = 0
camera2 = 1
foto1 = cv2.VideoCapture(camera1)
foto2 = cv2.VideoCapture(camera2)
n = int(input("Quantas fotos deseja tirar?"))
file1 = ("C:/Users/Desktop/software/DISPARO/2CAMERA/Image1_%03i.jpg" %camera)
file2 = ("C:/Users/Desktop/software/DISPARO/2CAMERA/Image2_%03i.jpg" %camera)
while n > camera1 and n>camera2:
ret, frame1 = foto1.read()
ret, frame2 = foto2.read()
cv2.imshow("Camera 1", frame1)
cv2.imshow("camera 2", frame2)
cv2.imwrite(file1,frame1)
cv2.imwrite(file2,frame2)
camera1 += 1
camera2 += 1
print("FINALIZADO!")
you have to rename the files?
– Tmilitino
A doubt. Which key would stop? Which action will stop? Because if it gets infinite loop, the performance will get bad.
– Maury Developer
would stop with the command Ctrl+C
– Edvaldo Teomar
@Edvaldoteomar Do you want this? https://stackoverflow.com/questions/1364173/stopping-python-using-ctrlc/21460045
– Maury Developer
No, I’d just like to know how to take pictures in an infinite loop
– Edvaldo Teomar