当前位置:   article > 正文

python读取视频流缓存加载_关于opencv python 获取视频流的一帧

python ret, frame = cap.read()并发流帧处理

各位大佬:

1.我是在centos6.9系统编译的python3.6.3版本,地址是/usr/local/python3,然后使用bin文件下的pip3安装了opencv_python库

3b760cfe85b4a70149f8b4a511b86923.png

2.在/usr/local/python3/lib/python3.6/site-packages/下生成opencv_python-3.3.0.10.dist-info和cv2目录

5954b9f2e7a678f1f184e2d55fb9f011.png

3.然后使用命令运行/usr/local目录下的snapshot.py脚本文件,即:/usr/local/python3/bin/python3 snapshot.py 提示错误:

OpenCV Error: Unknown error code -10 (Raw image encoder error: Empty JPEG image (DNL not supported)) in throwOnEror, file /io/opencv/modules/imgcodecs/src/grfmt_base.cpp, line 140

Traceback (most recent call last):

File "snapshot.py", line 21, in

main()

File "snapshot.py", line 11, in main

ret,arr = cv2.imencode('.jpg', frame)

cv2.error: /io/opencv/modules/imgcodecs/src/grfmt_base.cpp:140: error: (-10) Raw image encoder error: Empty JPEG image (DNL not supported) in function throwOnEror

48fa4c4a2c18bd167229b806b7629983.png

请教大佬是什么原因,在windows下是可以按照程序截取到帧图片

import cv2

import numpy as np

from sys import argv

import base64

def main():

cap = cv2.VideoCapture("rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov")

for i in range(1, 500):

ret,frame = cap.read()

ret,arr = cv2.imencode('.jpg', frame)

a = arr.tostring()

fp = open('test'+str(i)+'.jpg', 'wb')

fp.write(a)

fp.close()

fps = cap.get(5)

print(fps)

cap.release()

if __name__ == '__main__':

main()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/280179
推荐阅读
相关标签
  

闽ICP备14008679号