我有一个超过1小时长的视频,并且有110000+帧。我正在使用下面的代码来分析视频中的面部表情。然而,整个过程太长,并且估计完成这项任务的时间是超过34小时!我的问题是:是否有任何方法可以加快这个过程(例如跳过帧)?每3帧分析一次?)
以下是代码:
from fer import Video
from fer import FER
import os
import sys
import pandas as pd
location_videofile = "/Users/M/Desktop/videoplayback.mp4"
input_video = Video(location_videofile)
processing_data = input_video.analyze(face_detector, display=False)发布于 2022-02-15 16:15:55
没有在fer的文档中显式地看到这一点,但是如果您查看Video对象的源代码,analyze会接受一堆关键字参数。
有关的双边投资条约是:
def analyze(
self,
detector, # fer.FER instance
display: bool = False,
output: str = "csv",
frequency: Optional[int] = None,
max_results: int = None,
save_fps: Optional[int] = None,
video_id: Optional[str] = None,
save_frames: bool = True,
save_video: bool = True,
annotate_frames: bool = True,
zip_images: bool = True,
detection_box: Optional[dict] = None
) -> list:
"""Recognize facial expressions in video using `detector`.
Args:
detector (fer.FER): facial expression recognizer
display (bool): show images with cv2.imshow
output (str): csv or pandas
frequency (int): inference on every nth frame (higher number is faster)
max_results (int): number of frames to run inference before stopping
save_fps (bool): inference frequency = video fps // save_fps
video_id (str): filename for saving
save_frames (bool): saves frames to directory
save_videos (bool): saves output video
annotate_frames (bool): add emotion labels
zip_images (bool): compress output
detection_box (dict): dict with bounding box for subimage (xmin, xmax, ymin, ymax) 因此,您可以设置“使用frequency”来减少采样频率,例如,每3帧采样一次:
processing_data = input_video.analyze(face_detector, display=False, frequency=3)https://stackoverflow.com/questions/71129365
复制相似问题