День добрый, требуется ваша помочь, нужно определить цвет фигуры и направления стрелки от 0 до 360 градусов. Уже несколько часов думаю над этой задачей, ничего в голову не приходит.
import numpy as np
import cv2 as cv
hsv_min = np.array((0, 50, 50), np.uint8)
hsv_max = np.array((187, 255, 253), np.uint8)
if __name__ == '__main__':
img = cv.imread('img.png')
hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)
thresh = cv.inRange(hsv, hsv_min, hsv_max)
contours, _ = cv.findContours(thresh.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_NONE)
for cnt in contours:
rect = cv.minAreaRect(cnt)
area = int(rect[1][0]*rect[1][1])
if area < 300:
continue
box = cv.boxPoints(rect)
box = np.int0(box)
cv.drawContours(img, [box], -1, (255, 0, 0), 2)
cv.imshow('contours', img)
cv.waitKey()
cv.destroyAllWindows()