cv2.kmeans usage in Python

前端 未结 2 1742
萌比男神i
萌比男神i 2021-02-06 04:03

I am considering to use OpenCV\'s Kmeans implementation since it says to be faster...

Now I am using package cv2 and function kmeans,

I can not understand the pa

2条回答
  •  春和景丽
    2021-02-06 04:53

    The problem here is your data_1.transpose is not a numpy array.

    OpenCV 2.3.1 and higher python bindings do not take anything except numpy array as image/array parameters. so, data_1.transpose has to be a numpy array.

    Generally, all the points in OpenCV are of type numpy.ndarray

    eg.

    array([[[100., 433.]],
           [[157., 377.]],
           .
           .  
           [[147., 247.]], dtype=float32)
    

    where each element of array is

    array([[100., 433.]], dtype=float32)
    

    and the element of that array is

    array([100., 433.], dtype=float32)
    

提交回复
热议问题