简体   繁体   中英

Why can't use `cv2.cv.BoxPoints` in OpenCV (Python)?

I am a beginner in OpenCV. I want to make bounding box around my detected marker.

Can you tell me how can I do it with OpenCV (Python)?

I'm using Python 3.6.3 with openCV

box =np.int0(cv2.cv.BoxPoints(marker))

Output:

Error showing cv2.cv2 has no module cv 

cv2.cv.BoxPoints was changed.

For OpenCV 3.x, use cv2.boxPoints instead.


For example:

>> import numpy as np
>> import cv2
>>> cv2.__version__
'3.3.0-dev'

>>> cnt = np.array([[0,0], [1,1], [2,0]])
>>> bbox = cv2.minAreaRect(cnt)
>>> pts = cv2.boxPoints(bbox)
>>> print(pts)
[[  9.99999940e-01   9.99999881e-01]
 [  5.96046448e-08   0.00000000e+00]
 [  9.99999940e-01  -9.99999881e-01]
 [  1.99999976e+00   0.00000000e+00]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM