I have to synchronize a Blender video background with Python since, base on what the video is displaying, objects will be created or deleted.
Since the information from which it is possible to know if an object is created or not comes from a python script, I cannot use Blender animation.
So I'd like to access the timeline ad tell which frame has to be displayed each time.
I've tried this code below without success since the code is executed before Blender opens. gen is a generator that gives me the image (frame) and the number of the frame.
for idx, img in gen: bg = cam0.background_images.clear bg = cam0.background_images.new() cv2.imwrite(r"trial\frame%d.jpg" % idx, img) bg.image = bpy.data.images.load(r"C:\path\trial\frame%d.jpg" % idx) #bg.image = img #I also tried to pass directly the image print("done") #other code that will elaborate the info #other code that will change objects
Thank you in advice.