当前位置:首页 > 操作系统 > MacOs

OpenCV Python脚本Mac“中止”

所以我只想尝试运行基本的OpenCV程序

<code>    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()
</code>

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

<code>    [1]    74309 abort      python3 index.py
</code>

(我猜这个5位数是PID)但是,如果我传入VideoCapture函数中已有视频的路径,它确实有效.我是所有这些的初学者,所以我不确定问题是什么

谢谢 :)

解决方法:

我找到了解决方案!
我尝试使用mac附带的默认终端来运行脚本并且它工作了:)所以看起来我使用的第三方终端(iTerm)有一些奇怪的问题


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐