Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - talldrinks

Pages: [1]
1
This snippet ended up as the solution to place the region box relative to world coordinates, thanks again:

<code>
#Switch to Local Coordinates
if chunk.crs:
   chunk.crs = None
   
crs = chunk.crs
region = chunk.region
T = chunk.transform.matrix

m = PhotoScan.Vector([10E+10, 10E+10, 10E+10])
M = -m

x_scale = 3.0
y_scale = 3.0
z_scale = 4.0
new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])
new_center = PhotoScan.Vector([0.0,0.0,2.0])

region.center = T.inv().mulp(crs.unproject(new_center))
region.size = new_size

v_t = T.mulp(region.center)
R = crs.localframe(v_t) * T
region.rot = R.rotation().t()

chunk.region = region
</code>

2
Figured this out based on these posts and examples. Thanks!

http://www.agisoft.com/forum/index.php?topic=7543.0

3
I understand that the chunk coordinate space is local to the chunk, but I'm not clear on how to convert and position everything within real world coordinate space.

I'm confused, since the measurement tool gives me exact accurate measurements and everything is located around the 0,0,0 point of the 3D grid and aligned as expected along the XYZ view axes as well.

4
Hello.
When I reconstruct, I also import a camera position CSV file as reference. This properly scales and orients the scene to the Agisoft grid axes reliably.

My issue is that I want programmatically scale and orient the build region after this step. My script below is run after alignment and importing the CSV file (which does correctly scale and orient the entire camera rig).
It appears that the region parameters are always in relation to one of the aligned cameras, and doesn't seem to be the same camera every time, so I'm having trouble reliably placing the build region box at the center of the rig on the ground plane where I need it. I can offset and rotate the box, but since its relative to some camera each build, it's not reliable.

How can I best place the region in my chunk at an absolute position in world space (for instance, at 0.0,0.0,2.0 and scaled to 3.5,3.5,4.0)?

Thank you!

My script: (apologies, the code tag button is not working in Edge browser)
<code>
#load CSV reference file
   try:
      #import csv reference for scale and orientation
      csvFilePath = (path+"/CameraData/CamData.csv")
      print("Loading references from "+csvFilePath)
      chunk.loadReference(csvFilePath,PhotoScan.ReferenceFormat.ReferenceFormatCSV,'nxyzXYZ',',')
      chunk.updateTransform()
      print("loaded references!")
   except:
      print("couldn't load references")
   
   #set volume bounding box
   print("===Setting Bounding Box Volume===")
   new_region = PhotoScan.Region()

   new_center = PhotoScan.Vector([0.0,0.0,2.0]) #this offsets relative to some cameras Z axis, undesired
   #new_center = offset + new_rot * new_center

   x_scale = 3.5
   y_scale = 3.5
   z_scale = 4.0

   new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])

   T = PhotoScan.app.document.chunk.transform.matrix
   v_t = T * PhotoScan.Vector( [0,0,0,1] )
   m = PhotoScan.Matrix.Diag( (1,1,1,1) )

   m = m * T
   s = math.sqrt(m[0,0] ** 2 + m[0,1] ** 2 + m[0,2] ** 2) #scale factor

   R = PhotoScan.Matrix( [[m[0,0],m[0,1],m[0,2]], [m[1,0],m[1,1],m[1,2]], [m[2,0],m[2,1],m[2,2]]])
   R = R * (1.0 / s)

   new_region.size = new_size
   new_region.center = new_center
   new_region.rot = R.t()

   PhotoScan.app.document.chunk.region = new_region
   PhotoScan.app.update()
</code>

5
Python and Java API / Re: One build script across multiple nodes
« on: April 05, 2017, 05:36:07 PM »
Thank you. I'll review these.

6
Python and Java API / Re: One build script across multiple nodes
« on: April 05, 2017, 05:24:06 PM »
Oh, I don't think I mentioned, this is all being run from the command line.

I did find this snippet in the API reference:

Code: [Select]
import PhotoScan
task = PhotoScan.NetworkTask()
task.name = 'MatchPhotos'
task.params['keypoint_limit'] = 40000
client = PhotoScan.NetworkClient()
client.connect('127.0.0.1')
batch_id = client.createBatch('processing/project.psx', [task])
client.resumeBatch(batch_id)

Am I to understand that I can run a single python script from the server PC, which calls out individual nodes by IP address, and generates tasks for each with a unique task name as such?:

Code: [Select]
task1 = PhotoScan.NetworkTask()
task1.name = 'MatchPhotos'
task1.params['keypoint_limit'] = 40000
client1 = PhotoScan.NetworkClient()
client1.connect('127.0.0.1')
batch_id1 = client1.createBatch('processing/project.psx', [task1])
client1.resumeBatch(batch_id1)

task2 = PhotoScan.NetworkTask()
task2.name = 'AlignPhotos'
task2.params['Accuracy'] = HighAccuracy
client2 = PhotoScan.NetworkClient()
client2.connect('127.0.0.2')
batch_id2 = client2.createBatch('processing/project.psx', [task2])
client2.resumeBatch(batch_id2)
etc

for instance...?

7
Python and Java API / Re: One build script across multiple nodes
« on: April 05, 2017, 05:22:46 PM »
I see.
Do you happen to have any examples of such a script structure which interacts with nodes and utilizes custom python scripts?
Much appreciated!

8
Python and Java API / One build script across multiple nodes
« on: April 05, 2017, 03:50:54 PM »
Hello!
I've got a script which does a complete build:
Match
Align
Dense
Mesh
Uv
*texture path swap
*disables all mono cameras before texturing
*texture projection
*loads reference CSV for orient and scale
*Export files
*save scene

My question is, what happens during the above starred* steps when the job is distributed across a farm of Agi nodes?

First off, do I just call the script from the control mode pc?
Does that script then get sent out to the other nodes for processing?
How does each node know which piece of the script it should run?

Do all results get returned to the main node for texture processing and file exports?

Thank you. I know it's many questions.


9
I figured it out. My mistake.
The bounding volume region was being set far too small in some of my test scenes, so there was zero volume. This error displays as "error: zero volume" during GUI build, but "problem" displays during a scripted build.

10
Correction, it fails to build dense cloud at any quality level via this script.

11
Morning (or evening),

I've got a basic script like this:

Code: [Select]
print("===Match Photos===")
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.NoPreselection, filter_mask=True, keypoint_limit=30000, tiepoint_limit=30000)

print("===Align Cameras===")
chunk.alignCameras()

print("===Export Cameras===")
chunk.exportCameras(path+"/Scan Mesh/Cameras.xml")

print("===Build Dense Cloud===")
chunk.buildDenseCloud(quality=PhotoScan.HighQuality, filter=PhotoScan.AggressiveFiltering, keep_depth=True, reuse_depth=False)

print("===Build Model===")
chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation, face_count=500000)

print("===Build UVs===")
chunk.buildUV(mapping=PhotoScan.GenericMapping)
...

This fails to build the dense cloud step, and throws the error: "problem".

output:
2017-03-22 12:01:09 ===Build Dense Cloud===
2017-03-22 12:01:09 BuildDenseCloud: quality = Low, depth filtering = Aggressive
2017-03-22 12:01:09 Initializing...
2017-03-22 12:01:09 Using device: GeForce GTX 1070, 15 compute units, 8192 MB global memory, CUDA 6.1
2017-03-22 12:01:09   max work group size 1024
2017-03-22 12:01:09   max work item sizes [1024, 1024, 64]
2017-03-22 12:01:09 Using CUDA device 'GeForce GTX 1070' in concurrent. (4 times)
2017-03-22 12:01:09 sorting point cloud... done in 0.001 sec
2017-03-22 12:01:09 processing matches... done in 0.001 sec
2017-03-22 12:01:09 initializing...
2017-03-22 12:01:09 selected 0 cameras from 20 in 0.003 sec
2017-03-22 12:01:09 Loading photos...
2017-03-22 12:01:09 loaded photos in 0.001 seconds
2017-03-22 12:01:09 Reconstructing depth...
2017-03-22 12:01:09 finished depth reconstruction in 0.001 seconds
2017-03-22 12:01:09 Device 1: 0% work done with performance: 0 million samples/sec (CPU), device used for 0 seconds
2017-03-22 12:01:09 Device 2: 0% work done with performance: 0 million samples/sec (GeForce GTX 1070), device used for 0 seconds
2017-03-22 12:01:09 Generating dense point cloud...
2017-03-22 12:01:09 selected 0 cameras in 0.002 sec
2017-03-22 12:01:09 Finished processing in 0.029 sec (exit code 0)
2017-03-22 12:01:09 problem


If I manually build high quality point cloud in the GUI, it works fine.

Is this a strange memory issue somehow?

thanks.

12
Python and Java API / Re: loadReference returning odd error
« on: March 13, 2017, 07:05:20 AM »
Beauty. Works perfectly thank you.

13
Python and Java API / loadReference returning odd error
« on: March 12, 2017, 10:01:34 AM »
Hi friends.
I just keep getting this error when I try to loadReference, using a csv file, which works fine if loaded manually in the GUI...

My python script:
csvFilePath = "C:/temp/CamData.csv"
chunk.loadReference(path='csvFilePath', format='csv', columns='nxzyXZY', delimiter=',')

Error in Agi:

Traceback (most recent call last):  File "C:/temp/tempScript.py", line 2, in <module>
PhotoScan.app.document.chunk.loadReference('csvFilePath','csv','nxzyXZY',',')
TypeError: argument 2 must be TiffCompressionDeflate, not str

TiffCompressionDeflate!? I don't get it. On Version 1.3.0, Build 3772, 64-bit

Thank you! (sorry about formatting, the web markup tools aren't doing anything for me, I tried to wrap lines as #code)

Pages: [1]