1
Python and Java API / Re: captureModelView
« on: August 14, 2019, 07:01:12 PM »
Да, все отлично! Спасибо еще раз!
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.
R = Metashape.Matrix( [[0.87, -0.5, 0], [0.5, 0.87, 0], [0, 0, 1]] ).t()
T = T.Rotation(R)
bbox_rot = 50.58462719482992 # deg
point = chunk.region.center + Metashape.Vector([0,0, chunk.region.size.z * 2])
SinRotZ = math.sin(math.radians(bbox_rot))
CosRotZ = math.cos(math.radians(bbox_rot))
T = Metashape.Matrix([[CosRotZ, SinRotZ, 0, point.x], [SinRotZ, CosRotZ, 0, point.y], [0, 0.5, -1, point.z], [0, 0, 0, 1]])
point = chunk.region.center + Metashape.Vector([0,0, chunk.region.size.z * 2])
T = Metashape.Matrix([[1,0,0, point.x], [0,-1,0, point.y], [0,0,-1, point.z], [0,0,0,1]])
calibration = chunk.sensors[0].calibration
calibration.f = 5 / 0.006
calibration.cx = 0
calibration.cy = 0
calibration.b1 = 0
calibration.b2 = 0
calibration.k1 = 0
calibration.k2 = 0
calibration.k3 = 0
calibration.k4 = 0
calibration.p1 = 0
calibration.p2 = 0
calibration.width = 4000
calibration.height = 6000
calibration.type = Metashape.Sensor.Type.Frame
render = chunk.model.renderImage(T, calibration)
# Model Image
viewpoint = Metashape.app.viewpoint
cx = viewpoint.width
cy = viewpoint.height
print(cx)
print(cy)
capture = Metashape.app.captureModelView(width = cx, height = cy, transparent = (True), hide_items = (True), source = Metashape.DataSource.ModelData, mode = Metashape.ModelViewMode.ShadedModelView)
print(capture.height)
capture.save(main_path + "model_preview.png")
RuntimeError: Can't save image: /task_files/fd6faba4-bda8-11e9-8ccc-606dc717741f/model_preview.pngВот что в capture:
<Image '0x0x0'>
Расчёт площади с учётом рельефа пока также не поддерживается. Альтернативный вариант - расчёт площади для полигональной модели, т.к. данный метод суммирует площадь всех полигонов модели. Но такой подход требует удаления лишней геометрии.
if len(coords) >= 2:
new_shape = chunk.shapes.addShape()
new_shape.label = "boundary"
new_shape.type = Metashape.Shape.Polygon
new_shape.has_z = True
new_shape.vertices = [Metashape.Vector([coord[1], coord[0]]) for coord in coords]
chunk.shapes.updateAltitudes(new_shape)
print("Периметр фигуры:",new_shape.perimeter2D()," м.")
print("Периметр фигуры с учетом высоты вершин:",new_shape.perimeter3D()," м.")
print("Площадь фигуры:",new_shape.area()," м^2.")
print("Объем фигуры:",new_shape.volume(level = 0)['total']," м^3.")
print("New shape created.")
2019-07-29 14:34:58 Finished processing in 0.011056 sec (exit code 1)
2019-07-29 14:34:58 Calculating 2D dimensions...
2019-07-29 14:34:58 Периметр фигуры: 312.7722914106116 м.
2019-07-29 14:34:58 Периметр фигуры с учетом высоты вершин: 0.0 м.
2019-07-29 14:34:58 Calculating 2D dimensions...
2019-07-29 14:34:58 Площадь фигуры: 3027.203739898397 м^2.
2019-07-29 14:34:58 Calculating plane...
2019-07-29 14:34:58 Calculating vertex coordinates...
2019-07-29 14:34:58 Calculating volume...
2019-07-29 14:34:58 Finished processing in 0.125381 sec (exit code 1)
2019-07-29 14:34:58 Объем фигуры: 375278.9691737943 м^3.
2019-07-29 14:34:58 New shape created.