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 - bbbares

Pages: [1]
1
Python and Java API / Detected Marker has None Position
« on: June 04, 2020, 09:52:54 PM »
This chunk of code:
Code: [Select]
marker_positions = []

for marker in chunk.markers:
    print("{} position: {}".format(marker, marker.position))
    marker_positions.append(marker.position)

vectors = []
for position in marker_positions:
    vectors.append(array([position.x, position.y, position.z]))

Results in this console output:
Code: [Select]
<Marker 'target 11'> position: Vector([2.850384004018244, 1.0210633499586494, -6.354710883046436])
<Marker 'target 12'> position: Vector([0.1409655312925602, -1.873231255504267, -4.556384146429653])
<Marker 'target 13'> position: Vector([-3.1367483930697495, 0.2522316043279687, -6.05366511916446])
<Marker 'target 14'> position: Vector([-0.4853655511060345, 3.1416026085665454, -7.8536455698625565])
<Marker 'target 16'> position: None
<Marker 'target 17'> position: None
<Marker 'target 18'> position: None
<Marker 'target 19'> position: None
<Marker 'target 20'> position: Vector([0.34745671678010315, 1.4629262299823313, -5.828908686770713])
<Marker 'target 21'> position: Vector([1.0872473152349622, 0.8241725426644423, -5.389903594150859])
<Marker 'target 22'> position: Vector([0.3666418664748137, 0.6686374725083808, -4.418571191247626])
<Marker 'target 23'> position: Vector([-0.2897068854704151, 0.650584019576526, -5.326348232334733])
<Marker 'target 24'> position: Vector([-1.4136581747723513, 0.9682022687019506, -5.566239838233837])
<Marker 'target 25'> position: Vector([-0.7353815825573798, 1.9562010612076728, -5.309009445145799])

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/cron/ms_pipeline/sweepS3.py", line 84, in <module>
    main()
  File "/home/ubuntu/cron/ms_pipeline/sweepS3.py", line 77, in main
    runmetashape.main(project_name=runnable_project.name, project_suffix=runnable_project.suffix)
  File "/home/ubuntu/cron/ms_pipeline/ms_workflow/runmetashape.py", line 392, in main
    orientchunk.orient_markers_to_xy_plane(chunk)
  File "/home/ubuntu/cron/ms_pipeline/ms_workflow/bounding_box/orientchunk.py", line 26, in orient_markers_to_xy_plane
    vectors.append(array([position.x, position.y, position.z]))
AttributeError: 'NoneType' object has no attribute 'x'

Can someone explain to me how a marker can be detected but its position is unknown. Is it because there isn't enough data of that marker for Metashape to determine where it is in the 3D space?

2
Python and Java API / Standalone Module Use in a Docker Container
« on: June 03, 2020, 07:10:50 PM »
I'm looking to build my standalone scripting project into a docker image and I was wondering if anyone here has had any experience with that and if so what their Dockerfile looked like.

Related, I was wondering if there is documentation of all the libraries/drivers used by the standalone module so I don't need to go one by one in debugging while building a docker image for my project.

3
Python and Java API / Headless mode import
« on: May 22, 2020, 11:32:34 PM »
I am looking to run my metashape script in a docker container and when I run it I receive this error:
Code: [Select]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/appuser/ms_pipeline/sweepS3.py", line 10, in <module>
    from ms_pipeline.ms_workflow import runmetashape
  File "/home/appuser/ms_pipeline/ms_workflow/runmetashape.py", line 7, in <module>
    import Metashape as Ms
  File "/usr/local/lib/python3.7/site-packages/Metashape/__init__.py", line 3, in <module>
    from .Metashape import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
From preliminary research it seems that this it related to the GUI. For my purposes the GUI is not necessary is there a way I can run the module in headless mode forgoing needs for the GUI? If not please let me know. Thanks.

4
I want to add texturing to my pipeline but when I run the script I get the following output to the command line:

Code: [Select]
BuildTexture: texture size = 4096, texture type = Diffuse map, source data = Images, blending mode = Mosaic, fill holes = 1, ghosting filter = 1, enable_gpu = 1, relaxed_precision = 1
Found 1 GPUs in 0.000973 sec (CUDA: 0.000223 sec, OpenCL: 0.000736 sec)
Using device: Tesla T4, 40 compute units, free memory: 14989/15109 MB, compute capability 7.5
  driver/runtime CUDA: 10020/6050
  max work group size 1024
  max work item sizes [1024, 1024, 64]
Initializing context...
Cannot use GPU. Reason: VK Error : VkResult is "ERROR_INITIALIZATION_FAILED" at line 59
Performing blending on CPU...
calculating mesh connectivity... done in 0.426329 sec
detecting outliers... ******************************************* done in 37.4896 sec
estimating quality... ******************************************* done in 48.2925 sec
blending textures...  ******************************************* done in 53.0495 sec
postprocessing atlas... done in 0.849618 sec

The texture result seemed to be of lower quality, but if this error is normal I would like to know.

5
Python and Java API / Bounding Box and Coordinate System Conflict
« on: May 01, 2020, 05:43:57 AM »
This is hopefully my last post on my bounding box brigade. I was able to write two standalone scripts, one that orients the markers of the model downwards and another that minimizes the bounding box around the markers. It seems that the coordinate system to bounding box feature borrowed from another script functions for the model orientation but screws up the bounding box for the bounding box reduction. I figured this from the orthographic view and proceeding point data being seemingly skewed.  Both scripts work fine separately but they do not work together. My final product requires both features in succession. I have attached photos visually representing the issue.

This is the section of code I was referring to:
Code: [Select]
R = chunk.region.rot  # Bounding box rotation matrix
C = chunk.region.center  # Bounding box center vector

if chunk.transform.matrix:
    T = chunk.transform.matrix
    print(T)
    s = math.sqrt(T[0, 0] ** 2 + T[0, 1] ** 2 + T[0, 2] ** 2)  # scaling # T.scale()
    S = Metashape.Matrix().Diag([s, s, s, 1])                  # scale matrix
else:
    S = Metashape.Matrix().Diag([1, 1, 1, 1])

T = Metashape.Matrix([[R[0, 0], R[0, 1], R[0, 2], C[0]],
                      [R[1, 0], R[1, 1], R[1, 2], C[1]],
                      [R[2, 0], R[2, 1], R[2, 2], C[2]],
                      [      0,       0,       0,    1]])


Ideally there is a solution that allows the rotation of the object model without altering the coordinate system disabling me from utilizing it properly in the future.

P.S. I have two additional pictures that would aid in understanding the issue but I am limited to 4

6
Python and Java API / Trimming Floor From Object
« on: April 24, 2020, 12:31:37 AM »
I have a random object centered among markers as seen in the attached image. In my model processing pipeline I would like to remove the floor before the object model is exported. I have two questions here:
  • At what point in the pipeline would be recommended to trim the floor? After sparse point cloud generation? After dense cloud generation? After Model generation?
  • Would it be better to trim the floor away by adjusting the bounding box to not include the floor or removing the points associated with the floor?
Thanks in advance.

7
Python and Java API / Removing low confidence dense cloud points
« on: April 23, 2020, 04:41:04 PM »
I have a script that sets the confidence filter of the dense cloud. I would like to select all of the points remaining from the filter (say 10 - 255 confidence) and cut them, removing all the other points (0 - 9 confidence). I didn't see any dense cloud point selection method. Do I need to apply the points to a class and then delete the class?

8
Python and Java API / reduceOverlap() Null model error
« on: April 17, 2020, 06:48:39 PM »
I am trying to add reduceOverlap() functionality to my script but I am getting this error:
Code: [Select]
ReduceOverlap: overlap = Medium, max_cameras = 5, use_selection = 0
Traceback (most recent call last):
  File "/home/ubuntu/A3M/cron_sweep_s3.py", line 89, in <module>
    main()
  File "/home/ubuntu/A3M/cron_sweep_s3.py", line 82, in main
    run_metashape.main(project_name=runnable_project.name, project_suffix=runnable_project.suffix)
  File "/home/ubuntu/A3M/run_metashape.py", line 286, in main
    chunk.reduceOverlap(overlap=reduce_overlap.overlap, max_cameras=reduce_overlap.max_cameras)
Exception: Null model
Does reduceOverlap() need to be run after buildModel()?

9
I am running my python script that imports the Metashape module on an AWS EC2 instance that is running ubuntu. My previous solution allowed me to run the script from within the directory that contained the script itself and the .lic file. I now need to be able to run the file from any directory e.x. "python3 /path/to/directory/scripy.py". When I do this I get the following error "No license found. Details: No license for product (-1)". I tried the solution recommended in an older forum post by moving the .lic file into the Metashape module folder .../python3.6/site-packages/Metashape. This solution did not work for me and I am confused as to how to proceed. Any help is greatly appreciated!

10
Python and Java API / Calibrating a specific Camera Model
« on: March 05, 2020, 06:46:22 PM »
I am writing a script that follows the general workflow guide laid out in the user manual. I have gotten everything to work except for camera calibration. Ideally I would like to load in all of the photos and then calibrate a specific camera model associated with many photos as opposed to calibrating a new camera connected to each photo added. I was wondering if this was possible and if so how this can be implemented.

Here is my in progress script:

Code: [Select]
# Import Metashape
try:
    import Metashape
except ImportError:
    import sys

    print("This library requires Agisoft Metashape")
    sys.exit(1)

# Import other libraries
from pathlib import Path

# Checking Version Compatibility
print("--- Checking version compatibility...")
compatible_major_version = "1.6"
found_major_version = ".".join(Metashape.app.version.split('.')[:2])
if found_major_version != compatible_major_version:
    raise Exception("Incompatible Metashape version: {} != {}".format(found_major_version, compatible_major_version))

# DEFINE PROCESSING SETTINGS
print("--- Defining processing settings...")

# Define: Source Path
SourcePath = Path.home().joinpath('Documents', 'A3M')

# Define: Project Prefix
ProjectPrefix = "Scripted"

# Define: Project Name
ProjectName = "Test1"

# Define: Image pattern
ImagePattern = "*.dng"

# INITIALIZE ENVIRONMENT
# Main app objects
doc = Metashape.app.document
chunk = doc.chunk


# Method to save project
def saveproject():
    print("--- Saving project...")
    doc.save()


# LOAD AND CALIBRATE PHOTOS
print("--- Loading images...")
# Find paths to photos
PhotoPaths = SourcePath.joinpath("Images", ProjectPrefix).rglob(ImagePattern)
# Load photos
Photos = list(map(str, PhotoPaths))
chunk.addPhotos(Photos)
# Calibrate cameras

# Psuedocode <------------------------------------------------------------------------------ Change this
# chunk.cameramodel.sensor = Metashape.Sensor.Fisheye

saveproject()

# ALIGN PHOTOS
print("--- Aligning photos...")
# print("Accuracy: " + AlignPhotosAccuracy)
chunk.matchPhotos()
chunk.alignCameras()
saveproject()

# BUILD DENSE CLOUD
print("--- Building Depth Maps...")
chunk.buildDepthMaps()
print("--- Building Dense Cloud...")
chunk.buildDenseCloud()
saveproject()

# BUILD MODEL
print("--- Building Model...")
chunk.buildModel()
saveproject()

# EXPORT MODEL
ModelPath = SourcePath.joinpath("Models", ProjectPrefix)
try:
    ModelPath.mkdir()
except FileExistsError:
    print("Duplicate directory found, no new directory made")
chunk.exportModel(path=str(ModelPath.joinpath(ProjectName + ".obj")))

Pages: [1]