0

Consider:

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 the 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: macOS v10.14 (Mojave)).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    https://stackoverflow.com/questions/48290403/process-finished-with-exit-code-134-interrupted-by-signal-6-sigabrt – Eskapp Jul 27 '19 at 20:48
  • @Eskapp above issue is happening because of apple refuse to give permission to access the webcam is there any other solutions to this issue? – Bathiya Seneviratne Jul 28 '19 at 14:09
  • [The underlying reason may be an assert](https://stackoverflow.com/questions/23098695/strange-return-value-134-to-call-gawk-in-bash-script/23098735#23098735). 134 is most certainly a very common exit code for [asserts](https://en.wikipedia.org/wiki/Assertion_(software_development)#Assertions_for_run-time_checking). – Peter Mortensen Jan 18 '22 at 23:32

4 Answers4

4
  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.
user229044
  • 232,980
  • 40
  • 330
  • 338
2

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

Run PyCharm or IntelliJ IDEA (whatever JetBrains application) 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
cansik
  • 1,924
  • 4
  • 19
  • 39
1

By running the Python script in Visual Studio Code, it will execute the program without any warnings or bugs.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

Open file /Applications/PyCharm.app/Contents/info.plist in any text editor.

Add these two lines before the dict and plist tags:

        <key>Privacy - Camera Usage</key>
        <string>An application in PyCharm wants to use the camera.</string>
    </dict>
</plist>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jakir Hossain
  • 800
  • 6
  • 12