ximea camera

851 views
Skip to first unread message

Marie-Sophie van der Goes

unread,
Aug 24, 2020, 1:04:55 PM8/24/20
to Bonsai Users

Hi Gonçalo and Bonsai users,

I'd like to interface Bonsai with a ximea camera (model MQ013MG-ON) and record videos with the ephys. However it seems there is no module for this type of camera (but please correct me if I'm wrong!). I'd like to use this camera because it's what I have now and it has pretty nice specs. The software to run it is ximea-cam tool. It seems to have a c++ api and I have used it in the past with the OpenCV C++ library. Here are two links for more detailed info: https://www.ximea.com/support/wiki/vision-libraries/OpenCV , https://www.ximea.com/support/documents/4 . I don't know how to make a module, I would appreciate any help or suggestion on how to move forward.

Thank you for developing this great software!

Marie



Gonçalo Lopes

unread,
Aug 27, 2020, 7:13:53 PM8/27/20
to Marie-Sophie van der Goes, Bonsai Users
Hi Marie and welcome to the forums!

The easiest way forward would probably be to use the ximea .NET API and directly interface the camera with Bonsai. Most likely they will have some C# examples that could be readily ported to a new Bonsai module, similar to the Spinnaker or uEye packages, as the logic for interfacing with these cameras with their native APIs is usually quite similar.

Let us know if you want to go this route and we might be able to help coordinate and support the integration efforts, but I don't have any Ximea cameras so cannot test at the moment.


--
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/526add22-95b0-4347-a806-d4042b0dd386n%40googlegroups.com.

Marie-Sophie van der Goes

unread,
Aug 28, 2020, 4:09:00 PM8/28/20
to Gonçalo Lopes, Bonsai Users
Thank you for your suggestion, the sample shown on the page you linked seems pretty clear. I'd definitely go that route coordinate about creating the module and integrating it.

Thanks again
Marie

Leandro Aluisio Scholz

unread,
Mar 12, 2021, 1:22:54 AM3/12/21
to Bonsai Users

Hi all,

Did any of you started working on this already? We have got a Ximea camera in the lab and I would also like to have it linked with Bonsai. I would be happy to help! I never programmed in C# but I have experience in python and I could do some C# learning anyway.

What is the structure needed for an API to communicate with XIAPI.NET. I have seen that Nick Guilbeault made one API for Teledyne Dalsa Cameras and Goncalo for Basler (Pylon), PCO, and FLIR (Spinnaker) systems.

Cheers,
Leandro

Leandro Aluisio Scholz

unread,
Apr 7, 2021, 12:18:58 AM4/7/21
to Bonsai Users
Hi all,

Getting back to this thing. I was reading through some code of the Bonsai packages for other cameras, and based on the little knowledge I could acquire, it seems the way xiAPI.NET (https://www.ximea.com/support/wiki/apis/xiAPINET , https://www.ximea.com/support/wiki/apis/XiAPINET_Manual) works is probably most similarly to the CLEye API (https://github.com/bonsai-rx/cleyemulticam) . So I am starting a repo to structure the Bonsai.Ximea in a similar way and will post it here again when I commit the first bits of code.

I noted that in CLEye.cs there is a bunch of functions are imported from the CLEyeMulticam.dll and camera properties defined there as well, I will to it similarly to export functions from xiApi.NETX64 (there are 64 and 32 bit versions but i will start with 64 as it is our case in the lab). Hopefulle as I go through this things get clearer, but I would appreciate any support once I send you the first pieces of code.

Cheers,
L.

You received this message because you are subscribed to a topic in the Google Groups "Bonsai Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bonsai-users/uARTr4UbdoY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/93a22c69-27ec-4705-a296-88ee367e7056n%40googlegroups.com.
xiApi.NETX64.xml

Gonçalo Lopes

unread,
May 5, 2021, 7:05:07 AM5/5/21
to Leandro Aluisio Scholz, Bonsai Users
Hi Leandro,

I don't think there is any package for Ximea cameras yet, so thanks for spearheading the effort. Indeed the best approach would be to use a repository structure similar to other existing cameras with a similar API so you can use the same code patterns.

Not sure if you already have code somewhere, but I'm happy to code review and make suggestions on how setup the deployment scripts for packages if that helps.

Eric Staykov

unread,
Jun 22, 2021, 1:48:25 AM6/22/21
to Bonsai Users
Hi Gonçalo and Bonsai users,

I created a Bonsai node that generates a sequence of images acquired from a Ximea camera for Ethan Scott's Lab at The University of Queensland. Leandro wrote the project specifications and helped test the code. 


Gonçalo, is it possible that you could take a look at the code and provide feedback? That would be much appreciated, thanks!

Best regards,
Eric Staykov

Gonçalo Lopes

unread,
Jun 26, 2021, 5:18:56 PM6/26/21
to Eric Staykov, Bonsai Users
Hi Eric and Leandro,

Great work, congrats on the effort, I'm sure it will be very useful for others too :)

I'm not really familiar with the Ximea SDK, so I have just a few questions that generally come up whenever interfacing with camera drivers and some style comments:

  1. I see you exposed several camera properties in the node. Is the Ximea SDK targeting only a specific camera, or several camera models? While it is convenient to have properties configured directly in the node, I've seen several times in SDKs that support multiple models that some properties will be available for some cameras but not others. This will then make the package and source actually tied specifically to certain models and might even crash in others (e.g. the AlliedVision package currently suffers from this). The other issue is that often firmware / software updates might change or expose new properties.

For this reason I've mostly chosen to be extremely minimalist when integrating vendor interfaces with Bonsai and expose no properties except those having to do with selecting cameras and/or certain readout specific properties such as color conversion / debayering, etc which are not set at the camera level. To support project specific camera configurations I then use the vendor specific configuration files, often in XML or similar format, which are exported from their configuration app, and try to figure out a way to load them into Bonsai. That way I guarantee that complete functionality of each camera is supported and also I don't have to recreate their configuration GUI.

  2. Does the Ximea SDK support specifying a camera serial number? While this is not yet supported in all Bonsai camera interfaces, I've started giving preference to specifying the camera using the unique serial number, if available. The reason is it will help setups be more reliable for reconnecting USB ports, changing computers (as long as cameras are the same), etc. To do this I use two properties, one for serial number, the other with an optional index, and use the following preference: serial number? > index? > index0 , so basically if there is a serial number use serial number, otherwise check if there is an index, and finally if there isn't just try to pick the first available camera.

  3. Is there any image metadata associated with Ximea SDK frames? Sometimes for industrial cameras I tend to expose this extra information using a class which has both the image and metadata. This can be useful in some cases where embedded information like GPIO inputs can be sampled simultaneously with sensor exposures.

  4. In general I like to avoid printing debug info to the console, since it quickly becomes messy when using multiple cameras or multiple sources which print messages. Might be more future-proof to use logs and identify each message with the camera index or ID. Although my main preference is simplifying the interface as mentioned above. Then you can just open a connection to the camera and throw an error if it fails.

  5. I noticed you are prefixing each property with a letter of the alphabet (A, B, C, D, etc). Is this to impose a certain order of the properties in the property grid? If that is the case, there are other ways to do it that do not require changing the property name, e.g. using a type converter.

  6. Finally a few minor style points:
    - I wouldn't use underscores as word separators in C#. To keep the code idiomatic it would be better to keep to pascal casing for all public properties
    - Constants should be pascal-cased
    - I guess for general naming style guidelines check Naming Guidelines - Framework Design Guidelines | Microsoft Docs

Hope this helps, I'll keep an eye out for repository updates.

Eric Staykov

unread,
Jun 28, 2021, 1:16:06 AM6/28/21
to Bonsai Users
Hi Gonçalo,

To answer your questions:

1. Correct, I wrote the node specifically for the Ximea CB019MG-LX-X8G3 model.
2. Yes, the API does support opening a camera by its serial number.
3. xiAPI.NET doesn't appear to have metadata for frames.
5. Yes I prefixed each property with a letter to impose that order.

Thank you for the detailed feedback! I will endeavour to make the changes that you suggested and will post here with updates.

Mingrui Zhao

unread,
Jul 22, 2021, 12:27:21 PM7/22/21
to Bonsai Users
Hi Eric,
Thanks for your working on XimeaCamera node. I am using two Ximea MQ042RG-CM cameras. When I tried your node, I received the error 'SetParam acq_timing_mode: wrong paramteter value'.
1. Could you make your node work for other models such as MQ042RG-CM?
2. Where I can change the value of acq_timing_mode? I am new in using Bosai software.
3. Could you add the 2048x2048 in the F_Resolution?
4. Is it possible to do 2x2 or 4x4 binning using this node?

Best,
Mingrui

Reply all
Reply to author
Forward
0 new messages