1
如何將cv2.boundingRect
應用於np.array
點?
以下代碼會產生錯誤。在np.array上應用cv2.boundingRect
points = np.array([[1, 2], [3, 4]], dtype=np.float32)
import cv2
cv2.boundingRect(points)
錯誤:
OpenCV Error: Unsupported format or combination of formats (The image/matrix format is not supported by the function) in cvBoundingRect, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/shapedescr.cpp, line 97
File "<ipython-input-23-42e84e11f1a7>", line 1, in <module>
cv2.boundingRect(points)
error: /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/shapedescr.cpp:970: error: (-210) The image/matrix format is not supported by the function in function cvBoundingRect
我要建議'輸出cv2.boundingRect(cv2.cv.fromarray(點))'但是這似乎並沒有工作。返回'TypeError:點不是一個numpy數組,也不是一個標量' – jmunsch
我試過你的代碼,它給了我這個邊界框沒有錯誤(1,2,3,3),這似乎是真的。但是,我的簡歷版本是'3.1.0-dev'。 – cagatayodabasi