<tfoot id='fOKxm'></tfoot>
    1. <i id='fOKxm'><tr id='fOKxm'><dt id='fOKxm'><q id='fOKxm'><span id='fOKxm'><b id='fOKxm'><form id='fOKxm'><ins id='fOKxm'></ins><ul id='fOKxm'></ul><sub id='fOKxm'></sub></form><legend id='fOKxm'></legend><bdo id='fOKxm'><pre id='fOKxm'><center id='fOKxm'></center></pre></bdo></b><th id='fOKxm'></th></span></q></dt></tr></i><div id='fOKxm'><tfoot id='fOKxm'></tfoot><dl id='fOKxm'><fieldset id='fOKxm'></fieldset></dl></div>

      <small id='fOKxm'></small><noframes id='fOKxm'>

        • <bdo id='fOKxm'></bdo><ul id='fOKxm'></ul>
      1. <legend id='fOKxm'><style id='fOKxm'><dir id='fOKxm'><q id='fOKxm'></q></dir></style></legend>

        通过 Blender python 渲染和保存图像

        时间:2023-10-19

              <tbody id='OWmRu'></tbody>
          • <legend id='OWmRu'><style id='OWmRu'><dir id='OWmRu'><q id='OWmRu'></q></dir></style></legend>
            • <bdo id='OWmRu'></bdo><ul id='OWmRu'></ul>

                <tfoot id='OWmRu'></tfoot>

                  <small id='OWmRu'></small><noframes id='OWmRu'>

                  <i id='OWmRu'><tr id='OWmRu'><dt id='OWmRu'><q id='OWmRu'><span id='OWmRu'><b id='OWmRu'><form id='OWmRu'><ins id='OWmRu'></ins><ul id='OWmRu'></ul><sub id='OWmRu'></sub></form><legend id='OWmRu'></legend><bdo id='OWmRu'><pre id='OWmRu'><center id='OWmRu'></center></pre></bdo></b><th id='OWmRu'></th></span></q></dt></tr></i><div id='OWmRu'><tfoot id='OWmRu'></tfoot><dl id='OWmRu'><fieldset id='OWmRu'></fieldset></dl></div>
                1. 本文介绍了通过 Blender python 渲染和保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试通过搅拌机中的 python 脚本渲染和保存多个图像.我知道如何通过 Blender GUI 渲染和保存图像,但我想通过我的脚本来完成这一切,因为我使用了一组嵌套循环并且需要保存多个图像.我能够渲染图像,我猜想在输出成功的情况下保存图像.但我不确定它保存到哪里,当我尝试编辑文件路径时,它会给我上下文不正确的错误.

                  I am trying to render and save multiple images through python script in blender. I know how to render and save the image through the Blender GUI but I want to do it all through my script since I am using a set of nested loops and need to save multiple images. I am able to render the image and I guess save the image with the output being successful. But I am not sure where it saves to and when I try to edit the filepath it gives me the error of the context being incorrect.

                  推荐答案

                  下面的代码创建了一个VR全景";(一个物体的一系列图片,从它周围的不同角度).

                  The code below creates a "VR panorama" (a series of pictures of an object, from different perspectives around it).

                  我最终得到了这个算法:

                  I ended up with this algorithm:

                  1. 创建或加载您要拍摄的对象(主题)
                  2. 缩放它并添加一些漂亮的照明(以便从您想要的方向看到对象);您可以通过渲染场景来检查照明(使用 F12 键)
                  3. 创建一个Empty对象,并将其位置设置为主体中心,旋转为identity (0, 0, 0)
                  4. 将您的相机视图设置为起始位置(再次检查渲染)
                  5. 打开交互式 Python shell (Shift+F4)
                  6. 粘贴&运行脚本
                  1. create or load an object you are going to take pictures of (the subject)
                  2. scale it and add some nice lighting (so that the object is visible from directions you want); you can check the lighting by rendering the scene (using the F12 key)
                  3. create an Empty object and set its position to the center of the subject and rotation to identity (0, 0, 0)
                  4. set your camera view to the starting position (check it with rendering, again)
                  5. open interactive Python shell (Shift+F4)
                  6. paste & run the script

                  您最终会在 /Users/myusername/Pictures/VR 下的对象周围获得许多图片(由 rotation_steps 定义)目录:

                  You shall end up with a number of pictures (defined by rotation_steps) around your object under /Users/myusername/Pictures/VR directory:

                  def rotate_and_render(output_dir, output_file_pattern_string = 'render%d.jpg', rotation_steps = 32, rotation_angle = 360.0, subject = bpy.context.object):
                    import os
                    original_rotation = subject.rotation_euler
                    for step in range(0, rotation_steps):
                      subject.rotation_euler[2] = radians(step * (rotation_angle / rotation_steps))
                      bpy.context.scene.render.filepath = os.path.join(output_dir, (output_file_pattern_string % step))
                      bpy.ops.render.render(write_still = True)
                    subject.rotation_euler = original_rotation
                  
                  rotate_and_render('/Users/myusername/Pictures/VR', 'render%d.jpg')
                  

                  您必须选择要渲染的对象.或者,您可以使用 Blender 的 Python API 在场景并将其作为 subject 参数传递给函数:

                  You will have to select the object you want to render. Alternatively, you can use Blender's Python API to find the object in the scene and pass it as a subject param to the function:

                  rotate_and_render('/Users/myusername/Pictures/VR', 'render%d.jpg', subject = bpy.data.objects["Cube"])
                  

                  这篇关于通过 Blender python 渲染和保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 python 2.7 中下载并保存文件? 下一篇:Python - 如何保存函数

                  相关文章

                    <bdo id='TqYVQ'></bdo><ul id='TqYVQ'></ul>
                  <tfoot id='TqYVQ'></tfoot>

                  <small id='TqYVQ'></small><noframes id='TqYVQ'>

                2. <i id='TqYVQ'><tr id='TqYVQ'><dt id='TqYVQ'><q id='TqYVQ'><span id='TqYVQ'><b id='TqYVQ'><form id='TqYVQ'><ins id='TqYVQ'></ins><ul id='TqYVQ'></ul><sub id='TqYVQ'></sub></form><legend id='TqYVQ'></legend><bdo id='TqYVQ'><pre id='TqYVQ'><center id='TqYVQ'></center></pre></bdo></b><th id='TqYVQ'></th></span></q></dt></tr></i><div id='TqYVQ'><tfoot id='TqYVQ'></tfoot><dl id='TqYVQ'><fieldset id='TqYVQ'></fieldset></dl></div>
                  1. <legend id='TqYVQ'><style id='TqYVQ'><dir id='TqYVQ'><q id='TqYVQ'></q></dir></style></legend>