Skip to content

RenderImage

ipynbFile usdapputils__RenderImage.ipynb

In [2]:

1
2
3
4
from pxr import UsdAppUtils,Usd

from PySide2 import QtOpenGL
from PySide2.QtWidgets import QApplication

In [3]:

1
stage = Usd.Stage.Open("D:/sample/cube.usd")

In [4]:

1
usdCamera = UsdAppUtils.GetCameraAtPath(stage,"/root/Camera/Camera")

In [5]:

1
2
3
4
5
6
7
8
application = QApplication()

glFormat = QtOpenGL.QGLFormat()
glFormat.setSampleBuffers(True)
glFormat.setSamples(4)
glWidget = QtOpenGL.QGLWidget(glFormat)
glWidget.setFixedSize(640,480) # 出力サイズではなく、いい感じにするための値
glWidget.makeCurrent()

In [6]:

1
2
frameRecorder = UsdAppUtils.FrameRecorder()
frameRecorder.SetImageWidth(640)

In [7]:

1
frameRecorder.Record(stage, usdCamera, 0, "./sample.jpg")

Success

1
True

In [8]:

1
2
from IPython.display import Image
Image("./sample.jpg")

Success

```

jpeg

1
```