Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render_model.py帧数据缓存到内存后人脸会糊 #88

Closed
lddcdut opened this issue Jan 1, 2025 · 3 comments
Closed

render_model.py帧数据缓存到内存后人脸会糊 #88

lddcdut opened this issue Jan 1, 2025 · 3 comments

Comments

@lddcdut
Copy link

lddcdut commented Jan 1, 2025

在reset_charactor方法中我将视频所有帧全部读出来了,然后存到frames对象中

获取视频所有帧

    self.__cap_input.set(cv2.CAP_PROP_POS_FRAMES, 0)
    while True:
        ret, frame = self.__cap_input.read()
        if ret:
            self.frames.append(frame)
        else:
            break

在interface方法中直接通过索引获取帧数据,避免每次去读取,但是运行一段时间后脸部会糊,打印了下日志,视频第一轮循环完成后,第二轮ret, frame = self.__cap_input.read()读出来的frame和frames[0]的值就不一致了。这是什么原因啊。

    def interface(self, mouth_frame):
        if self.frame_index % self.vid_frame_count == 0:
            self.__cap_input.set(cv2.CAP_PROP_POS_FRAMES, 0)
            self.frame_list_index = 0
        ret, frame_read = self.__cap_input.read()

        epoch = self.frame_index // len(self.__mat_list)
        if epoch % 2 == 0:
            new_index = self.frame_index % len(self.__mat_list)
        else:
            new_index = -1 - self.frame_index % len(self.__mat_list)
        frame = self.frames[self.frame_list_index]

        if not np.array_equal(frame_read, frame):
            # 第二轮开始,输出就为False了
            print(np.array_equal(frame_read, frame))
@kleinlee
Copy link
Owner

kleinlee commented Jan 2, 2025 via email

@lddcdut
Copy link
Author

lddcdut commented Jan 2, 2025

通过read()这种方式不会出问题,但只要把frame放到内存,就算强制指定从起始帧开始,一段时间后都会糊脸。百思不得其解。。。

@lddcdut lddcdut closed this as completed Jan 3, 2025
@lddcdut
Copy link
Author

lddcdut commented Jan 3, 2025

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants