# -*- 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调取摄像头并实时显示
最新推荐文章于 2024-09-30 22:28:01 发布
本文介绍了如何使用OpenCV库在计算机上调用摄像头,并实时显示捕获到的视频流。通过简单易懂的步骤,读者可以学习到如何设置帧率、调整窗口大小以及进行基本的视频处理操作。
摘要由CSDN通过智能技术生成