Forum

How do I render a model at the camera viewpoints?

Started by Goldname, July 12, 2019, 06:04:09 AM

Previous topic - Next topic

Goldname

Hello,
I realize this old thread exists: https://www.agisoft.com/forum/index.php?topic=7615.0

I am using part of their code on Windows, but after modifying their example to work on Windows, the software just gives me "unknown image format".

import PhotoScan, os
chunk = PhotoScan.app.document.chunk
for camera in chunk.cameras:
   if not chunk.model:
      print(" no model" )
      break
   if not camera.transform:
      continue
   render = chunk.model.renderImage(camera.transform, camera.sensor.calibration)
   render.save(os.path.dirname("C:\\Users\\user1\\Desktop\\Temp\\render" + camera.label[:-4] + "_render.jpg"))

Alexey Pasumansky

Hello Goldname,

I think the problem is in os.path.dirname utilization. You are passing the path to the folder instead of the file path to the .save command.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Goldname

Hi,

What do you mean by passing the directory? I believe I am passing the filename into the command: ("C:\\Users\\cs_u\\Desktop\\Temp\\render" + camera.label[:-4] + "_render.jpg"), where render + camera label + _render.jpg is the filename.

Thanks

Alexey Pasumansky

Hello Goldname,

The path argument for the save operation in your code is:
os.path.dirname("C:\\Users\\user1\\Desktop\\Temp\\render" + camera.label[:-4] + "_render.jpg")
and not
"C:\\Users\\user1\\Desktop\\Temp\\render" + camera.label[:-4] + "_render.jpg"
Best regards,
Alexey Pasumansky,
Agisoft LLC