OpenCV Python脚本Mac会“中止" [英] OpenCV Python Scripts Mac "aborts"

查看:72
本文介绍了OpenCV Python脚本Mac会“中止"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So I'm just trying to run the basic OpenCV program

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

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

But for some reason when I try to run it (with python 2 or 3) I get this weird abort statement

    [1]    74309 abort      python3 index.py

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

(I'm guessing the 5 digit number is the PID) However, it does work if I pass in a path to an already existing video in the VideoCapture function. I am a beginner in all of this so I'm not really sure what the problem is

谢谢:)

推荐答案

我找到了解决方案! 我尝试使用mac随附的默认终端运行脚本,该脚本可以正常工作:)因此,似乎我使用的第三方终端(iTerm)出现了一些奇怪的问题

I found the solution! I tried running the script using the default terminal that comes with mac and it worked :) So it seems there was some weird issue with the third party terminal (iTerm) I was using

这篇关于OpenCV Python脚本Mac会“中止"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆