wadimkehl / ssd-6d

Inference code and trained networks for SSD-6D
MIT License
310 stars 78 forks source link

More than one renderer instance #24

Open N-NEJATISHAHIDIN opened 4 years ago

N-NEJATISHAHIDIN commented 4 years ago

I am using your Renderer class for images with different height and width. So, I need to have more than one Renderer instance. Although I clear the previous renderer, I still can not build a new one with different height and width. What is your suggestion?

wadimkehl commented 4 years ago

Hi Negar,

the code is already getting quite out of date ;) If I would start today from scratch, I would take one of the many good Python renderers out there, e.g. pyrender

Rendering is then super simple, and you should be able to have multiple offscreen renderers with different resolutions! Something like this should work:

import cv2
import pyrender
scene = pyrender.Scene()
renderer = pyrender.OffscreenRenderer(1600, 1200)
light = pyrender.DirectionalLight(intensity=3)

# Set up the camera -- X-right, Y-up, Z-back
camera = pyrender.IntrinsicsCamera(512, 512, 800, 600)

mesh = pyrender.Mesh.from_trimesh(trimesh.Trimesh(vertices, faces))
scene.add(mesh)
color, depth = renderer.render(scene)
cv2.imshow('color', color)
cv2.waitKey()
N-NEJATISHAHIDIN commented 4 years ago

Thank you for your prompt reply!