失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python opencv 拍照_在jupyter noteb中使用opencv显示网络摄像头中的图像

python opencv 拍照_在jupyter noteb中使用opencv显示网络摄像头中的图像

时间:2019-04-20 14:00:38

相关推荐

python opencv 拍照_在jupyter noteb中使用opencv显示网络摄像头中的图像

我正在尝试显示网络摄像头拍摄的图像。但是,存储捕获图像的变量是空的。此问题仅在使用网络摄像头时出现,而不是在播放mp4等视频时出现。这个问题是由Python版本引起的吗?我的OpenCV版本是3.4.3,Python版本是3.6.5。在import numpy as np

import cv2

from IPython import display

import matplotlib.pyplot as py

%matplotlib inline

def showVideo():

try:

print('카메라를 구동합니다.')

cap = cv2.VideoCapture(0)

except:

print('카메라 구동 실패')

return

print(cap.isOpened())

print(cap.read())

cap.set(3, 480)

cap.set(4, 320)

try:

while(True):

# Capture frame-by-frame

ret, frame = cap.read()

if not ret:

# Release the Video Device if ret is false

cap.release()

# Message to be displayed after releasing the device

print ("Released Video Resource")

break

frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

# Turn off the axis

py.axis('off')

# Title of the window

py.title("Input Stream")

# Display the frame

py.imshow(frame)

py.show()

# Display the frame until new frame is available

display.clear_output(wait=True)

except keyboardInterrupt:

# Release the Video Device

cap.release()

# Message to be displayed after releasing the device

print("Released Video Resource")

pass

如果觉得《python opencv 拍照_在jupyter noteb中使用opencv显示网络摄像头中的图像》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。