Open thoppe opened 6 years ago
What kind of frame rates do you think CV2 could support? For example do you think it could plot 1024 points on a graph at 10 fps?
It'd be kind of cool if the Artist generator could fail safely. Say there's no data available when it polls for input, there could be a timeout and if the timeout hits then it could assume a default image.
That leads to another question I had, does the Artist generator grab data or does it wait for data? Yet a third possibility is that the Artist generator is a class object, and if you want to use it you create a derived child class that somehow has a mechanism to get data itself.
I think if you do it properly, you could easily get 10fps. CV2 can plot and annotate that much coming from a live webcam. I'll mock up a simple Artist and Canvas method that shows random data and we can go from there.
Whoa, that was super easy to write! Check out the branch live_artist
and the example. It generates this little image that live displays the frame rate.
With an image of (800x400)
I get 27 fps, and twice that (1600,800)
I get 7 fps which is almost perfect scaling w.r.t. the square (or proportional to the number of pixels). This write to every pixel, so with a single line plot it could probably be much faster.
@apsistech if you want to play with this, you could come up with a more complicated Artist that computes in the background while waiting for a poll. Or you could implement the poll/wait/blank method that gets beyond a simple block (that's what's done now). Honestly, this is all the live animation is now:
class LiveAnimation(Animation):
def show(self, delay=1):
while True:
img = self.render(0)
self.has_rendered[0] = False
img.show(delay=delay)
Also, without the full pixel write, I get about 50fps just writing to text and blank rectangle to the screen with 800x400
resolution.
Oh cool, that's great to hear, I'll git clone your repo and try messing around myself soon!
Multiple people expressed interest in creating animations that do not have a fixed time schedule, but rather run with a generator. I envision an Artist generator that takes input continuously and keeps rendering until broken by the user. cc @ehaengel