Process finished with exit code 134 (interrupted by signal 6: SIGABRT) in python OpenCV

让人想犯罪 __ 提交于 2021-01-29 11:22:49

问题


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

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

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

I'm using Python and OpenCV in Pycharm IDE. When I try to open the webcam using OpenCV, it gives the following error:

"Process finished with exit code 134 (interrupted by signal 6: SIGABRT)"

Is this happening because I'm running out of memory? What are the solutions for this?

I'm using PyCharm on MacBook Pro (OS: Mojave)

Thanks!


回答1:


  1. Open /Applications/PyCharm.app/Contents/info.plist,
  2. Insert a new line:

    • Key: Privacy - Camera Usage
    • Type: String
    • Value: An application in PyCharm wants to use the camera.
  3. Save it.

  4. Reopen PyCharm.
  5. Run your code.



回答2:


I have opened an issue at Jetbrains because of this. But here is a workaround:

Run PyCharm / IntelliJ (whatever Jetbrains App) from an application which already has been approved for camera access. For example I use the Hyper Terminal to run the IDE and everything works.




回答3:


By running the python script in vs code (visual studio code) will execute the program without any warning or bugs.




回答4:


Open /Applications/PyCharm.app/Contents/info.plist in any text editor. Add these two line before dict & plist tag:

<key>Privacy - Camera Usage</key>
<string>An application in PyCharm wants to use the camera.</string>
</dict>
</plist>


来源:https://stackoverflow.com/questions/57230407/process-finished-with-exit-code-134-interrupted-by-signal-6-sigabrt-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!