由于暂时没有实现led灯的定位,所以这里放上led灯ROI定位工具代码。
# -*- coding: utf-8 -*-
"""
Class definition of YOLO_v3 style detection model on image and video
"""
import cv2
import OperationMysql as mySql
img = cv2.imread('images/test.jpg')
op_mysql = mySql.OperationMysql()
#for循环多个区域,选取后去输出,可存储入数据库
for num in range(1,10):
roi = cv2.selectROI(windowName='roi' , img=img, showCrosshair=True, fromCenter=False)
#x, y, w, h = (96, 84, 63, 29)
x, y, w, h = roi
print(x, y, w, h)
cv2.rectangle(img=img, pt1=(x, y), pt2=(x + w, y + h), color=(0, 0, 255), thickness=1)
# op_mysql = mySql.OperationMysql()
# res = op_mysql.insert_one('insert led_roi (x_length,y_length,w_length,h_length) values ({0},{1},{2},{3})'.format(x, y, w, h))
cv2.waitKey(0)
cv2.destroyAllWindows()