问题遇到的现象和发生背景
图像中绿色的框是用cv2.line画的, 然后需要将绿色框框, 通过滑动条来进行等比缩放。
问题相关代码,请勿粘贴截图
import cv2
import numpy as np
def empty():
pass
cv2.namedWindow('TrackBars')
cv2.resizeWindow('TrackBars', 150, 200)
cv2.createTrackbar('Hue min', 'TrackBars', 0, 255, empty())
img = np.zeros((856, 936, 3), np.uint8)
img = cv2.imread('C:/Users/Administrator/Desktop/xiangmu/test_dis/img/quanxi1.jpg')
size = img.shape
print(size)
左
img = cv2.line(img, (182, 250), (168, 258), (123, 231, 0), 2) # 颜色自己可以定义
img = cv2.line(img, (168, 258), (155, 270), (123, 231, 0), 2)
img = cv2.line(img, (155, 270), (135, 300), (123, 231, 0), 2)
img = cv2.line(img, (135, 300), (120, 330), (123, 231, 0), 2)
img = cv2.line(img, (120, 330), (113, 350), (123, 231, 0), 2)
img = cv2.line(img, (113, 350), (113, 570), (123, 231, 0), 2)
img = cv2.line(img, (113, 570), (125, 590), (123, 231, 0), 2)
右
img = cv2.line(img, (182, 250), (198, 258), (123, 231, 0), 2)
img = cv2.line(img, (198, 258), (212, 270), (123, 231, 0), 2)
img = cv2.line(img, (212, 270), (232, 300), (123, 231, 0), 2)
img = cv2.line(img, (232, 300), (247, 330), (123, 231, 0), 2)
img = cv2.line(img, (247, 330), (254, 350), (123, 231, 0), 2)
img = cv2.line(img, (254, 350), (254, 570), (123, 231, 0), 2)
img = cv2.line(img, (254, 570), (242, 590), (123, 231, 0), 2)
尾部
img = cv2.line(img, (125, 590), (242, 590), (123, 231, 0), 2)
cv2.imshow('quanxi', img)
cv2.imwrite('./img/anquan.jpg', img)
cv2.waitKey(0)
cv2.destroyAllWindows()