【问题标题】:Python Function is not executed in the outputPython 函数未在输出中执行
【发布时间】:2019-08-06 13:42:36
【问题描述】:

我正在使用 opencv 和 pyautogui 创建一个相机应用程序。该功能没有得到评估。

from utils import CFEVideoConf, image_resize


def recog():
    cap = cv2.VideoCapture(0)
    save_path = 'saved-media/video.avi'
    frames_per_seconds = 24.0
    config = CFEVideoConf(cap, filepath=save_path, res='720p')
    out = cv2.VideoWriter(save_path, config.video_type, frames_per_seconds, config.dims)

    while (True):
        # Capture frame-by-frame
        ret, frame = cap.read()
        out.write(frame)
        # Display the resulting frame
        cv2.imshow('frame',frame)
        if cv2.waitKey(20) & 0xFF == ord('q'):
            op = pyautogui.confirm("") 
            if op == 'OK':
                print("Out")
                break
    cap.release()
    out.release()
    cv2.destroyAllWindows()

opt =pyautogui.confirm(text= 'Chose an option', title='Camcorder', buttons=['Record', 'Capture', 'Exit'])
if opt == 'START':
    print("Starting the app")
    recog()

if opt == 'Exit':
    print("Quit the app")

如有错误请指正。

【问题讨论】:

  • 请阅读this guide 以获取如何改进您的问题的提示。
  • 标记为python

标签: python opencv computer-vision artificial-intelligence pyautogui


【解决方案1】:

函数 recog 没有得到评估,因为下面的 if 语句

if opt == 'START':

没有名为START 的按钮。您的confirm() 函数显示一个带有RecordCaptureExit 按钮的消息框,但没有START 按钮。所以,confirm()函数的返回值不可能等于START

【讨论】:

  • 感谢 Anubhav,但这是我复制未编辑文件时的错误。改了还是不行。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-29
  • 2021-01-28
  • 1970-01-01
  • 1970-01-01
  • 2017-11-30
  • 1970-01-01
相关资源
最近更新 更多