Python Forum
Rewrite variable every n times
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rewrite variable every n times
#1
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.
Reply


Messages In This Thread
Rewrite variable every n times - by andrea0913 - Aug-20-2017, 05:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Optmized way to rewrite this very slow code liva28 0 1,496 Jul-18-2021, 12:16 PM
Last Post: liva28
  Cleaner way to rewrite fakka 5 3,077 Dec-05-2019, 04:53 AM
Last Post: stullis
  How do I rewrite this .bat file code onto Python? SteampunkMaverick12 4 2,849 Nov-02-2019, 11:28 PM
Last Post: snippsat
  Rewrite a function to make it work with 'bottle-pymysql' nikos 1 1,976 Feb-26-2019, 02:59 PM
Last Post: nikos
  piexif rewrite exif data yawstick 2 3,324 Oct-09-2018, 08:56 PM
Last Post: yawstick
  Not having to rewrite 'obj.' on each line beuaaa 4 3,152 Sep-30-2018, 02:21 AM
Last Post: micseydel
  How to rewrite image file name based on ocr data.txt kevinchr 0 3,647 Apr-16-2018, 07:09 PM
Last Post: kevinchr
  how do i rewrite this code to give me 10 outputs BlackPimpernel 2 2,668 Mar-29-2018, 11:29 AM
Last Post: BlackPimpernel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020