count
方法是Matrix4dVector
类中的一个方法,用于返回保存在向量中的Matrix4d
对象的数量。
Matrix4dVector
类继承自Python内置的list
类,因此支持大多数list类的基本操作。
count(self, value: Any) -> int
value
:需要统计的对象。在Matrix4dVector
类中,它应该是Matrix4d
对象。count
:对应对象出现的次数。import open3d as o3d
import numpy as np
transformation_1 = np.array([[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]])
transformation_2 = np.array([[0, 1, 0, 0],
[-1, 0, 0, 0],
[0, 0, 1, 1],
[0, 0, 0, 1]])
matrix4d_vector = o3d.utility.Matrix4dVector([transformation_1, transformation_1, transformation_2])
count_of_transformation_1 = matrix4d_vector.count(transformation_1)
count_of_transformation_2 = matrix4d_vector.count(transformation_2)
print(f"Transformation 1 appears {count_of_transformation_1} times")
print(f"Transformation 2 appears {count_of_transformation_2} times")
Transformation 1 appears 2 times
Transformation 2 appears 1 times
如果向向量中传入的不是Matrix4d
对象,则count
方法将会抛出TypeError
异常。