【发布时间】:2018-01-20 03:50:43
【问题描述】:
我正在尝试在 python 中使用 opencv 加载视频文件。程序崩溃并返回:
$ python bg_reduction.py 分段错误(核心转储)
在浏览论坛数小时后,我开始意识到问题可能出在我构建的 opencv 上。我是一名新手程序员和 linux 用户,所以无论如何我发现的大部分内容都超出了我的想象。
这是我的程序的要点 - 从网络摄像头流式传输视频时有效,从文件加载时失败。
cap = cv2.VideoCapture('SuccessPrint.mp4')
fgbg = cv2.createBackgroundSubtractorMOG2()
while (cap.isOpened()):
try:
ret, frame = cap.read()
except cv2.error:
cap.release()
cv2.destroyAllWindows()
k = cv2.waitKey(30) & 0xFF
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
这里是返回的编解码器信息:
$ffmpeg -i SuccessPrint.mp4
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 557 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
最后是来自核心的信息:
$gdb bg_reduction.py core
返回(我已经删除了路径):
/bg_reduction2.py": not in executable format: File format not recognized
[New LWP 12398]
[New LWP 12401]
[New LWP 12399]
[New LWP 12400]
Core was generated by `python bg_reduction2.py'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fe3c7364fd1 in ?? ()
[Current thread is 1 (LWP 12398)]
(gdb)
任何建议都会令人难以置信。提前致谢!
【问题讨论】:
标签: python opencv ubuntu video crash