mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-26 13:07:33 +02:00
[blender] preview: clear loaded images to avoid memory leak
This commit is contained in:
parent
7e6ce90234
commit
94491994a5
1 changed files with 11 additions and 6 deletions
|
@ -151,12 +151,11 @@ def setupBackground(view, folderUndistorted):
|
|||
matches = glob.glob(folderUndistorted + '/*' + baseImgName + "*") # try with image name
|
||||
if len(matches) == 0:
|
||||
# no background image found
|
||||
return False
|
||||
return None
|
||||
undistortedImgPath = matches[0]
|
||||
bpy.ops.image.open(filepath=undistortedImgPath)
|
||||
undistortedImgName = os.path.basename(undistortedImgPath)
|
||||
bpy.context.scene.node_tree.nodes["Image"].image = bpy.data.images[undistortedImgName]
|
||||
return True
|
||||
img = bpy.data.images.load(filepath=undistortedImgPath)
|
||||
bpy.context.scene.node_tree.nodes["Image"].image = img
|
||||
return img
|
||||
|
||||
|
||||
def loadModel(filename):
|
||||
|
@ -335,14 +334,20 @@ def main():
|
|||
continue
|
||||
|
||||
print("Rendering view " + view['viewId'])
|
||||
img = None
|
||||
if args.useBackground:
|
||||
if not setupBackground(view, args.undistortedImages):
|
||||
img = setupBackground(view, args.undistortedImages)
|
||||
if not img:
|
||||
# background setup failed
|
||||
# do not render this frame
|
||||
continue
|
||||
setupRender(view, intrinsic, pose, args.output)
|
||||
bpy.ops.render.render(write_still=True)
|
||||
|
||||
if img:
|
||||
# clear memory
|
||||
bpy.data.images.remove(img)
|
||||
|
||||
print("Done")
|
||||
return 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue