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

Pages: [1]
1
Python and Java API / Re: Syntax for exportRaster image compression
« on: September 06, 2023, 07:01:32 PM »
That worked!  Restarting was key, since I think the previous mistake I made had broken things.  Thanks!

2
Python and Java API / Syntax for exportRaster image compression
« on: September 06, 2023, 05:31:08 AM »
What's the proper syntax for setting the image compression for the exportRaster method? I'm trying to export an RGB orthomosaic to a Geotiff with JPG compression, quality=90, using the code below:

Code: [Select]
import Metashape

chunk = Metashape.app.document.chunk

compression = Metashape.ImageCompression
compression.tiff_compression = Metashape.ImageCompression.TiffCompressionJPEG
compression.jpeg_quality = 90


out_projection = Metashape.OrthoProjection()
out_projection.type = Metashape.OrthoProjection.Type.Planar
out_projection.crs = Metashape.CoordinateSystem("EPSG::32610")

chunk.exportRaster(path = 'D:\my\output\path\geotiff.tif',
                    source_data = Metashape.DataSource.OrthomosaicData,
                    format = Metashape.RasterFormatTiles,
                    image_format = Metashape.ImageFormatTIFF,
                    image_compression = compression,
                    save_alpha = True,
                    white_background = True,
                    resolution_x = 0.10,
                    resolution_y = 0.10,
                    projection = out_projection
                    )


But I keep getting this error.

Code: [Select]
TypeError: invalid value type
I'm guessing I must have the ImageCompression syntax wrong, but I haven't been able to find an example of the correct way of doing this in the forums.

3
I believe I may have solved this -- required "importing" geoid under datum transformation settings.

4
I'm getting the following error in the console in Metashape when I open a project created in Photoscan 1.4:
Code: [Select]
Error: Vertical datum missing
The project had markers and chunks in the following CRS: "NAD83 / UTM Zone 10N + NAVD88(m)".   I made sure to download the "navd88-12b.tif" geoid into the Metashape Pro\geoids directory, and have restarted Metashape. 

New projects created with Metashape can have their CRS defined to "NAD83 / UTM Zone 10N + NAVD88(m)" without issue.  The error only shows up with the old project created with 1.4. 

Any help resolving this would be appreciated. We have many old projects that rely on this geoid transformation for the vertical datum.

Thanks.

5
Python and Java API / Find cameras for each point in dense cloud
« on: February 05, 2019, 09:51:30 PM »
Is it possible to return a list of cameras (projections?) for each point in the dense point cloud?

Are the camera names(or indices) available somehow as an attribute for each point (on the PhotoScan.DenseCloud object?)?

I would like to be able to iterate through each camera and derive a list of the DenseCloud points derived from it.

Thanks.

6
General / Calibrate colors - Undo (revert)
« on: November 16, 2018, 10:03:16 PM »
I ran "Calibrate colors" in a chunk and created an orthophoto mosaic, but I wasn't satisfied with the results.  How do I undo the color calibration, so I can rebuild the ortho with the original (unaltered) photos?

Thanks.

7
Is there a way to programmatically determine (from within a script) if a script is being run from the 'run script' dialog box or from the python console (using the 'run' command)?


8
I ran into some unexpected behavior from the console which tripped me up for a bit.  I don't think it's big deal, but I'm posting here in case it potentially saves someone else the hassle of troubleshooting it. 

The order of messages output by the Photoscan python console doesn't necessarily match the order of the commands being executed.  For instance:

Code: [Select]
print('CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT')
newchunk = chunk.copy()
newchunk.label = chunk.label + '_NewChunk'

2018-05-24 16:47:26 DuplicateChunk: items = (depth maps, dense cloud, model, DEM, orthomosaic, tiled model)
2018-05-24 16:47:26 Duplicating chunk...
2018-05-24 16:47:26 Finished processing in 0.016 sec (exit code 1)
2018-05-24 16:47:26 CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT

I even paused the copy() method by inserting a time.sleep() line, but it didn't change the outcome:
Code: [Select]
import time
print('CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT')
time.sleep(5)
newchunk = chunk.copy()
newchunk.label = chunk.label + '_NewChunk'

2018-05-24 16:47:54 DuplicateChunk: items = (depth maps, dense cloud, model, DEM, orthomosaic, tiled model)
2018-05-24 16:47:54 Duplicating chunk...
2018-05-24 16:47:54 CHUNK WILL BE COPIED --AFTER-- THIS PRINT STATEMENT
2018-05-24 16:47:54 Finished processing in 0.031 sec (exit code 1)


9
Fantastic.   I’ll look for this in the next update.  Thanks for the response.

10
Thank you for the code snippet.  I placed your code into a script ('calcOptimizeCamerasError.py') and tried it out on a small test project.  Unfortunately it doesn't reproduce the error value printed in the console. 

Here's the console output from Optimize Cameras:

Code: [Select]
2018-05-09 10:50:07 OptimizeCameras: f, cx, cy, k1-k3, p1, p2
2018-05-09 10:50:07 Optimizing camera locations...
2018-05-09 10:50:07 adjusting: xxxxx- 0.922438 -> 0.922438
2018-05-09 10:50:07 coordinates applied in 0 sec
2018-05-09 10:50:07 Finished processing in 0.318 sec (exit code 1)

Here's the output from the script:
Code: [Select]
run calcOptimizeCamerasError.py
2018-05-09 10:50:20 0.4755864736517061

Is there any other way to access the standard error value from OptimizeCameras?

Thanks again for your help with this.


11
Is there a way to get the standard error of unit weight after you run the optimizeCameras method in python? 

I believe this is the value printed in the console when you run Optimize Cameras in the GUI, like this:
>>Optimizing camera locations ...
>>adjusting: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0.489454 -> 0.489437

Is there a way to get this value (0.489437) through the python API? 

It seems like this would be returned from the chunk.optimizeCameras method, or it would be available in the chunk.meta object, but I don't see it anywhere.

Any help would be greatly appreciated.

Thanks.

Pages: [1]