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

Continuous animations #17

Open
thoppe opened this issue Nov 16, 2018 · 6 comments
Open

Continuous animations #17

thoppe opened this issue Nov 16, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@thoppe
Copy link
Owner

thoppe commented Nov 16, 2018

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

@thoppe thoppe added the enhancement New feature or request label Nov 16, 2018
@apsistech
Copy link

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.

@thoppe
Copy link
Owner Author

thoppe commented Nov 17, 2018

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.

@thoppe
Copy link
Owner Author

thoppe commented Nov 17, 2018

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.

screenshot from 2018-11-17 15-02-42

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.

@thoppe
Copy link
Owner Author

thoppe commented Nov 17, 2018

@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)

@thoppe
Copy link
Owner Author

thoppe commented Nov 17, 2018

Also, without the full pixel write, I get about 50fps just writing to text and blank rectangle to the screen with 800x400 resolution.

@apsistech
Copy link

Oh cool, that's great to hear, I'll git clone your repo and try messing around myself soon!

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

No branches or pull requests

2 participants