使用openCV-python显示图像时使用input()命令
我想在Python Notebook中使用OpENCV显示我的图像,同时从用户那里获取输入。当图像在全屏中显示时,输入命令不接受输入,除非我最大程度地减少全屏,然后单击文本栏以提供输入。我想在全屏显示图像时使用输入命令。请参阅代码
import threading
import time
import glob
import cv2
def threadFunc():
while True:
for k in range(0,3):
directory="/" + "*" + "." + "j" + "p" + "g"
images = [cv2.imread(file) for file in glob.glob(directory)]
for i in images:
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.imshow('window',i)
cv2.waitKey(3000)
def main():
th = threading.Thread(target=threadFunc)
th.start()
while True:
time.sleep(1)
code_read=(input("Enter Number : "))
print(code_read)
if __name__ == '__main__':
main()
我想在文件夹中显示多个图像,然后将用户输入存储为响应。为简单起见,我只使用print命令。
I want to take input from user at the same time while displaying my image with opencv in python notebook. When the image is displaying in full screen, input command do not take input unless I minimize full screen and click on text bar to give input. I want to use input command while displaying image in full screen. Please see code
import threading
import time
import glob
import cv2
def threadFunc():
while True:
for k in range(0,3):
directory="/" + "*" + "." + "j" + "p" + "g"
images = [cv2.imread(file) for file in glob.glob(directory)]
for i in images:
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.imshow('window',i)
cv2.waitKey(3000)
def main():
th = threading.Thread(target=threadFunc)
th.start()
while True:
time.sleep(1)
code_read=(input("Enter Number : "))
print(code_read)
if __name__ == '__main__':
main()
I want to display images multiple images in folder one by one and store user input as response. for simplicity I just use print command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论