python使用模块cv2过程中,报错:A fatal error has been detected by the Java Runtime Environment:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fe9ef5e3696, pid=25302, tid=0x00007fea12c4c740
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [cv2.cpython-36m-x86_64-linux-gnu.so+0xcd0696]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
错误发生点定位在这两行:
Problematic frame:
C [cv2.cpython-36m-x86_64-linux-gnu.so+0xcd0696]
1、说明是在使用cv2这个模块过程中发生的错误。
通过谷歌搜索这个错误,有个帖子写道,在使用cv2模块的cv2.VideoCapture()时候报错:SIGSEGV (0xb) at pc=0x00007fffbe7d605d, pid=922, tid=0x0000000000000307。
里面提到是cv2调用视频捕捉方法时报错。
https://stackoverflow.com/questions/43664709/opencv-java-cant-open-the-webcam
2、说明可能是cv2.VideoCapture()这个方法过程中发生错误。
在代码中屏蔽cv2.VideoCapture()方法
cap = cv2.VideoCapture(content)
num = int(cap.get(6))
cap.set(cv2.CAP_PROP_POS_FRAMES, num) # 设置要获取的帧号
a, img = cap.read() # read方法返回一个布尔值和一个视频帧。若帧读取成功,则返回True
3、运行后,不再报错。证明问题确实在:cv2.VideoCapture()。至于为何调用cv2.VideoCapture()会发生这个error,且待后续。