Create Property Source Question

137 views
Skip to first unread message

tomwheat...@gmail.com

unread,
Dec 12, 2018, 12:20:53 PM12/12/18
to Bonsai Users
Hi there,

Say I want a program to take images from a camera, crop them, and then output them as a video, I think I can do this with CameraCapture->Crop->VideoWriter.

If I want to also save the coordinates of the cropped region (the ROI) in a CSV file, how can I do this?

I tried externalizing the ROI value, however I can't find any way of producing the Open.CV.Net.Rect format needed for the input.

I then tried 'Create a property source'. I can now feed this PropertySource node into a CsvWriter, but the values don't change when I update the ROI.

Is there a way to link the ROI value of the Crop node to the value of the created PropertySource, so that when the former gets updated, the latter does too?


Best wishes,
Tom

tomwheat...@gmail.com

unread,
Dec 12, 2018, 12:29:13 PM12/12/18
to Bonsai Users
Sorry forgot to attach the workflow
exampleProgramForGroup.bonsai
exampleProgramForGroup.bonsai.layout

Gonçalo Lopes

unread,
Dec 12, 2018, 7:25:05 PM12/12/18
to tomwheat...@gmail.com, Bonsai Users
Hi Tom,

With the new Bonsai 2.4 (now in preview), as you have already realized, you can do this easier using the new PropertySource nodes. However, the way they work is a bit different from externalized properties.

Specifically, a property source is not directly connected to a certain node. They are just a way to generate values, like a normal source, but you can easily connect them to an externalized property. For example, in your case:

image.png

This way, when you change the value of the RegionOfInterest source, you will both write the value on the file and on the node property. One potential problem is that you lose the nice visual editor of the ROI, since you don't have access to the original image. To get it back, you can connect the image source to the property source, like this:

image.png

This way, you can edit the visual node the same as before, but you will have the problem that you will save the ROI value for every frame. You can decide to save it only when the value changes, by adding DistinctUntilChanged:

image.png

If you only wanted to save it in the beginning, you could add Take(1), and so on.

Basically the idea is that you should treat these property sources as just simple ways of constructing and manipulating values, and doing some processing on them before you send them to the actual node properties.

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...@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/ac029bce-d8a7-401a-853f-c9c3e4832951%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages