防止屏幕上快速移动的物体模糊
我正在使用 Qt 框架用 Python 编写一个桌面应用程序,它涉及以相当快的速度在屏幕上扫动图像。我以一种非常简单的方式做到这一点:
- 对于每个项目,创建一个带有关联图像的 Qlabel 对象
- 使用 startTimer 为每个 Qlabel 启动一个计时器,
- timerEvent 会导致一个类似于以下内容的调用: self.move(self.x() + SPEED , self.y()) 其中 SPEED 是一些少量的像素。
这是可行的,但即使在中等速度(例如每秒 500 像素)下,图像(在本例中我使用的是扑克牌)看起来也非常痛苦。有很多水平模糊。我认为我可以通过改变计时器关闭的频率来缓解这种情况(以便图像移动的次数减少,或者移动的次数减少),但这并没有真正的帮助。
谁能解释一下是什么原因造成的,以及我该如何解决它?我读过关于运动模糊的维基百科文章,但没有多大帮助。当有人问我是什么原因造成的时,我说了一些关于显示器响应时间的事情,但我并不相信这一点,当他们问我“那为什么当你玩电子游戏时不会发生这种情况呢?”我无法给出答案。
编辑:根据要求,这是一个玩具程序的粘贴,其中展示了问题。将图像文件的路径作为命令行参数。
I'm writing a desktop application in Python using the Qt framework, and it involves whisking images across the screen at a fairly quick pace. I do this in a pretty straightforward way:
- For each item, create a Qlabel object with the associated image
- Start a timer for each Qlabel using startTimer
- timerEvent leads to a call that looks something like: self.move(self.x() + SPEED, self.y()) where SPEED is some small number of pixels.
This works, but even at modest speeds (say 500 pixels per second) the images (in this case I'm using playing cards) are really painful to look at. There's a lot of horizontal blurring. I thought that I might be able to mitigate this by changing the frequency with which the timer goes off (so that the images get moved a larger amount fewer times, or a smaller amount more times), but this doesn't really help.
Can anyone explain what's causing this, and how I might fix it? I've read the Wikipedia article on Motion Blur, but it didn't help much. When someone asked me what caused it, I said something about monitor response times, but I wasn't convinced of it, and when they asked me "So how come that doesn't happen when you play a video game?" I couldn't give an answer.
Edit: As requested, here's a paste of a toy program that exhibits the problem. Takes a path to an image file as a command line argument.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它看起来像是由于缺乏双缓冲而导致的闪烁。我不确定如何在您的特定工具包中解决它,但这应该为您指明正确的方向。
It looks like flicker from a lack of double buffering. I'm not sure exactly how to solve it in your particular toolkit, but that should point you in the right direction.