# -*- coding: utf-8 -*-
"""
Created on Mon May 7 14:59:54 2018
@author: PC
"""
import cv2
import time
import numpy as np
cam = cv2.VideoCapture(0)
cam.set(3, 2448) # set video widht
cam.set(4, 2448) # set video height
ret, img =cam.read()
img = np.rot90(img)
#img = np.rot90(img)
img = cv2.flip(img, 1)
img = np.rot90(img)
cv2.namedWindow('camera')
#cam1 = cv2.VideoCapture(1)
#cam1.set(3, 1440) # set video widht
#cam1.set(4, 1280) # set video height
#ret, img1 =cam1.read()
#img = cv2.flip(img, 1)
#img1 = np.rot90(img1)
#cv2.namedWindow('camera1')
#cv2.setMouseCallback("img", onmouse) #回调绑定窗口
while True:
ret, img =cam.read()
img = np.rot90(img)
# img = np.rot90(img)
img = cv2.flip(img, 1)
img = np.rot90(img)
cv2.imshow('camera',img)
k = cv2.waitKey(10) & 0xff #
opencv调取摄像头并实时显示
最新推荐文章于 2023-04-13 22:34:33 发布