m0_46685009
2022-03-20 15:15
采纳率: 52.5%
浏览 72

cv2.resize后修改显示图片大小


import cv2
 
cap = cv2.VideoCapture(0)        #打开摄像头
cap.set(cv2.CAP_PROP_FRAME_WIDTH,5000)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,5000) 
#size = (int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))
size = (int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), 2000)
print(size)
while(1):
    ret, frame = cap.read()
    img = cv2.resize(frame,size) 
    cv2.namedWindow('img1', cv2.WINDOW_AUTOSIZE)
    cv2.resizeWindow('img1',(500,500))
    cv2.imshow('img1',img) 
    
    if cv2.waitKey(1) & 0xFF == ord('q'):   #如果按下q 就截图保存并退出
        cv2.imwrite("test3.bmp", img)   #保存路径
        break
 
cap.release()
cv2.destroyAllWindows()

因为img像素很大设置完window大小后显示还是沾满屏幕,该怎么做

1条回答 默认 最新

相关推荐 更多相似问题