简体   繁体   English

在 OpenCV 上输入的更高分辨率视频文件的 fps 低

[英]Low fps on higher resolution video file input on OpenCV

I am trying to blur the faces using dlib face detector and open cv.我正在尝试使用 dlib 人脸检测器和打开 cv 来模糊人脸。 The code works fine when giving input from a webcam but it gives low fps when I give 720p or 1080p video file as input.当从网络摄像头提供输入时,代码工作正常,但当我提供 720p 或 1080p 视频文件作为输入时,它会提供低 fps。 My end goal is to blur the faces when the video file with any resolution is given to the code.我的最终目标是在将具有任何分辨率的视频文件提供给代码时模糊人脸。

I have tried reducing the frame size using "cap.set()".But it isn't working.我曾尝试使用“cap.set()”减小帧大小。但它不起作用。 Any help will be appreciated.任何帮助将不胜感激。 output frame输出帧

Would it be possible to reduce the resolution of higher quality video if your code already works with lower resolution video?如果您的代码已经适用于较低分辨率的视频,是否可以降低更高质量视频的分辨率? If so, then maybe you could try something like the following code from opencv.org :如果是这样,那么也许您可以尝试使用opencv.org 中的以下代码:

import cv2
vidcap = cv2.VideoCapture('myvid2.mp4')
success,image = vidcap.read()
count = 0;
print "I am in success"
while success:
    success,image = vidcap.read()
    resized = cv2.resize(image, fx=0.5, fy=0.5, interpolation = cv2.INTER_LINEAR) 
    cv2.imwrite("%03d.jpg" % count, resize)     
    if cv2.waitKey(10) == 27:                     
        break
    count += 1

That should halve the resolution of the video.这应该使视频的分辨率减半。 And you can reduce the resolution further by changing the 0.5 parameters in cv2.resize() to something even smaller.您可以通过将 cv2.resize() 中的 0.5 参数更改为更小的参数来进一步降低分辨率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM