Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Darshan on December 15, 2019, 02:51:32 PM

Title: Metashape.Chunk' object has no attribute 'camera'
Post by: Darshan on December 15, 2019, 02:51:32 PM
Hi

i am trying to for the rotation matrix from the camera center and the camera position input and i am getting the below error

 <Chunk 'Chunk 3'>
2019-12-15 12:44:51 Traceback (most recent call last):
2019-12-15 12:44:51   File "C:/Users/Darshan Savanur/Downloads/project/py files/script2.py", line 13, in <module>
2019-12-15 12:44:51     for camera in ch_flir.camera:
2019-12-15 12:44:51 AttributeError: 'Metashape.Chunk' object has no attribute 'camera'
2019-12-15 12:44:51 Error: 'Metashape.Chunk' object has no attribute 'camera'

please help me on this .. I think there is something wrong with my labels in my other code which generates csv with camera co-ordinates and camera center ...please check the attached file which generates this csv


import Metashape
import numpy


doc = Metashape.app.document#active ch_flir

ch_flir = doc.chunks[2]
print(ch_flir)
cameracenter= numpy.loadtxt(open(r"C:\Users\Darshan Savanur\Downloads\project\py files\cameracenttermal.csv","rb"), delimiter=",")

R = []

for camera in ch_flir.camera:
   
    d = ch_flir.crs.project(ch_flir.transform.matrix.mulp(cameracenter))
    T = ch_flir.transform.matrix
   
    print (T)
Title: Re: Metashape.Chunk' object has no attribute 'camera'
Post by: Alexey Pasumansky on December 15, 2019, 03:57:36 PM
Hello Darshan,

I think it should be:
Code: [Select]
for camera in ch_flir.cameras: