小编DJL*_*d97的帖子

Mac“中止” OpenCV Python脚本

所以我只是试图运行基本的OpenCV程序

    import numpy as np
    import cv2

    cap = cv2.VideoCapture(0)

    while(True):
        # Capture frame-by-frame
        ret, frame = cap.read()

        # Our operations on the frame come here
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)

        # Display the resulting frame
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # When everything done, release the capture
    cap.release()
    cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

但是由于某种原因,当我尝试运行它(使用python 2或3)时,我得到了这个奇怪的中止语句

    [1]    74309 abort      python3 index.py
Run Code Online (Sandbox Code Playgroud)

(我猜5位数是PID),但是,如果我在VideoCapture函数中传递到现有视频的路径,则它确实可以工作。我是所有这方面的初学者,所以我不确定是什么问题

谢谢 :)

python opencv macos-mojave

3
推荐指数
1
解决办法
2009
查看次数

标签 统计

macos-mojave ×1

opencv ×1

python ×1