Forum

Author Topic: Export markers  (Read 18669 times)

Merzel

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Export markers
« Reply #15 on: January 04, 2017, 06:47:28 PM »
# exports all markers in activeChunk to csv.
# compatibility: Agisoft PhotoScan Professional 0.9.0
import PhotoScan
import math


FILEPATH = 'E:/marker_export.txt'

app = PhotoScan.app
doc = PhotoScan.app.document
chunk = PhotoScan.app.document.chunk
f = open(FILEPATH, 'w')
for item in chunk.markers:
   if item.position == None:
      continue
   v = item.position
   v.size = 4
   v.w = 1
   T = chunk.transform
   if not chunk.transform:
      chunk.transform = PhotoScan.Matrix.diag( (1,1,1,1) )
   T = chunk.transform
   v_t = T * v
   v_t.size = 3
   proj = chunk.crs
   v_out = proj.project(v_t)
   f.write(item.label + ',' + str(v_out[0]) + ',' + str(v_out[1]) + ',' + str(v_out[2]) + '\n')
f.close()

Guilhem

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Export markers
« Reply #16 on: October 26, 2017, 10:29:57 AM »
Hi all,

I am trying the same export with you code but I get the same error "TypeError: unsupported types" at line "v_t = T * v".

But my project is referenced as there is a [R] beside the chunk name, and "str(type(T))" gives "<class 'PhotoScan.ChunkTransform'>".

I am using APS 1.3.4

By the way, it seems that on this version of APS, the PhotoScan.Matrix.diag( (1,1,1,1) ) is wrong and "diag" takes a capital :
PhotoScan.Matrix.Diag( (1,1,1,1) )

But not a problem in my case as my chunk.transform exists.

Thanks for your precious help !

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: Export markers
« Reply #17 on: October 26, 2017, 10:46:09 AM »
Hello Guilhem,

Please try the following code in 1.3.4:
Code: [Select]
# exports all markers in activeChunk to csv.
# compatibility: Agisoft PhotoScan Professional 1.3.4
import PhotoScan, math
FILEPATH = 'E:/marker_export.txt'

doc = PhotoScan.app.document
chunk = doc.chunk
T = chunk.transform.matrix
f = open(FILEPATH, 'wt')
for marker in chunk.markers:
   if not marker.position:
      continue
   v_t = T.mulp(marker.position)
   v_out = chunk.crs.project(v_t)
   f.write(marker.label + ',' + str(v_out[0]) + ',' + str(v_out[1]) + ',' + str(v_out[2]) + '\n')
f.close()
Best regards,
Alexey Pasumansky,
Agisoft LLC

Guilhem

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Export markers
« Reply #18 on: October 26, 2017, 12:44:06 PM »
Ok I got it work with APS 1.3.4 (I guess the problem was due to changes in calls with last version of APS)

We have to specify "chunk.transform.matrix" and not "chunk.transform" before doing "v_t = T * v" otherwise APS does not understand ad chunk.transform contains several things beside the ".matrix".

Beware also with the "PhotoScan.Matrix.Diag" with captial for "Diag", in case needed... (old version did not take a capital)

FILEPATH = 'G:/marker_export.txt'

f = open(FILEPATH, 'w')
for item in chunk.markers:
   if item.position == None:
      continue
   v = item.position
   v.size = 4
   v.w = 1
   if not chunk.transform:
      chunk.transform.matrix = PhotoScan.Matrix.Diag( (1,1,1,1) )
   T = chunk.transform.matrix
   v_t = T * v
   v_t.size = 3
   proj = chunk.crs
   v_out = proj.project(v_t)
   f.write(item.label + ',' + str(v_out[0]) + ',' + str(v_out[1]) + ',' + str(v_out[2]) + '\n')
f.close()

Cheers