Forum

Author Topic: export list of complete camera paths to csv?  (Read 1480 times)

wyowill

  • Newbie
  • *
  • Posts: 20
    • View Profile
export list of complete camera paths to csv?
« on: December 17, 2019, 08:30:52 AM »
I'm looking to generate a csv file of camera paths and enabled/disabled status.  I've sorted the following and have it running from the console...


Code: [Select]
import Metashape as ms
import csv

def get_camera_names(chunk):

    camera_lst = []
    enabled_lst = []
    for c in chunk.cameras[:10]:
        p = c.photo.meta["path"]
        if c.enabled == True:
            en = "True"
        else:
            en = "False"
        camera_lst.append(p)
        enabled_lst.append(en)
                       
    return (camera_lst, enabled_lst)

doc = ms.app.document
print(doc)
chunk = doc.chunk
print(chunk)

print(get_camera_names(chunk))

out_file = "J:\\MyDrive\\MyCode\\TestFile.txt"
with open(out_file, 'w', newline='') as myfile:
     wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
     wr.writerow(get_camera_names(chunk))

However, variable 'p' returns a bunch of unwanted characters in the string without the full path or extension.  For example:

    ...,<Camera 'DJI_0735_Mission4X_nadir'>,<Camera 'DJI_0736_Mission4X_nadir'>,...

Unless the above is needed for subsequent import into a different .psx file, I'd like:

   ...,'C:/MyDrive/DJI_0735_Mission4X_nadir.jpg','C:/MyDrive/DJI_0736_Mission4X_nadir.jpg',...

Cheers
W

[my ultimate aim is to add the identical suite of cameras and their enabled/disabled status into a completely different psx file]

Seboon

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: export list of complete camera paths to csv?
« Reply #1 on: December 17, 2019, 09:00:50 AM »
Hello,
Try to replace
"p = c.photo.meta["path"]"
with
p = c.photo.path
S.Poudroux
Archaeologist - Topographer - Drone remote pilot

wyowill

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: export list of complete camera paths to csv?
« Reply #2 on: December 17, 2019, 11:09:23 AM »
replace
"p = c.photo.meta["path"]"
with
p = c.photo.path

Spot-on.  Cheers!