Opencv read picture pixel adjustment (1080, 1920) 1.cv2.VideoCapture (configured image reading) 2.cv2.nameWindow (Construction of a video display window) 3.cv2.setWindowProperty (picture window pixel set) 4 .video_capture (picture pixel set)

1. cv2.VideoCapture (0) # construct an arrest video 

Parameters: 0 expressed the need to start the camera, where you can also write path video

2. cv2.nameWindow (name, cv2.WINDOW_NORMAL) # build video window

Parameters: Indicates the name of the window, cv2.WINDOW_NORMAL represents the size of the window, where the window size is normal, 

3.cv2.setWindowProperty(name, cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)

Parameters: name expressed the need to change the pixel window name, cv2.WND_PROP_FULLSCREEN expressed full screen

4. video_capture.set (cv2.CAP_PROP_FRAME_WIDTH, 1920) of the window pixel set

Parameters: cv2.CAP_PROP_FRAME_WIDTH provided which indicates the size of the width, 1920 denotes a pixel set

video_capture = cv2.VideoCapture(0)
cv2.namedWindow("frame", cv2.WINDOW_NORMAL)
cv2.setWindowProperty("frame", cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
while True:
    ret, frame = video_capture.read()
    (h, w) = frame.shape[:2]
    print(h, w)
    center = (w/2, h/2)
    print()
    M = cv2.getRotationMatrix2D(center, 90, 1.0)
    rotated = cv2.warpAffine(frame, M, (1920, 1080))
    cv2.imshow('image', rotated)
    cv2.imwrite('2.png', rotated)
    cv2.waitKey(0)

 

Guess you like

Origin www.cnblogs.com/my-love-is-python/p/11457539.html