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

Pages: 1 [2]
16
Python and Java API / Export Point Classes
« on: February 15, 2018, 04:48:52 AM »
Hi,

To export only specific point classes is the below the correct method;

Code: [Select]
chunk.exportPoints(mypath, source=PhotoScan.DenseCloudData, format=PhotoScan.PointsFormatLAS, projection=v_projection, blockw=1000, blockh=1000, classes=[1,2])
Ben

17
Python and Java API / Re: 'PhotoScan' has no attribute 'pointCloudData'
« on: September 26, 2017, 03:01:21 AM »
Thank You for the clarification

18
Python and Java API / Clarification of ModelData and Elevation-Data
« on: September 22, 2017, 06:18:16 AM »
Version 1.3.3 build 4827 (64 bit)
Win 10

Hello,

When using buildOrthomosaic() surface

does modelData use the surface from buildModel()
and does Elevation-Data use the surface from buildDem()

I have also found that Elevation-Data throws an error and ElevationData does not

The manual states;

class PhotoScan.DataSource
Data source in [PointCloudData, DenseCloudData, DepthMapsData, ModelData, TiledModelData, Elevation-Data, OrthomosaicData]

Ben

19
Python and Java API / 'PhotoScan' has no attribute 'pointCloudData'
« on: September 22, 2017, 02:29:59 AM »
Version 1.3.3 build 4827 (64 bit)
Win 10

Hello,

Could someone tell me what I have done wrong?

I am getting the following error;

Traceback (most recent call last):
2017-09-22 09:05:35   File "E:/PhotoScan_Scripts/photoscan_process_dji_p4p_ver13.py", line 182, in <module>
2017-09-22 09:05:35     chunk.buildOrthomosaic(surface=PhotoScan.DataSource.PointCloudData, blending=PhotoScan.BlendingMode.MosaicBlending, color_correction=True, fill_holes=True)
2017-09-22 09:05:35 RuntimeError: Unsupported data source


This is the offending line;
Code: [Select]
chunk.buildOrthomosaic(surface=PhotoScan.DataSource.PointCloudData, blending=PhotoScan.BlendingMode.MosaicBlending, color_correction=True, fill_holes=True)
And this is the full script;

Code: [Select]
import PhotoScan
import os

global doc

#Used to loop through folders
#Add comma delimited list of project folders below
collection = ['test_1','test_2']

for project_name in collection:

doc = PhotoScan.app.document

print('project_path')
drive = 'E'
project_path = os.path.normpath(drive + ":/" + project_name + "/" + project_name + ".psx")
path_photos = os.path.normpath(drive + ":/" + project_name + "/JPEG")
output_path = os.path.normpath(drive + ":/" + project_name + "/")

print(project_path)
print(path_photos)
print(output_path)

# Create project file
doc.save(project_path, chunks = doc.chunks )
doc.open(project_path)

# Remove Chunks if they exist (they are in the order 1 and 0 for a reason).
print('Remove chunks if exist')
if len(doc.chunks):
doc.chunk = doc.chunks[1]
chunk = doc.chunk
doc.remove(chunk)

if len(doc.chunks):
doc.chunk = doc.chunks[0]
chunk = doc.chunk
doc.remove(chunk)

print('Name the chunk for dense cloud')
chunk = PhotoScan.app.document.addChunk()
chunk.label = project_name + "_dense_cloud"

print('Add Photos')
image_list = [
os.path.join(path_photos, path)
for path in os.listdir(path_photos)
if path.lower().endswith(("jpg", "jpeg", "tif", "png","JPG","JPEG","TIF",""))
]

print(image_list)
chunk.addPhotos(image_list)

print('Load Exif')
chunk.loadReferenceExif()

print('Set COORD SYS to WGS84')
coord_system = PhotoScan.CoordinateSystem('EPSG::4326')
chunk.crs = coord_system

print('Match Photos')
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.ReferencePreselection, tiepoint_limit=40000)

print('Align Cameras')
chunk.alignCameras()

print('Optimize Cameras')
chunk.optimizeCameras()

print('Build Dense Point Cloud')
#UltraQuality, HighQuality, MediumQuality, LowQuality, LowestQuality
#NoFiltering, MildFiltering, ModerateFiltering, AggressiveFiltering
chunk.buildDenseCloud(quality=PhotoScan.HighQuality, filter=PhotoScan.NoFiltering)   

print('Copy chunk for sparse cloud processing.')
chunk.copy()
doc.chunk = doc.chunks[1]
chunk = doc.chunk
chunk.label = project_name + "_sparse_cloud"

print('Return to the chunk for dense cloud processing')
doc.chunk = doc.chunks[0]
chunk = doc.chunk

#print('Classify Ground Points')
#chunk.classifyGroundPoints(max_angle=15.0, max_distance=4.0, cell_size=5.0)

#print('Export Point Cloud')
#chunk.exportPoints(output_path + "/POINT_CLOUD/" + project_name + "_pointcloud.txt", source=PhotoScan.DenseCloudData, format=PhotoScan.PointsFormatXYZ, blockw=1000, blockh=1000)

# -------------------------------------------------------------------
# Create Dense Cloud Chunk
# -------------------------------------------------------------------

'''
print('Build Model (Mesh) using dense cloud')
chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.DenseCloudData, face_count=PhotoScan.MediumFaceCount, interpolation=PhotoScan.EnabledInterpolation)

print('Close Holes')
chunk.model.closeHoles(level = 50)

print('Mapping Mode')
chunk.buildUV(mapping=PhotoScan.OrthophotoMapping)

print('Build Texture')
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=8192)

print('Save project')
doc.save()

#print('Export Report')
chunk.exportReport(output_path + project_name + "_dense_cloud.pdf")
'''

# -------------------------------------------------------------------
# Create Sparse Cloud Chunk
# -------------------------------------------------------------------

print('Make new chunk %_sparse_cloud active')
doc.chunk = doc.chunks[1]
chunk = doc.chunk

#print('Build Dense Point Cloud')
#We have copied the Dense Point Cloud from the Chunk above so we dont have to process it again.
#UltraQuality, HighQuality, MediumQuality, LowQuality, LowestQuality
#NoFiltering, MildFiltering, ModerateFiltering, AggressiveFiltering
#chunk.buildDenseCloud(quality=PhotoScan.HighQuality, filter=PhotoScan.NoFiltering)

print('Build Model (Mesh) using sparse cloud (pointCloudData = sparse cloud)')
chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.PointCloudData, face_count=PhotoScan.MediumFaceCount, interpolation=PhotoScan.EnabledInterpolation)

print('Save project')
doc.save()

print('Close Holes')
chunk.model.closeHoles(level = 50)

print('Mapping Mode')
chunk.buildUV(mapping=PhotoScan.OrthophotoMapping)

print('Build Texture')
chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=8192)

print('Save project')
doc.save()

print('Build Dem using sparse cloud (PointCloudData)')
chunk.buildDem(source=PhotoScan.PointCloudData, interpolation=PhotoScan.EnabledInterpolation)

print('Export Dem to GDA94 Zone 50')
chunk.exportDem(output_path +'/DEM/'+ project_name + "_DEM_DenseCloud_NoFiltering.tif",image_format=PhotoScan.ImageFormatTIFF, projection=PhotoScan.CoordinateSystem('EPSG::28350'))

print('Export INPHO file to GDA94 Zone 50 ')
chunk.exportCameras(output_path + project_name + "_inpho_EPSG28350.prj", format=PhotoScan.CamerasFormatInpho, projection=PhotoScan.CoordinateSystem('EPSG::28350'), rotation_order=PhotoScan.RotationOrderXYZ)

print('Build Orthomosaic')
chunk.buildOrthomosaic(surface=PhotoScan.DataSource.PointCloudData, blending=PhotoScan.BlendingMode.MosaicBlending, color_correction=True, fill_holes=True)

print('Export Orthomosaic to GDA94 Zone 50')
chunk.exportOrthomosaic(output_path +'/ORTHO/'+ project_name + "_Ortho_SparseCloud_NoFiltering_EPSG28350.tif", image_format=PhotoScan.ImageFormatTIFF, projection=PhotoScan.CoordinateSystem('EPSG::28350'))

print('Export Report')
chunk.exportReport(output_path + project_name + "_sparse_cloud.pdf")

print('Save project')
doc.save()
   
The PhotoScan Python reference states the following;

class PhotoScan.DataSource
Data source in [PointCloudData, DenseCloudData, DepthMapsData, ModelData, TiledModelData, Elevation-Data, OrthomosaicData]

Regards
Ben

   


20
Python and Java API / Re: Chunk Name
« on: September 18, 2017, 09:15:45 AM »
Found out you could use chunk.label

21
Python and Java API / Chunk Name
« on: September 18, 2017, 06:18:40 AM »
Hello,

Is it possible to give a chunk a name?

Ben

22
Python and Java API / Re: addPhotos Error
« on: September 18, 2017, 03:23:06 AM »
Thank You

23
Python and Java API / Re: Sparse Cloud
« on: September 15, 2017, 03:18:11 AM »
Great - Thank You for your assistance.

24
Python and Java API / Re: How to use optimizeCamera
« on: September 15, 2017, 03:16:34 AM »
Thank You

25
Python and Java API / Sparse Cloud
« on: September 14, 2017, 09:52:39 AM »
Hi,

How do I get this to use the sparse cloud and not the dense cloud;

Code: [Select]
chunk.buildModel(surface=PhotoScan.HeightField, source=PhotoScan.DenseCloudData, face_count=PhotoScan.MediumFaceCount, interpolation=PhotoScan.EnabledInterpolation)
Ben

26
Python and Java API / addPhotos Error
« on: September 14, 2017, 04:31:59 AM »
Hi,

PhotoScan Pro Ver 1.2.6 Build 2834

I have the following code that returns an error, can someone tell me why?


This is the error I get (in red);

2017-09-14 09:27:38 Saving project...
2017-09-14 09:27:38 saved project in 0.016 sec
2017-09-14 09:27:38 Finished processing in 0.016 sec (exit code 1)
2017-09-14 09:27:38 Loading project...
2017-09-14 09:27:38 loaded project in 0 sec
2017-09-14 09:27:39 Finished processing in 0 sec (exit code 1)
2017-09-14 09:27:39 E:\python_dev\py_test101.psz
2017-09-14 09:27:39 ['E:\\python_dev\\JPEG\\DJI_0416.JPG', 'E:\\python_dev\\JPEG\\DJI_0417.JPG', 'E:\\python_dev\\JPEG\\DJI_0418.JPG', 'E:\\python_dev\\JPEG\\DJI_0419.JPG', 'E:\\python_dev\\JPEG\\DJI_0420.JPG', 'E:\\python_dev\\JPEG\\DJI_0421.JPG', 'E:\\python_dev\\JPEG\\DJI_0422.JPG', 'E:\\python_dev\\JPEG\\DJI_0433.JPG', 'E:\\python_dev\\JPEG\\DJI_0434.JPG', 'E:\\python_dev\\JPEG\\DJI_0435.JPG', 'E:\\python_dev\\JPEG\\DJI_0436.JPG', 'E:\\python_dev\\JPEG\\DJI_0437.JPG', 'E:\\python_dev\\JPEG\\DJI_0438.JPG', 'E:\\python_dev\\JPEG\\DJI_0439.JPG', 'E:\\python_dev\\JPEG\\DJI_0446.JPG', 'E:\\python_dev\\JPEG\\DJI_0447.JPG', 'E:\\python_dev\\JPEG\\DJI_0448.JPG', 'E:\\python_dev\\JPEG\\DJI_0449.JPG', 'E:\\python_dev\\JPEG\\DJI_0450.JPG', 'E:\\python_dev\\JPEG\\DJI_0451.JPG', 'E:\\python_dev\\JPEG\\DJI_0452.JPG', 'E:\\python_dev\\JPEG\\DJI_0462.JPG', 'E:\\python_dev\\JPEG\\DJI_0463.JPG', 'E:\\python_dev\\JPEG\\DJI_0464.JPG', 'E:\\python_dev\\JPEG\\DJI_0465.JPG', 'E:\\python_dev\\JPEG\\DJI_0466.JPG', 'E:\\python_dev\\JPEG\\DJI_0467.JPG']
2017-09-14 09:27:39 Traceback (most recent call last):
2017-09-14 09:27:39   File "E:/python_dev/create_project_ver2.py", line 28, in <module>
2017-09-14 09:27:39     chunk.addPhotos(image_list)
2017-09-14 09:27:39 AttributeError: 'NoneType' object has no attribute 'addPhotos'

>>>

This is the code;

Code: [Select]
import PhotoScan
import os

global doc
doc = PhotoScan.app.document

project_path = r'E:\python_dev\py_test101.psz'
path_photos = r'E:\python_dev\JPEG'

# Create project file
doc.save(project_path, chunks = doc.chunks)
doc.open(project_path)
chunk = doc.chunk

# Add Photos
image_list = [
    os.path.join(path_photos, path)
    for path in os.listdir(path_photos)
    if path.lower().endswith(("jpg", "jpeg", "tif", "png"))
    ]

print(project_path)
print(image_list)

chunk.addPhotos(image_list)

# Save project
doc.save()

Ben

27
Python and Java API / How to use optimizeCamera
« on: September 14, 2017, 02:37:21 AM »
Hi,

I want to use optimizeCamera but it has thrown the following error;

2017-09-13 16:15:10 Traceback (most recent call last):
2017-09-13 16:15:10   File "E:/python_dev/create_project.py", line 44, in <module>
2017-09-13 16:15:10     chunk.optimizeCameras(fit_b1=True, fit_k1=True, fit_k2=True, fit_k3=True, fit_p1=True, fit_p2=True)
2017-09-13 16:15:10 TypeError: 'fit_p1' is an invalid keyword argument for this function

And this is the line of code that I used in my script;

Code: [Select]
chunk.optimizeCameras(fit_b1=True, fit_k1=True, fit_k2=True, fit_k3=True, fit_p1=True, fit_p2=True)
What have I done wrong?

Ben

28
Python and Java API / Re: Write path into script
« on: September 13, 2017, 10:41:56 AM »
I figured it out

29
Python and Java API / Write path into script
« on: September 13, 2017, 06:39:50 AM »
Hi,

Is there a way to hardcode a path for addPhotos into a script this line of code;

Code: [Select]
path_photos = PhotoScan.app.getExistingDirectory("Specify folder with input photos:")

prompts the user during the running of the script but I would like to write the path directly into the script, so no prompt appears

I have attempted to use this;

Code: [Select]
path_photos = r'C:\folder_name\jpeg'

Ben

Pages: 1 [2]