Using .cs files to serve an problem.

82 views
Skip to first unread message

Mehmet Yücel Sarıtaş

unread,
Sep 8, 2021, 1:56:12 PM9/8/21
to Bonsai Users
Hi all. I need to handle a problem. For example,  I have one frame in the x folder. Code will take that frame from folder and model will process frame and will output it as csv. The key point is to do these operations with codes(C#). Not from the bonsai app. The main problem I don't really understand the codes published on Github(Because of my c# skills ). I appreciate it if anybody helps me. Thanks!

Gonçalo Lopes

unread,
Dec 29, 2021, 8:40:26 AM12/29/21
to Mehmet Yücel Sarıtaş, Bonsai Users
Hi Mehmet,

Do you really need to have your entire project in C#, or is it enough to add custom scripts into Bonsai? I would suggest experimenting with C# first inside Bonsai itself, so you can easily setup your project by using the C# scripting nodes: CSharpSource for example, you can use to replace for example FileCapture with your random source of frames, and have something like the following:

image.png

Then inside the script you can specify a totally different way of feeding frames to DLC and it should still work fine.

If you really need to, it is also possible to use Bonsai.DeepLabCut directly from a C# project by adding it as a dependency. Make sure you use .NET 4.7.2 and add something like this in your .csproj file:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Bonsai.DeepLabCut" Version="0.2.0" />
  </ItemGroup>

</Project>

This should download the Bonsai.DeepLabCut package straight into your project and you can then call the functions by setting up a reactive pipeline directly in C#. This would be exactly the same as scripting in C# inside Bonsai, which is why I also suggested starting there.

Make sure to also install the system dependencies, exactly as you do for getting DLC to work with Bonsai: https://github.com/bonsai-rx/deeplabcut#how-to-install

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/5dcbd7c6-450a-439e-8a42-6ecaadc2c763n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages