1
Feature Requests / Re: Inteligent seamlines / cutlines
« on: March 22, 2017, 11:45:18 AM »
+1
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.
Чтобы удалить облако точек через Python нужно присвоить ему значение None:Code: [Select]chunk.dense_cloud = None
Добрый день, Леонид,
Вот пример скрипта, который разбивает исходную рабочую область на сетку N на M (задаётся в виде аргументов в соответствующей строке диалогового окна запуска скрипта). В принципе, такой подход можно расширить и на трёхмерный случай.
Обратите внимание, что исходный блок для данного скрипта должен содержать плотное облако.Code: [Select]## Splits active chunk into user defined grid of sub-chunks (images are kept but bounding box is split)
## after chunk being split, for every smaller chunk mesh is generated based on the dense cloud, then dense cloud is removed from smaller chunks
#arguments - X and Y grid sizes
#compatibility PhotoScan Professional 1.0.4
import PhotoScan
import sys
doc = PhotoScan.app.document
chunk = doc.activeChunk
def dist(v0, v1):
"""
Calculate distance between two points defined as vectors
"""
distance = (v1 - v0)
return distance.norm() #**2
partsX = 3 #parts of the model, 3 by default
partsY = 3
if len(sys.argv) == 2:
parts = int(sys.argv[1])
partsX = partsY = parts
elif len(sys.argv) == 3:
partsX = int(sys.argv[1])
partsY = int(sys.argv[2])
print("Script started...")
region = chunk.region
r_center = region.center
r_rotate = region.rot
r_size = region.size
x_scale = r_size.x / partsX
y_scale = r_size.y / partsY
z_scale = r_size.z
offset = r_center - r_rotate * r_size /2.
for j in range(1, partsY + 1): #creating new chunks and adjusting bounding box
for i in range(1, partsX + 1):
new_chunk = chunk.copy()
new_chunk.label = "Chunk "+ str(i)+ "\\" + str(j)
new_chunk.model = None
doc.chunks.add(new_chunk)
new_region = PhotoScan.Region()
new_rot = r_rotate
new_center = PhotoScan.Vector([(i - 0.5) * x_scale, (j - 0.5) * y_scale, 0.5 * z_scale])
new_center = offset + new_rot * new_center
new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])
new_region.size = new_size
new_region.center = new_center
new_region.rot = new_rot
new_chunk.region = new_region
PhotoScan.app.update()
if new_chunk.dense_cloud:
new_chunk.buildModel("height field", "dense", interpolation = "enabled", faces = "high")
new_chunk.resetDepth()
new_chunk.dense_cloud = None #removing dense cloud
print("Script finished...")
PhotoScan.app.update()