Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\pyqt_baiduyun\baiduyun1.py", line 111, in run
cut_img=get_faceimg(frame,i,face_list) #注册用的剪切后的人脸照片
File "c:\Users\Administrator\Desktop\pyqt_baiduyun\utils\utils.py", line 156, in get_faceimg
cut_img_str = cv2.imencode('.jpg', cutImg)[1].tostring()
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgcodecs\src\grfmt_base.cpp:145: error: (-10:Unknown error code -10) Raw image encoder error: Empty JPEG image (DNL not supported) in function 'cv::BaseImageEncoder::throwOnEror'
-----------------------分割线--------------------------------
156 行的函数如下:
#获取人脸裁剪图片
def get_faceimg(frame,i,face_list):
width,top,left,height=get_face_location(i,face_list) #获取人脸的左顶点坐标和长宽。
cutImg = frame[top:top+height,left:left+width] #[y1:y2,x1:x2]切片
cut_img_str = cv2.imencode('.jpg', cutImg)[1].tostring() # 将图片编码成流数据,放到内存缓存中,然后转化成 string 格式
cut_img = str(base64.b64encode(cut_img_str),'utf-8') # 编码成 base64
return cut_img
-----------------------分割线--------------------------------
请问各位老哥这个错误是什么原因呢? 我在 pyqt 里多线程同时调用 opencv 的 videocapture()读取视频的每一帧,对每一帧进行处理。结果经常随机性地报这个错误,google 了没找到合适的解释,下面这篇感觉比较符合:
https://www.cnblogs.com/hul201610101100/p/10233211.html
但是还是不知道如何修改,希望各位老哥给支个招。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.