Rewrite variable every n times - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Rewrite variable every n times (/thread-4484.html) |
Rewrite variable every n times - andrea0913 - Aug-20-2017 I'm doing image processing with cv2, and i need to replace the background every 30 seconds during 2 minutes. The background will be something like a photo of the current chroma. def Foto(): cv2.imwrite("Fondo1.jpg",entrada4) entrada = cv2.imread("Fondo1.jpg") .... t = threading.Timer(3.0,Foto) t.start()I think the problem is i'm defining "entrada" at the begining of my code but also defining "entrada" in the funtion Foto() entrada = cv2.imread("Fondo.jpg") def Foto(): cv2.imwrite("Fondo1.jpg",entrada4) entrada = cv2.imread("Fondo1.jpg") .... t = threading.Timer(3.0,Foto) t.start()I need every 30 seconds it rewrites the image "fondo1" and replace "entrada" with that image. Like taking a photo of what the chroma is showing and change the background witht the photo. |