Use two Basler GigE cameras simultaneously

2,348 views
Skip to first unread message

Bastijn van den Boom

unread,
Aug 7, 2017, 9:34:05 AM8/7/17
to Bonsai Users
Hi Goncalo,

I have used Bonsai with one single Basler GigE camera without any problems for a while now. However, I would like to have two cameras on one computer. This doesn't seem to work properly.

Currently, I have two Intel LAN PCI cards, both connected to a Basler GigE camera (same model cameras actually). Using the Basler drivers (Pylon), I have correctly made a static ip address and can acquire frames from both cameras with their software. In Bonsai, I cannot find the cameras properly. If I use CameraCapture with index 0, I get an image from one of the cameras (always the same one I think). Other index numbers don't seem to work. In VideoCaptureDevice (Pylon support DirectShow although discouraged by them), next to index I get a drop down menu with only one camera (0 (Basler GenICam Source)). If I start two VideoCaptureDevice nodes simultaneously (both index 0), I most often get frames from both cameras! However, it changes which node acquires what camera (very often actually). Sometimes, I get an error (Exception of type 'System.OutOfMemoryException' was thrown.".

Any clue how to get both cameras in the index drop down menu?

Thanks in advance!

Best,
Bastijn

Gonçalo Lopes

unread,
Aug 7, 2017, 12:23:05 PM8/7/17
to Bastijn van den Boom, Bonsai Users
Hi Bastijn,

I have never tried any of the Basler cameras. Unfortunately, what you describe sounds like a problem in the Basler DirectShow driver adapter. It looks like they didn't bother mapping multiple cameras to multiple indices... that is probably why they discourage its use.

I suspect the best way to solve this would be to implement a pylon-based interface to Bonsai, so that you can directly use their SDK from Bonsai to access the camera. I've checked their website and since they had C# interfaces and some example code, I quickly put together a simple draft for such a package:


I'm also attaching a preview build that you can install as a custom package directly in bonsai. Do you mind giving this package a try and letting me know what happens? Bear in mind I had no means of actually trying out this code, since I actually have no Basler camera, so it is quite possible it simply blows up criptically.

If it does, let me know if you would be willing to debug this jointly, since I have no way of debugging further without getting my hands on a camera.

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/45bb2327-622a-4c88-88dd-ad86b4e7d7ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bonsai.Pylon.0.1.0-alpha1.nupkg

Bastijn van den Boom

unread,
Aug 8, 2017, 4:22:46 AM8/8/17
to Bonsai Users, bastijnv...@gmail.com
Hi Goncalo,

Works like a charm out of the box! I agree that this is probably one of the best ways to keep the cameras constant. 

Using the Pylon IP Configuration, I found the serial numbers of the cameras and typed them next to SerialNumber. This works right away for both cameras in 1 Bonsai script. The drop down menu does not work, it is blank and gives an error.

Thanks a lot for your fast reply and great solution!
Bastijn


On Monday, 7 August 2017 18:23:05 UTC+2, goncaloclopes wrote:
Hi Bastijn,

I have never tried any of the Basler cameras. Unfortunately, what you describe sounds like a problem in the Basler DirectShow driver adapter. It looks like they didn't bother mapping multiple cameras to multiple indices... that is probably why they discourage its use.

I suspect the best way to solve this would be to implement a pylon-based interface to Bonsai, so that you can directly use their SDK from Bonsai to access the camera. I've checked their website and since they had C# interfaces and some example code, I quickly put together a simple draft for such a package:


I'm also attaching a preview build that you can install as a custom package directly in bonsai. Do you mind giving this package a try and letting me know what happens? Bear in mind I had no means of actually trying out this code, since I actually have no Basler camera, so it is quite possible it simply blows up criptically.

If it does, let me know if you would be willing to debug this jointly, since I have no way of debugging further without getting my hands on a camera.

Hope this helps.
On 7 August 2017 at 14:34, Bastijn van den Boom <bastijnv...@gmail.com> wrote:
Hi Goncalo,

I have used Bonsai with one single Basler GigE camera without any problems for a while now. However, I would like to have two cameras on one computer. This doesn't seem to work properly.

Currently, I have two Intel LAN PCI cards, both connected to a Basler GigE camera (same model cameras actually). Using the Basler drivers (Pylon), I have correctly made a static ip address and can acquire frames from both cameras with their software. In Bonsai, I cannot find the cameras properly. If I use CameraCapture with index 0, I get an image from one of the cameras (always the same one I think). Other index numbers don't seem to work. In VideoCaptureDevice (Pylon support DirectShow although discouraged by them), next to index I get a drop down menu with only one camera (0 (Basler GenICam Source)). If I start two VideoCaptureDevice nodes simultaneously (both index 0), I most often get frames from both cameras! However, it changes which node acquires what camera (very often actually). Sometimes, I get an error (Exception of type 'System.OutOfMemoryException' was thrown.".

Any clue how to get both cameras in the index drop down menu?

Thanks in advance!

Best,
Bastijn

--
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.

Gonçalo Lopes

unread,
Aug 8, 2017, 10:35:27 AM8/8/17
to Bastijn van den Boom, Bonsai Users
Ahah, nice, great to hear that it worked right away. The serial number dropbox blew up because it turns out I was using the wrong key for retrieving the camera info properties.

I'm attaching a new version where the drop down should now work and display just the raw serial numbers. Let me know if you find some time to try it. If you do, can you send me a screenshot of the bonsai properties window so I can see what the serial numbers actually look like?

After that I can maybe release the first version with a better formatted layout for the drop down.


To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.
Bonsai.Pylon.0.1.0-alpha2.nupkg

Bastijn van den Boom

unread,
Aug 8, 2017, 2:03:32 PM8/8/17
to Bonsai Users, bastijnv...@gmail.com
Sure no problem. Please, find attached a screenshot of the properties window. If you want to make it more fancy, can you add "Device User ID" to the serial number list? This can be user defined (using pylon IP Configurator) and will make it easier to distinguish cameras.

I noticed you used a CameraCapture node to load the Directshow of Pylon. Isn't it a function of the VideoCaptureDevice to pull the Directshow? If not, can you add other members (variables) of CameraCapture to the new node (e.g., FrameWidth, Fps, etc)? Or is this impossible due to the Directshow?
Bonsai_Pylon.jpg

Gonçalo Lopes

unread,
Aug 8, 2017, 3:27:27 PM8/8/17
to Bastijn van den Boom, Bonsai Users
Ah, good to hear that this worked, this means that I am accessing the right set of camera properties. Yes, I can add more details to the dropdown list for the next version.

About the extra variables, what did you have in mind? Was the goal to be able to configure the camera properties?

If this was the case, I think I would prefer to add support to load the pylon Viewer settings file. The reason is that there are usually many, many settings you can configure in these industrial cameras, and they can change between camera models and camera versions, so it is usually much easier to just configure the parameters in their own Viewer app and then simply write generic support to load the settings, rather than write our own user interface to configure everything.

I cannot try it myself but it looks like there is an option to "Save Camera Features" in the "Camera" menu. Can you save one of these files and send it as an attachment so I can have a look?



To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.

Bastijn van den Boom

unread,
Aug 11, 2017, 6:03:40 AM8/11/17
to Bonsai Users, bastijnv...@gmail.com
I have tried to change the settings using the pylon Viewer program. Yes, this works as well and I agree is preferable. Bonsai (CameraCapture (Pylon)) will load the settings of pylon. Please, find attached a screenshot. Not sure if you can use it.

To conclude, it is fairly easy to change camera settings (per camera) in pylon Viewer. One thing to keep in mind is that one should save the settings and set as default (camera - Configuration Sets - change: Configuration Set Selector and Default Startup Set). If you don't set the new settings as default, pylon will reset all settings after shutting down of the camera. It took me a while to figure this out but makes sense now.
pylon_Viewer.png
pylon_Viewer2.png

Gonçalo Lopes

unread,
Aug 11, 2017, 6:12:57 AM8/11/17
to Bastijn van den Boom, Bonsai Users
Cool, nice to hear :-) this is indeed my preferred solution.

We could add in the future an option to load their settings file directly, so you don't need to have default startup settings. Unfortunately I couldn't find a way to load their settings files from the pylon C# interface, so we might have to write a loader from scratch.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.

Bastijn van den Boom

unread,
Aug 11, 2017, 6:23:23 AM8/11/17
to Bonsai Users, bastijnv...@gmail.com
Thanks a lot for your help and support! If one just saves the settings once in the pylon Viewer, Bonsai will get these settings right away so it works great at the moment.

I noticed you do need a quick machine to run both cameras. Our first attempt (3.00GHz Core2Duo; 6GB RAM) runs out of cpu power and memory. Current machine (2.80GHz Xeon quad-core; 12GB RAM) has no problems and potentially can record more cameras simultaneously. 

Gonçalo Lopes

unread,
Aug 11, 2017, 7:01:27 AM8/11/17
to Bastijn van den Boom, Bonsai Users
That makes sense. I would actually guess that it's not so much the speed but the actual number of processors, because the OS will basically assign one processor to each camera. Quad-core parallelism helps :-)

Great to hear you got it working.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users+unsubscribe@googlegroups.com.

Zhichao Guo

unread,
Apr 30, 2019, 9:22:34 PM4/30/19
to Bonsai Users
Hi Goncalo,

I reply here because I have similar but worse issues. I also have two Basler Gige cameras that work well with Pylon and other applications. However, using Bonsai 2.3 and the Pyloncapture package, I can't connect to either of the camera. I attached a snapshot of the error message. The drop down menu doesn't work and reports the same error, and putting in the serial number doesn't work as well. I tried to downgraded the Pylon package to the two versions you put here and I still had the same error (by the way I had to uninstall Bonsai and reinstall since I can't remove the installed package from the library. It'll be helpful in this case to have an "uninstall" function in the package list).

When I tried using the general camera capture, the camera seemed to be recognized, and some related information could be pulled out. However, the image visualizer doesn't work. I saw your posts somewhere else addressing similar issues in other type of cameras saying that by pulling out specifically the ImageData of the camera as output the issue can be bypassed, but it can only be visualized by the text visualizer, which still doesn't show me the image of the camera. I'm completely out of my wit and after spending some effort trying to understand the logic of Bonsai, I feel it's a great software for data streaming and online processing, which is exactly what I need. Any help with this will be greatly appreciated!

Best,
Zhichao


On Monday, August 7, 2017 at 12:23:05 PM UTC-4, goncaloclopes wrote:
Hi Bastijn,

I have never tried any of the Basler cameras. Unfortunately, what you describe sounds like a problem in the Basler DirectShow driver adapter. It looks like they didn't bother mapping multiple cameras to multiple indices... that is probably why they discourage its use.

I suspect the best way to solve this would be to implement a pylon-based interface to Bonsai, so that you can directly use their SDK from Bonsai to access the camera. I've checked their website and since they had C# interfaces and some example code, I quickly put together a simple draft for such a package:


I'm also attaching a preview build that you can install as a custom package directly in bonsai. Do you mind giving this package a try and letting me know what happens? Bear in mind I had no means of actually trying out this code, since I actually have no Basler camera, so it is quite possible it simply blows up criptically.

If it does, let me know if you would be willing to debug this jointly, since I have no way of debugging further without getting my hands on a camera.

Hope this helps.
On 7 August 2017 at 14:34, Bastijn van den Boom <bastijnv...@gmail.com> wrote:
Hi Goncalo,

I have used Bonsai with one single Basler GigE camera without any problems for a while now. However, I would like to have two cameras on one computer. This doesn't seem to work properly.

Currently, I have two Intel LAN PCI cards, both connected to a Basler GigE camera (same model cameras actually). Using the Basler drivers (Pylon), I have correctly made a static ip address and can acquire frames from both cameras with their software. In Bonsai, I cannot find the cameras properly. If I use CameraCapture with index 0, I get an image from one of the cameras (always the same one I think). Other index numbers don't seem to work. In VideoCaptureDevice (Pylon support DirectShow although discouraged by them), next to index I get a drop down menu with only one camera (0 (Basler GenICam Source)). If I start two VideoCaptureDevice nodes simultaneously (both index 0), I most often get frames from both cameras! However, it changes which node acquires what camera (very often actually). Sometimes, I get an error (Exception of type 'System.OutOfMemoryException' was thrown.".

Any clue how to get both cameras in the index drop down menu?

Thanks in advance!

Best,
Bastijn

--
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...@googlegroups.com.
Bonsai pyloncapture error Capture.PNG

Gonçalo Lopes

unread,
May 1, 2019, 12:08:58 PM5/1/19
to Zhichao Guo, Bonsai Users
Hi Zhichao,

Glad to hear this fixed the problem. About the visualizer, the Pylon sources output not just images, but also embedded image metadata. Therefore, the output structure is not really an image, and cannot be visualized / saved directly. First you need to right click the node and select Output > Image, so that you extract the image output, which should then be correctly visualized.

Hope this helps.

On Wed, 1 May 2019 at 17:04, Zhichao Guo <guozhic...@gmail.com> wrote:
Thanks Gonçalo, you're absolutely right! I downgraded the driver from 5.2 to 5.1 and now I can see the list of available cameras from Pyloncapture and connect to them. However, I still couldn't find a way to see the video. It only has the text visualizer associated with it. I checked the packages and all visualization packages has been installed. I guess maybe I'm just not familiar with Bonsai. Could you help with a little bit more instructions?

Best,
Zhichao

On Tue, Apr 30, 2019 at 9:30 PM Gonçalo Lopes <goncal...@gmail.com> wrote:
Hi Zhichao and welcome to the forums,

This seems like a driver version mismatch. The Basler Pylon camera driver is very sensitive to version changes. If you use the latest Bonsai.Pylon package, you should install Pylon driver version 5.1.0. Other versions most likely won't work and will generate similar errors.

You can uninstall Bonsai packages by going to Tools > Manage Packages, and selecting Installed packages in the left side tabs. This will list all the installed packages and give you an option to uninstall.

Hope this helps.

To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
GUO Zhichao, PhD candidate
PTN program
Peking University, School of Life Sciences
Beijing, CHINA, 100871

Gonçalo Lopes

unread,
May 1, 2019, 3:04:37 PM5/1/19
to Zhichao Guo, Bonsai Users
Hi Zhichao,

Can you please always use Reply-All to the group? That way it's easier to keep track of the conversation.

About the second error you mention, this is due to out of date OpenGL drivers. Bonsai requires at least OpenGL 1.1 or 1.2 for visualizers, and 4.0 for shaders.
Most of the times this can be fixed simply by updating your graphics card drivers. All vendors should now support OpenGL 4.0 in even the most basic profiles.

You can check which version you have using one of the tools in this answer:

To update your graphics card driver, you should be able to use the control panel, or check your vendor website for updated drivers, it varies depending on hardware model and manufacturer.

Hope this helps.

On Wed, 1 May 2019 at 19:13, Zhichao Guo <guozhic...@gmail.com> wrote:
Hi Gonçalo,

I see! I thought I had to select some specific data output below Image and didn't realize that I can select Image as a whole. However, there still seems to be something wrong when I try to visualize the image. I appended screenshots here showing the error message and the camera information. What do you think?

Best,
Zhichao

Zhichao Guo

unread,
May 1, 2019, 7:01:43 PM5/1/19
to Gonçalo Lopes, Bonsai Users
Hi Gonçalo,

I'm sorry I didn't realize that I need to reply to all in order to push this to the forum. Actually this is my first google forum.:)

It took me some effort to update my graphic driver, but in the end everything worked out! I was almost crying when the video showed up eventually. Thank you so much for your help!

Last but not least, I've read all the documents I can find about Bonsai, but I'm still not sure how to implement my project. Is there any document about the detailed function of all the modules in the toolbox and way to use them? All I want is relatively simple, to make a couple of circular ROIs in the image stream, generate the average pixel value within the region, and then plot their values over time with a line plot. What I'm trying now is going through every module in the toolbox and see if there's any that can help me move forward, which is not an ideal algorithm.

Oh no!!! I was trying to view some examples in the gallery and stupidly pressed start, and lost the video again. I can't visualize it since the crash. Here's the error image (It looks identical to me...) I really hate this Basler camera. It gave me so much trouble! Do you know why this happened and any tips about how to prevent the crush in the future?

Thanks,
Zhichao
Bonsai pyloncapture error Capture 3.PNG

Gonçalo Lopes

unread,
May 1, 2019, 7:56:10 PM5/1/19
to Zhichao Guo, Bonsai Users
Hi Zhichao,

Which version of Bonsai were you using to run the Basler camera successfully? Was it Bonsai 32-bit or 64-bit? Maybe when you were checking the examples in the gallery you accidentally changed which version you were using?

You can choose which version to use when you start Bonsai from the start menu, or from the toolbar shortcut. Try it with both 32-bit and 64-bit to see if any of them works. The bits must match with your driver version as well, so if you installed Pylon 32-bit you need to run Bonsai 32-bit, and so on.

Hope this helps!

Zhichao Guo

unread,
May 2, 2019, 11:03:04 AM5/2/19
to Gonçalo Lopes, Bonsai Users
I think I used the 32-bit one. I tried both since that crush, and can't get it back online. I just realized that the OpenGL version relapsed into 1.1 again from 4.4 when I reinstall the driver. I'm asking for help from IT person and I'll let you know if I can resolve it. Thanks again!

Zhichao Guo

unread,
May 3, 2019, 12:25:26 PM5/3/19
to Gonçalo Lopes, Bonsai Users
Hi Gonçalo,

I just figured out the driver issue and now I can finally work on the flow. As I mentioned in the previous reply, my task is relative simple, which is to select a couple of circular ROIs and measure the mean pixel value, then plot with time. Do you mind to show me an example flow of this? I got stuck in the first step, which is how I can define a circular roi. I don't know if it's because I don't quite get it, I find the CropPolygon / RoiActivity functions quite difficult to use, which is not very user-friendly. I've had a hard time trying to draw something, modify and delete. Is there any documentation about the common functions in Bonsai that shows us how to use, which will make the learning process a bit easier?

Your help is much appreciated!
Zhichao

Gonçalo Lopes

unread,
May 6, 2019, 5:14:58 PM5/6/19
to Zhichao Guo, Bonsai Users
Hi Zhichao,

Can you create a new question for this? That way it will be easier for future users to identify relevant topics of discussion.
Reply all
Reply to author
Forward
0 new messages