import
numpy as np
import
cv2
img2
=
cv2.imread(
'arrow.jpg'
, cv2.IMREAD_COLOR)
img
=
cv2.imread(
'arrow.jpg'
, cv2.IMREAD_GRAYSCALE)
_,threshold
=
cv2.threshold(img,
110
,
255
,
cv2.THRESH_BINARY)
contours,_
=
cv2.findContours(threshold, cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)
for
cnt
in
contours :
area
=
cv2.contourArea(cnt)
if
area >
400
:
approx
=
cv2.approxPolyDP(cnt,
0.009
*
cv2.arcLength(cnt,
True
),
True
)
if
(
len
(approx)
=
=
7
):
cv2.drawContours(img2, [approx],
0
, (
0
,
0
,
255
),
5
)
cv2.imshow(
'image2'
, img2)
if
cv2.waitKey(
0
) &
0xFF
=
=
ord
(
'q'
):
cv2.destroyAllWindows()