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

Pages: [1]
1
General / Orthomosaic Background Differences
« on: September 01, 2018, 12:58:37 AM »
Greetings,

I'm exporting an Orthomosaic from a project using the PhotoScan Python API (v 1.4.2). I've noticed the following behavior which I can't explain.

When exporting an image using the following code, I get a proper RGBA image with an alpha channel.

Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
doc.open("/data/some_project.psx")
chunk = doc.chunks[0]

wkt = 'PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32616"]]'

coord_sys = PhotoScan.CoordinateSystem(wkt)

chunk.exportOrthomosaic(
  "/data/some_ortho_image.tif",
  image_format=PhotoScan.ImageFormat.ImageFormatTIFF,
  projection=coord_sys,
  write_alpha=True)

When exporting an image using a the JPEG compression method, the resulting image is a simple 3 band RGB image with no alpha mask. Given that JPEG is simply the compression method, why would there be a difference in the number of output bands in the resulting image?

Code: [Select]
import PhotoScan

doc = PhotoScan.app.document
doc.open("/data/some_project.psx")
chunk = doc.chunks[0]

wkt = 'PROJCS["WGS 84 / UTM zone 16N",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9102"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-87],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32616"]]'

coord_sys = PhotoScan.CoordinateSystem(wkt)

chunk.exportOrthomosaic(
  "/data/some_ortho_image_without_alpha.tif",
  image_format=PhotoScan.ImageFormat.ImageFormatTIFF,
  projection=coord_sys,
  tiff_compression=PhotoScan.TiffCompression.TiffCompressionJPEG,
  write_alpha=True)

Notice the only difference in the two code samples is that of the tiff_compression parameter.

Ian

2
I am attempting to use Network Processing to run a number of tasks in a distributed environment. The BuildDEM task however, fails for all attempts when constructing the task from the Console window. When constructing the NetworkTask from the UI, I have no problem.

The 'createBatch' result when creating the task via the UI produces the following JSON:

Code: [Select]
{
"id": 152,
"method": "createBatch",
"params": {
"path": "some_photoscan_project.psx",
"tasks": [{
"frames": [
[0, 0]
],
"name": "BuildDem",
"params": {
"projection": {
"crs": "GEOGCS[\"WGS 84\",DATUM[\"World Geodetic System 1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9102\"]],AUTHORITY[\"EPSG\",\"4326\"]]",
"radius": 1,
"surface": 0,
"transform": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
}
}
}],
"username": "someuser"
}
}

When creating the batch via the Python console, the following JSON is produced:

Code: [Select]
{
"id": 4,
"method": "createBatch",
"params": {
"path": "some_photoscan_project.psx",
"tasks": [{
"name": "BuildDem",
"params": {
"projection": {
"crs": "[\"\",[\"\"],UNIT[\"\",0]]",
"radius": 1,
"surface": 0,
"transform": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
}
},
"supports_gpu": false
}],
"username": "someuser"
}
}

The principle difference between the two appears to be the CRS member of the "projection" parameter. For whatever reason, the "PhotoScan.OrthoProjection" type does not appear to serialize the "CRS" member of the projection parameter correctly. Can you provide any examples to create a projection parameter that is crafted correctly for the BuildDEM task?

Thanks,

Ian

Pages: [1]