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
BoxPoints Method. Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
cv2 (old interface in old OpenCV versions was named as cv ) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet.
cv2 is the module import name for opencv-python, "Unofficial pre-built CPU-only OpenCV packages for Python". The traditional OpenCV has many complicated steps involving building the module from scratch, which is unnecessary. I would recommend remaining with the opencv-python library.
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]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With