gpt4 book ai didi

python - Pycharm-运行打开的CV代码直接进入 “Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)”

转载 作者:行者123 更新时间:2023-12-02 16:15:51 26 4
gpt4 key购买 nike

我正在尝试运行open-cv代码以使用python脚本访问我的网络摄像头。但是,当我尝试运行它时,每次尝试运行它时,都会收到“进程以退出代码139完成(信号11:SIGSEGV中断)”。我的代码没有错误,我还查看了其他文章来添加环境变量:PYTHONUNBUFFERED=1;PYDEVD_USE_FRAME_EVAL=NO;PYTHONMALLOC=debug我的代码是:

import cv2

# define a video capture object
vid = cv2.VideoCapture(0)
while (True):
# Capture the video frame
# by frame
ret, frame = vid.read()

# display the resulting frame
cv2.imshow('frame', frame)

# the 'q button is set as the
# quitting button
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# after the loop realse the cap object
vid.release()
# destroy all windows
cv2.destroyAllWindows()

最佳答案

最后两行必须在while循环之外:

import cv2

# define a video capture object
vid = cv2.VideoCapture(0)
while (True):
# Capture the video frame
# by frame
ret, frame = vid.read()

# display the resulting frame
cv2.imshow('frame', frame)

# the 'q button is set as the
# quitting button
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# after the loop realse the cap object
vid.release()
# destroy all windows
cv2.destroyAllWindows()

关于python - Pycharm-运行打开的CV代码直接进入 “Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63419692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com