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

Pages: [1]
1
Python and Java API / Photo extent in orthomosaic
« on: May 02, 2021, 12:49:52 AM »
Hello,


I need to locate the extent of an input photo, that is the four corners of a camera.photo, within the orthomosaic (in CRS coordinates). So if my photo has size 4000x3000, I need the following output:

photo_coords (px)   ortho_coords (UTM)
(0, 0)(500000, 3000000)
(4000, 0)(500125, 3000050)
(4000, 3000)(5000176, 3000072)
(0, 3000)(500034, 3000101)

The ortho_coords are just fake UTM coordinates. I have the photo_coords, obviously, but I need the ortho_coords, and I need to match them to the photo_coords.
 I am using a script written by Alexey Pasumansky created as an answer to this forum post: https://www.agisoft.com/forum/index.php?topic=6662.0.  The important part of the script follows:
Code: [Select]

if chunk.dense_cloud:
surface = chunk.dense_cloud
elif chunk.model:
surface = chunk.model
else:
surface = chunk.point_cloud

for camera in chunk.cameras:
if not camera.transform:
continue #skipping NA cameras

sensor = camera.sensor
corners = list()
for i in [[0, 0], [sensor.width - 1, 0], [sensor.width - 1, sensor.height - 1], [0, sensor.height - 1]]:
corners.append(surface.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(PhotoScan.Vector(i)))))
if not corners[-1]:
corners[-1] = chunk.point_cloud.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(PhotoScan.Vector(i))))
if not corners[-1]:
break
corners[-1] = chunk.crs.project(T.mulp(corners[-1]))

if not all(corners):
print("Skipping camera " + camera.label)
continue
return corners

The corners returned by this script are correct, but the ordering is not guaranteed! The ordering might match my photo_coords if the camera is pointed north, but not if it points south or west or east. Does someone know how I can use the orientation of the camera to put my output corners in the correct order to match the photo_coords?



2
Hi,

I am trying to ensure that the images used to build my orthomosaics are full resolution.

The user manual states that with alignment accuracy <= Medium and dense cloud quality <= High, the images are down-scaled by a factor of 2 in both dimensions (total resolution reduced by a factor of 4). But is that down-scaling only applied to the actual processes of image alignment & dense cloud generation? This will affect the number of tie points, size of the point cloud, etc., but I don't think it MUST affect the output resolution of the orthomosaic. Will the full-resolution images be used to actually build the orthomosaic, regardless of these settings?

Thanks!

3
General / Best practice for dealing with inconsistent GPS datums?
« on: May 06, 2020, 01:04:08 AM »
In our UAV dataset, we have images with GPS tags using the WGS84 datum. Agisoft markers were used on the ground, and their locations were recorded in the NAD83 datum. We can expect that the GPS tags will therefore be shifted by up to 1m between the images and the markers. What is the best practice for the most accurate photogrammetry in Metashape?

1. Pretend all GPS tags are in NAD83, and set measurement precision of the camera reference entries to be lower (1m - 10m, compared with 0.02m for markers).

2. Remove the camera reference entries altogether, and generate the georeference only based on the markers in NAD83.

I would appreciate any input. Thanks!

4
Hi,

I processed some images in PhotoScan without any GPS data: no markers, no GPS info within the images. I was still able to export a nice orthomosaic. I noticed the orthomosaic automatically picked epsg:4978 as the CRS. Does PhotoScan always pick epsg:4978 as the default?

Thanks!

5
General / plane fit orthomosaic
« on: June 29, 2018, 02:09:41 AM »
Hi,

I am dealing with UAV imagery. My GPS data is imprecise, so it can't be relied upon to produce an orthomosaic with the correct orientation. For most of my image sets, the point cloud looks great, but the orthomosaic is at the wrong angle and thus unusable.

I want to abandon the georeferenced orthomosaic, and instead do some kind of plane fit on the point cloud (our data is very flat) to determine the correct orthomosaic orientation. Does anyone have any ideas for how this should be done?

I think I will have to export the point cloud, fit it to a plane using other software, then use those plane coefficients. But I appreciate any suggestions.

6
Python and Java API / photoscan.sh return code
« on: May 07, 2018, 08:46:58 PM »
While doing python scripting on Ubuntu 16.04 with photoscan 1.4.1, I've noticed photoscan.sh always returns 0 even when my script raises an exception. My solution is to explicitly call sys.exit(1) within my script, which causes photoscan.sh to return 1. But I'm not sure if it's safe to call sys.exit directly--does this prevent PhotoScan from cleaning up?

To be precise, here are two example scripts:

test_a.py:
Code: [Select]
raise RuntimeError("error!")
test_b.py:
Code: [Select]
import sys
sys.exit(1)

...and when I run them:
Code: [Select]
python test_a.py # returns 1
photoscan.sh -platform offscreen -r test_a.py # returns 0

python test_b.py # returns 1
photoscan.sh -platform offscreen -r test_b.py # returns 1

7
Python and Java API / export undistorted photos in python
« on: April 02, 2018, 08:41:33 PM »
I've been trying to recreate the GUI functionality export -> undistort photos using the Python API.

This is what I came up with, for a multiplane (MicaSense RedEdge) camera:

Code: [Select]
    for camera in chunk.cameras:
        for plane in camera.planes:
            img = plane.image()
            calib = plane.sensor.calibration
            # This is the key line for colour correction. Here, I opted not to square pixels or center principal point.
            imgu = img.undistort(calib, False, False)
            name = os.path.basename(plane.photo.path)
            imgu.save(os.path.join('undistorted/', name))

It seems to work. Unfortunately, it seems that the exif information, such as 'XMP:CaptureId' is not saved. (This is crucial for me.) Does anyone know if this can be accomplished?

EDIT: I noticed that photo.imageMeta() exists, and I also know how to extract metadata from the original photo using e.g. exiftool. But I'm not sure how to save the metadata properly to a new image.

EDIT 2: I am managing with a workaround--just using the metadata from the original images, and matching that to the undistorted images.

8
Python and Java API / calibrating reflectance in python
« on: March 25, 2018, 09:26:35 PM »
Hi,

Using Micasense Rededge photos, I'd like to try calibrating reflectance in python:
Code: [Select]
chunk.addPhotos(photo_paths, PhotoScan.MultiPlaneLayout)
chunk.locateReflectancePanels()
chunk.loadReflectancePanelCalibration(path='panel.csv')
chunk.calibrateReflectance()
# ...proceed with processing.

I have two questions:

1. How should panel.csv be formatted? I currently have a csv file with:
Quote
band,albedo
blue,0.709
green,0.729
red,0.728
rededge,0.712
nir,0.672

2. I see a Tasks.CalibrateReflectance with fields use_sun_sensor and use_reflectance_panels. But how can I set both those values to true using chunk.calibrateReflectance?

9
Python and Java API / Stitching long series of gopro images
« on: August 29, 2017, 09:08:56 PM »
Hi,

I'm trying to stitch together long bands of gopro images--maybe 100-300 images in the X direction, with at most 2 images  "side-by-side" in the Y direction at any given location. The images are maybe 2m above the ground, facing down. Each image is geotagged, although the GPS values may not be high quality.

We are using maximum image matching accuracy and dense cloud quality, and building the orthomosaic based on elevation data.

The resulting orthomosaic is warped and sometimes totally unusable.   You can visit https://www.dropbox.com/sh/dstvazzbn8ooacw/AAA_E-qqfGbmwE07-0z41E8Na?dl=0 and view gopro_*.pdf to see the orthomosaics in question (fonts are not working currently, but you can see the images).

When stitching manually, it's possible to re-align the frame of reference so that the orthomosaic is not warped. But we'd like our process to be totally automatic. Does anyone have any suggestions?

 

10
Python and Java API / Stitching errors with Micasense RedEdge
« on: August 28, 2017, 10:00:33 PM »
Referenced reports are at this dropbox link. Unfortunately, my fonts currently aren't working, so you can only see the output images:

https://www.dropbox.com/sh/dstvazzbn8ooacw/AAA_E-qqfGbmwE07-0z41E8Na?dl=0

I occasionally have trouble stitching 5-channel Micasense RedEdge images. Maybe 4/5 times, the result will be good (see micasense_drone_report_good.pdf). 1/5 times the result will be total misalignment between channels (see micasense_drone_report_bad.pdf).

Does anyone know if there is anything that can be done about this? Notably, if I stitch each of the 5 channels separately, they produce separately perfect results.

I use the elevation map to build the orthomosaic, after matching photos with High accuracy and building a dense cloud with Ultra quality. I can provide the relevant code if you like.

11
General / Headless Photoscan requires GUI on startup?
« on: July 11, 2017, 02:10:27 AM »
Hi,

I am experimenting with running PhotoScan headless using '-r' on the linux command line. It works, but I am getting the following error on startup:
Code: [Select]
QXcbConnection: Could not connect to display localhost:10.0
Aborted (core dumped)

I know this is due to PhotoScan (and not my script), because even a simple "Hello, World" script is failing.

I can work around this by using ssh -Y to connect to my linux server, but that only works for the first time photoscan is launched within the run. (I am running within a GNU screen, which means that I am losing my X-window when I detach).

Is there any way to run PhotoScan without such reliance on GUI availability? Or does anyone have any other tips? 

Thanks!

12
Python and Java API / chunk.exportOrthophotos() bug
« on: May 30, 2017, 02:35:04 AM »
Hi,

If I use chunk.exportOrthophotos(), it only asks for one path, and it seems to successively save every image to that same path (it took about 15 minutes to complete, but only yielded one photo at the end). How can I actually export all the separate orthophotos? Is this a bug?

Thanks!

13
Python and Java API / MicaSense Rededge camera alignment
« on: April 27, 2017, 10:29:37 PM »
Hi,

I have been doing multi-spectral processing on images from a Micasense Rededge camera, and the resulting aligned multi-plane orthomosaic looks great!

I know that, for a given Rededge camera, each plane is slightly offset (i.e. blue, red, green etc. do not align perfectly). Does Photoscan also do multi-plane alignment individually on each multi-plane camera? I am hoping I can extract a fully-aligned multi-spectral image from each camera, after performing matchPhotos() and alignCameras(). 

Thanks!

14
Python and Java API / Importing and detecting coded markers
« on: April 20, 2017, 07:02:57 PM »
Hi,

I am using the 12-bit coded markers, and Photoscan 1.3.1. I plan to use PhotoScan.detectMarkers() to automatically detect.

I have GPS coordinates for each marker, but I don't know how to import the marker reference coordinates into Photoscan so that the detected markers are mapped properly to the imported markers. Should I use chunk.importMarkers() or chunk.loadReference()? And how do I specify which marker is which? Do I need to know the numeric ID of the coded marker that I selected when printing?

Currently my plan is the following:

Code: [Select]
    # Assume I already have the chunk set up and photos imported.

    chunk.crs = PhotoScan.CoordinateSystem("EPSG::32613")
    chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy)
    chunk.alignCameras(adaptive_fitting=True)
    chunk.buildDenseCloud(quality=PhotoScan.UltraQuality, filter=PhotoScan.MildFiltering)
    PhotoScan.app.document.save("project.psx")
    chunk.loadReference(path='reference.csv', format=PhotoScan.ReferenceFormatCSV, columns=’nxyzXYZ’,
delimiter)   
    chunk.detectMarkers(type=PhotoScan.CircularTarget12bit)
    PhotoScan.app.document.save("project.psx")

...But I'm not sure if the order is correct, or if loadReference() is correct, or if I need to save the project.psx at a different place.

Here is my reference.csv layout:
Can I get some help? Thanks.

Pages: [1]