Dynamic frame counter

372 views
Skip to first unread message

jarto...@gmail.com

unread,
Oct 11, 2017, 12:01:28 PM10/11/17
to Bonsai Users
Hello,

I would like to count the frames in a video, but I want the index to reset to zero every time it recieves a different boolean value (eg. it counts the frames until it detects roi activity, it resets, and when the roi gives false, it restarts again). Is there any way to do this? Thanks in advance :)

-Felix Jarto

Gonçalo Lopes

unread,
Oct 11, 2017, 7:30:26 PM10/11/17
to jarto...@gmail.com, Bonsai Users
Hi Felix,

This is a good and didatic question! Yes, it is possible. You can use TriggeredWindow to split your continuous sequence of frames into chunks beginning and ending on the ROI activity changes (or any other event really). You can then use Index to count the frames inside each sequence (using a SelectMany node group).

I've put together a simple example where the reset event is a key press, but you can replace it with any other event you want:


Inside SelectMany:


If you visualize the output index you should notice it resets every time you hit a key.

Hope this helps.


--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/8185a727-bb19-46aa-818d-d99daf249923%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ResettableIndex.bonsai

jarto...@gmail.com

unread,
Oct 13, 2017, 5:59:34 AM10/13/17
to Bonsai Users
Thank you very much Goncalo, I replaced the KeyDown node with a DistinctUntilChanged and it works perfectly. On a related note, I'm trying to implement a real time velocity calculator. I know about the Skip-Zip method, but that only works with pre-recorded footage. Is there a way to delay the footage data by one frame instead of skipping it? I've attached my workflow below, it runs with a pre-recorded video file for the time being. It tracks the movement of a mouse and checks whether it stays completely still for a specified ammount of time (measured in frames).

-Felix
arduino_led_v2.5test.bonsai
Reply all
Reply to author
Forward
0 new messages