Search code examples
pythonimageqtanimationantialiasing

Preventing blurring of fast-moving objects on the screen


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.


Solution

  • 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.