[英]How to display an image and a terminal in OpenCV
如何使用 OpenCV 同时显示我的网络摄像头和终端? 我需要终端运行一些命令来使网络摄像头出现,并通过对象检测执行其他不同的操作。
下面是运行,而在同一时间能够使用终端网络摄像头的一个非常简单的例子input()
通过执行所有OpenCV的帧捕捉,并imshow
从一个单独的线程荷兰国际集团:
from threading import Thread
import cv2
shouldExit = False
color = True
def cam():
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
while not shouldExit:
ret, frame = cap.read()
if not color:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("window title", frame)
cv2.waitKey(1)
cap.release()
cv2.destroyAllWindows()
t = Thread(target=cam)
t.start()
while True:
print('select an action: q-quit, t-toggle color')
choice = input(">").strip().lower()
if choice == 'q':
shouldExit = True
t.join()
break
elif choice == 't':
color = not color
else:
print('invalid input')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.