Hi all !! I need your help...I try autopaching system with shape in orthophoto but in this version has a this error:
Traceback (most recent call last):
2020-11-18 18:01:36 File "C:/Users/RPAS_02/Desktop/4.py", line 89, in <module>
2020-11-18 18:01:36 polygon_auto_patching()
2020-11-18 18:01:36 File "C:/Users/RPAS_02/Desktop/4.py", line 49, in polygon_auto_patching
2020-11-18 18:01:36 shape_centroids[shape] = findCentroid(shape)
2020-11-18 18:01:36 File "C:/Users/RPAS_02/Desktop/4.py", line 11, in findCentroid
2020-11-18 18:01:36 for i in range(1, len(shape.vertices) - 1):
2020-11-18 18:01:36 TypeError: object of type 'NoneType' has no len()
2020-11-18 18:01:36 Error: object of type 'NoneType' has no len()
This is the code:
def findCentroid(shape):
area_sum = 0
C = Metashape.Vector([0, 0])
print("shape",shape.label)
print("vertices",shape.vertices)
for i in range(1, len(shape.vertices) - 1):
cent = shape.vertices[0] + shape.vertices + shape.vertices[i + 1]
area = area2(shape.vertices[0], shape.vertices, shape.vertices[i + 1])
C += Metashape.Vector([area * cent.x, area * cent.y])
area_sum += area
C /= (3 * area_sum)
return C
When I print the vertices...its show "none" but if I used the version 1.5.0 the code works fine...¿Anyone know what might be happening?My intention is to use an image automatically to patch all the forms, does anyone have any scripts that can help me?
Best reguards.