Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 视频猫耳过滤器太晃动_Python 3.x_Image Processing_Video Processing_Opencv4 - Fatal编程技术网

Python 3.x 视频猫耳过滤器太晃动

Python 3.x 视频猫耳过滤器太晃动,python-3.x,image-processing,video-processing,opencv4,Python 3.x,Image Processing,Video Processing,Opencv4,我正在制作一个视频过滤器,它可以像Snapchat镜头一样为你添加猫耳。我正在使用opencv4和Dlib。Dlib负责检测人脸。问题在于,由于检测坐标每帧都会发生一点变化,因此滤波器的摆动过大 我试着每2-3帧改变一次耳朵的位置,但变化不大 while True: _, frame = cap.read() ear_mask.fill(0) gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces =

我正在制作一个视频过滤器,它可以像Snapchat镜头一样为你添加猫耳。我正在使用opencv4和Dlib。Dlib负责检测人脸。问题在于,由于检测坐标每帧都会发生一点变化,因此滤波器的摆动过大

我试着每2-3帧改变一次耳朵的位置,但变化不大

while True:
    _, frame = cap.read()
    ear_mask.fill(0)
    gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = detector(frame)

    for face in faces:
        ear_width, ear_height, top_left, degree = generateNewEar(frame)
        frame = generateImage(frame, ear_width,
                              ear_height, top_left, degree)
    cv2.imshow("Frame", frame)
人们通常如何处理这个问题

“问题是,由于检测的原因,坐标每帧都会有一点变化,因此过滤器太过晃动。”

我不使用Python或OpenCV,因此无法向您展示示例代码。一些建议你可以试试

(1)摄像头噪音可能会影响检测。尝试对输入进行软模糊以平滑像素。测试不同的模糊级别

(2)尝试每秒更新一次耳朵位置,然后微调到每秒X次

(3)比较当前帧和前一帧的耳朵位置。如果距离太小(1或2像素),则忽略并使用旧位置