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.


Topics - LDBL

Pages: [1]
1
Python and Java API / Crop to GCPs in Sparse Cloud
« on: May 13, 2019, 11:42:48 PM »
Hello,

Agisoft 1.4.5 (still using the older version due to python script and OpenCL)

I've been trying to incorporate this into a larger script;

https://www.agisoft.com/forum/index.php?topic=8985.0

Unfortunately, it doesn't seem to crop to the markers I'm using?

Code: [Select]
## load project

import PhotoScan
doc = PhotoScan.app.document
doc.open('XX.psz')
chunk = doc.chunk

## select GCPs

for marker in chunk.markers:
    if marker.label == 'B1':
        marker.reference.enabled = True
        break
for marker in chunk.markers:
    if marker.label == 'B2':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B3':
        marker.reference.enabled = True
        break
for marker in chunk.markers:
    if marker.label == 'B4':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B5':
        marker.reference.enabled = True
        break
for marker in chunk.markers:
    if marker.label == 'B7':
        marker.reference.enabled = True
        break
for marker in chunk.markers:
    if marker.label == 'B8':
        marker.reference.enabled = True
        break
for marker in chunk.markers:
    if marker.label == 'B9':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B10':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B11':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B12':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B13':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B14':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B15':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B16':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B18':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B19':
        marker.reference.enabled = False
        break
for marker in chunk.markers:
    if marker.label == 'B20':
        marker.reference.enabled = False
        break

## rebuild sparse with selected GCPs

chunk.point_cloud = None
chunk.matchPhotos(accuracy=PhotoScan.LowAccuracy, generic_preselection=True, reference_preselection=True, keypoint_limit=40000, tiepoint_limit=4000)
for camera in chunk.cameras:
    camera.transform = None
chunk.alignCameras(adaptive_fitting = False)
doc.save('XX.psz')

## crop

import PhotoScan

chunk = PhotoScan.app.document.chunk
T = chunk.transform.matrix
crs = chunk.crs
if not chunk.shapes:
chunk.shapes = PhotoScan.Shapes()
chunk.shapes.crs = chunk.crs

shape = chunk.shapes.addShape()
shape.label = "boundary"
shape.type = PhotoScan.Shape.Polygon
shape.boundary_type = PhotoScan.Shape.BoundaryType.OuterBoundary

coords = [crs.project(T.mulp(marker.position)) for marker in chunk.markers]
shape.vertices = [PhotoScan.Vector([coord.x, coord.y]) for coord in coords]

Is there something missing, has something changed?

Thanks in advance.

Leon

2
Python and Java API / Resize bounding box
« on: February 11, 2019, 12:35:46 AM »
Hello,

I've incorporated the code from here;

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

In to a script I'm putting together, that also utilises the MC32 script found here;

https://www.lancaster.ac.uk/staff/jamesm/software/sfm_georef.htm

I'm trying to automate the process of ensuring the bounding box is larger than the point cloud for the Monte Carlo analysis to run successfully (both python scripts runs flawlessly within Photoscan/Metashape) but when I'm running the analysis through SfM_Georef, anywhere between 50-90% of the Monte Carlo iterations are rejected due to the bounding box being too small.

Is there a way to say, add 20% or 20m in the X,Y, and Z of the box within this?;

Code: [Select]
import PhotoScan, math

doc = PhotoScan.app.document
chunk = doc.chunk
region = chunk.region
T = chunk.transform.matrix

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

for point in chunk.point_cloud.points:
if not point.valid:
continue
coord = T * point.coord
coord.size = 3
coord = chunk.crs.project(coord)
for i in range(3):
m[i] = min(m[i], coord[i])
M[i] = max(M[i], coord[i])

center = (M + m) / 2
size = M - m

region.center = T.inv().mulp(chunk.crs.unproject(center))
region.size = size * (1 / T.scale())

v_t = T * PhotoScan.Vector( [0,0,0,1] )
v_t.size = 3
R = chunk.crs.localframe(v_t) * T
region.rot = R.rotation().t()

chunk.region = region
print("Script finished.")

Report to moderator   Logged

Cheers,

Leon

3
Bug Reports / Relink ./libgfortran.so.3' with `/usr/lib/librt.so.1'
« on: January 31, 2019, 12:46:39 AM »
Hello,

I've just upgraded my system (Linux) and that's included moving from an Ubuntu 18.04 to Manajaro (Arch).

When I run metashape from the CLi, I'm getting a relink notification (I think the system uses a newer version of GCC along with libgfortran.so.4);

Code: [Select]
Relink `/home/leond/ThirdParty/metashape-pro_1_5_0_amd64/metashape-pro/./libgfortran.so.3' with `/usr/lib/librt.so.1' for IFUNC symbol `clock_gettime'
Is this something that can be ignored? Or will it cause problems further down the line?

Cheers,

Leon

4
General / Being booted into demo mode whilst using a floating licence
« on: January 17, 2019, 09:29:54 PM »
Hello,


I'm using a floating licence via my university, I have the option to borrow the licence so that I need not be constantly connected via the VPN.

Recently, I've experienced Photoscan (v 1.4.2 and 1.4.5) and Metashape, both booting back to demo mode (so no save option and halting my python scripting workflow) even though I've borrowed a licence for 30 days. This is regardless of whether I'm still attached to the VPN or not.

I'm running PS or Metashape on an Ubuntu 18.04 distro.

Is this a PS/Metashape issue or a university issue?

Cheers,

Leon

5
Python and Java API / reset_alignment
« on: December 22, 2018, 01:49:51 AM »
Hello collective,

I'm trying to emulate the "reset current alignment" option in the GUI.

Essentially, I have a 'base' model I need to rebuild multiple times with different setting via python, but to do so, I need to be able to reset the current alignment each time.

My code thus far is;

Code: [Select]
import PhotoScan
doc = PhotoScan.app.document
doc.open('XXX.psz')
chunk = doc.chunk
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True, reference_preselection=False, keypoint_limit=40000, tiepoint_limit=4000)
chunk.alignCameras(reset_alignment=True)
doc.save('XXX.psz')

But this fails. Selecting to reset alignment in the GUI works fine.

Any help please?

Thanks,

Leon

Pages: [1]