Reputation: 99
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
Upvotes: 9
Views: 18008
Reputation: 18331
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]]
Upvotes: 26