[PYTHON] What to do if abort is displayed when inputting camera video in OpenCV

The other day I tried to input a video using opencv and display it. The environment was done on macOS Catalina vs Code, but at that time

zsh: abort      python load_video.py

Was displayed, and a phenomenon occurred in which processing stopped. From the point of view of the conclusion, I found that it is necessary to get permission for the camera by hitting ** directly on the terminal instead of hitting the command on VScode. Reference

I'm currently looking for a way to do it well on VScode. The detailed code is shown below for reference. * * * mp4 file and camera referring to openCV tutorial page The code for displaying the video is shown below.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(cap.isOpened()):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

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

cap.release()
cv2.destroyAllWindows()

You can also display videos by setting the argument of cv2.VideoCapture () to any video directory.

Recommended Posts

What to do if abort is displayed when inputting camera video in OpenCV
What to do when a warning message is displayed in pip list
What to do when Japanese is not displayed on matplotlib
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do when the value type is ambiguous in Python?
What to do if there is a decimal in python json .dumps
What to do when the result downloaded via scrapy is in English
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
What to do if pipreqs results in UnicodeDecodeError
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
What to do if (base) is displayed at the beginning of the Mac terminal
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
curl: (60) What to do when Issuer certificate is invalid.
What to do if a UnicodeDecodeError occurs in pip
What to do if pyenv is not enabled (zsh)
What to do when is not in the sudoers file.This incident will be reported.
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do if pip gives a DistributionError in Homebrew
What to do when PyCharm font is strange or garbled
What to do if you get "coverage unknown" in Coveralls
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do if package installation fails when deploying to heroku
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do if you can't log in as root
What to do when there is no response due to Proxy setting in Python web scraping
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if ʻObject arrays cannot be loaded when allow_pickle = False` occurs in numpy.load ()
What to do when Ubuntu crashes
What to do if yum breaks
What to do if you get a minus zero in Python
What to do when a video cannot be read by cv2.VideoCapture
What to do if the inode is exhausted on EC2 Linux
What to do if you can't use the trash in Lubuntu 18.04.
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
What to do if you get a must override `get_config` error when trying to model.save in Keras
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
What to do if an error message "There was a problem displaying this web page" is displayed in Chrome's Web Driver (Selenium)
What to do if you can't find PDO in Laravel or CakePHP
What to do if the Pipenv environment is corrupted by updating Homebrew
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
What to do if you can't use scikit grid search in Python
[Python] What to do when PEP8 is violated in the process of importing from the directory added to sys.path
What to do if you get angry in TensorFlow v2 without attribute'app'
What to do when "Something is already running at port 8000" is displayed when the develop command of Gatsby is executed.
What to do if No Python documentation found for ... appears in pydoc
[Python] What to do when an error related to SSL authentication is returned
What to do if an error occurs when importing numpy with VScode
What to do if PyInstaller3.5 gives an error in Python3.8 (TypeError: an integer is required (got type bytes))
What to do if you get an error when trying to load mnist
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
What to do if fprintd requires a password when registering your fingerprint
What to do if a symbolic link error occurs in import cv while trying to install OpenCV in Python
What to do if you get an error when installing Dlib (Ubuntu)
[OSX] [pyenv] What to do when an SSL error occurs in pip