Video Aquisition question

399 views
Skip to first unread message

Jocelyn Santiago

unread,
Feb 22, 2022, 10:13:19 AM2/22/22
to Bonsai Users
Hey everyone

I'm just getting started with Bonsai and programming as a whole. I'm trying to follow all of what I've seen in the forums and online documents, but I seem to have stumbled a bit. With the video aquisition tutorial/worksheet, I'm not able to find how to do the 
  • Configure the FileName property of the VideoWriter operator with a file name ending in .avi.
Whenever I try to run anything it says "a valid file path must be specified and I've been tinkering and putting different things but I don't know how to make it work. The one time it worked, it was just with Camera Capture and it showed my laptop webcam, but I was unable to find how to use the external webcam. 

Thanks in advance

brunocruz

unread,
Feb 28, 2022, 2:11:30 PM2/28/22
to Bonsai Users
Hey,

Can you include the workflow you are using?

Thanks,
Bruno

José Teixeira

unread,
Mar 9, 2022, 1:20:16 PM3/9/22
to Bonsai Users
Hi all,

I believe to be experiencing an identical issue.

As you can see (1st image below), the CsvWriter is displaying the same error as Jocelyn ("a valid file path must be specified"). The path is specified in the SavePath node (SubscribeSubject; created in an upper level of the workflow as a ReplaySubject) and only the file name and extension are appended to the string coming from SavePath (Add nodes). Notice that I use this method for defining the FileName in both the VideoWriter and CsvWriter nodes, but it only throws an error on the second case.

If I define the FileName manually on the property editor of the CsvWriter node (using the same path that comes out of the Add node before it - 2nd image below) the workflow runs without errors.

I'm attaching the workflow (not complete, only the part shown in the image, which constitutes a GroupWorkflow inside my actual workflow).

Thanks in advance!

cameraerror.png

cameraerror2.png
CameraError.bonsai

brunocruz

unread,
Mar 9, 2022, 2:24:04 PM3/9/22
to Bonsai Users
Having a SubscribeSubject for each of the properties should fix it I think
Something like this:

Capture.PNG
 cheers
B

José Teixeira

unread,
Mar 10, 2022, 1:21:09 PM3/10/22
to Bonsai Users
Hi Bruno,

Your suggestion solved this issue, and no errors are raised now.

Thank you!

Jaeeon Lee

unread,
Mar 16, 2022, 12:56:35 PM3/16/22
to Bonsai Users
This is super useful. I don't seem to be able to find the savepath node. Is is under different name? or do I need to install a package?

José Teixeira

unread,
Mar 16, 2022, 2:02:48 PM3/16/22
to Bonsai Users
Hi Jaeeon,

The SavePath node is a Subject, meaning it's a user-defined source of data, identical to declaring a variable in a typical programming language. That's why you can't find it.

Notice how in the image below I first define a CustomNode which 'contains' whatever data is connected to it (in this case a string, but could be something else), and then it shows up under 'Subject' on the Toolbox (left side of the image) so I can use it as a source for other branches of the workflow.

If you type 'Subject' on the Toolbox you'll see the different kinds of Subjects you can define (depending on what behavior you want them to have). On this case I'm using ReplaySubject.

Hope this helps clearing your doubts.

custom.png

Jaeeon Lee

unread,
Mar 17, 2022, 8:50:44 PM3/17/22
to Bonsai Users
Cool, I think I know how it works now.
Is there a node that, when double clicked, allows you to select a path? The videoWriter node, when double clicked, pops a window for saving file location, and I was wondering if one could create something similar, rather than having to type the actual path.

José Teixeira

unread,
Mar 25, 2022, 10:00:21 AM3/25/22
to Bonsai Users
Hi Jaeeon,

I'm not sure if I understand your question, but maybe take a look at this thread, it seems this could be what you're looking for.

Cheers.

brunocruz

unread,
Mar 25, 2022, 3:26:56 PM3/25/22
to Bonsai Users
If you want to use the double-click feature, you can use a custom C# source node:
(there are a few short descriptions on how to use these custom nodes, e.g. https://groups.google.com/g/bonsai-users/c/ve7dcdK-4gE/m/v7SMEcZVBQAJ)


------
using Bonsai;
using System;
using System.ComponentModel;
using System.Reactive.Linq;

namespace Bonsai.IO
{
    [DefaultProperty("FileName")]
    [Description("")]
    public class InteractivePath : Source<string>
    {
        [FileNameFilter("Any|*.*")]
        [Editor("Bonsai.Design.SaveFileNameEditor, Bonsai.Design", DesignTypes.UITypeEditor)]
        [Description("Path name.")]
        public string FileName { get; set; }

        public override IObservable<string> Generate()
        {
            return Observable.Return(FileName);
        }
    }
}

----

Hope it helps!
Reply all
Reply to author
Forward
0 new messages