Forum

Author Topic: How do I render a model at the camera viewpoints?  (Read 2684 times)

Goldname

  • Newbie
  • *
  • Posts: 6
    • View Profile
How do I render a model at the camera viewpoints?
« on: July 12, 2019, 06:04:09 AM »
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"))
« Last Edit: July 12, 2019, 08:19:28 AM by Goldname »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: How do I render a model at the camera viewpoints?
« Reply #1 on: July 12, 2019, 01:18:12 PM »
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

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How do I render a model at the camera viewpoints?
« Reply #2 on: July 12, 2019, 07:54:53 PM »
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

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14855
    • View Profile
Re: How do I render a model at the camera viewpoints?
« Reply #3 on: July 12, 2019, 08:09:51 PM »
Hello Goldname,

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

Goldname

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How do I render a model at the camera viewpoints?
« Reply #4 on: July 13, 2019, 06:58:39 AM »
Ok thanks!