Cannot connect to cameras using SDK

Post Reply
Jason_VV
Posts: 4
Joined: Mon Aug 19, 2013 2:53 pm

Cannot connect to cameras using SDK

Post by Jason_VV »

Hi, there.
I am new to Camera SDK. I am now using Prime 41 and SDK 1.2.1. The cameras are all connected by Ethernet cables, and my laptop is 32-bit Win7. All the cameras work well in Motive, while when I ran SimpleTest in SDK, it always said that no cameras are connected.

I also tried to insert a long interval for initialization. Though I can get connected to cameras with list.Count() > 0, all the cameras didn't light up and the hublist was still none.

Could anyone give me some suggestion?

Thank you.

Jason
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Cannot connect to cameras using SDK

Post by beckdo »

Hey Jason,

Thanks for the question. The Camera SDK is overdue for an upgrade in this regard. I problem is centered around the WaitForInitialization() method. Historically, all of our products were USB devices. These devices had a dedicated connection so the concept of waiting for them is straight forward. In the more recent Ethernet devices, the SDK isn't actually aware that they are out on the network until they announce themselves. Thus the issue where it sporadically reports 0 cameras.

I've been working with our hardware engineers on a solid fix for this issue so I can put this one to rest. I'm working on this currently so in the next release of the SDK it's likely the WaitForInitialization() will reliably wait until all cameras are initialized and pulled into the system.

As a quick fix you can do something like:

Code: Select all

CameraManager::X().WaitForInitialization();
Sleep(5000);
CameraManager::X().WaitForInitialization();
Also, for Sleep() you need to make sure you #include <windows.h>.

This is not great because your code is blocking for several seconds but it does ensure proper initialization. If you want to minimize the start-up time and you know the number of cameras you have connected you can do something like this so that your app is up and running as quickly as possible:

Do this as early in your code as possible:

Code: Select all

CameraLibrary::CameraManager::X();
This puts the wheels in motion for the cameras to initialize. At this point do all your other application initialization. This way the cameras will be initializing in parallel with the application getting it's window initialized and any other assets loaded.

Now, when you need the cameras in you can wait for them with something like this:

Code: Select all

int initializedCount=0;
int cameraCount = 3; // the number of cameras connected to your computer

while(initializedCount<cameraCount)
{
    CameraList list;
    initializedCount = 0;

    for(int i=0; i<list.Count(); i++)
    {
        if(list[i].State()==CameraLibrary::Initialized)
            initializedCount++;
    }
}
Additionally, you might want to put some code in there to time-out if all cameras do not become initialized in a reasonable amount of time.

One of your best tools for knowing what is going on with the cameras is the CameraList object. It gives you a non-blocking real-time way to know what cameras are connected to the system even if they are not available to the application yet because they are still in the process of initialization.

Additionally, we're going to improve the WaitForInitialization() call to simplify waiting for Ethernet cameras in the coming versions. For simple applications, WaitForInitialization() is a way to bring all the cameras to initialization and ready for use in a single line of code.
Jason_VV
Posts: 4
Joined: Mon Aug 19, 2013 2:53 pm

Re: Cannot connect to cameras using SDK

Post by Jason_VV »

Thank you for your detailed answer. I tried to insert Sleep(5000), but still didn't work well. As I have 16 cameras connected by Ethernet, I think it might have longer delay. So I insert Sleep(50000) instead. This time, it shows that I connected to 15 of 16 cameras in the output, but with 0 hubs connection. Worse still, all the indicator rings on the cameras didn't light up even I got connected to 15 cameras.

Could you help me?
Thank you.
Last edited by Birch on Wed Aug 28, 2013 3:02 pm, edited 1 time in total.
Reason: Trim quoting down
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Cannot connect to cameras using SDK

Post by beckdo »

It sounds like you have something wrong with your code. Send it to support and one of our engineers will take a look and help you resolve it.
Jason_VV
Posts: 4
Joined: Mon Aug 19, 2013 2:53 pm

Re: Cannot connect to cameras using SDK

Post by Jason_VV »

Thank you for your kind reply. Having tried time and time again, I guess I located the problem, and sorry for the last messy post.

Actually, your solution did work well if I changed the sleep period to 50,000 ms. I guess it might be because of the relatively large number(16) of cameras here. Here is the part of code:

Code: Select all

    
CameraManager::X().WaitForInitialization();
Sleep(50000);
CameraManager::X().WaitForInitialization();
However, I am not sure that if they work properly, as all the blue indicator rings do not light up during the whole process. I remember that when using Motive, all the rings light up after initialization with a camera index number showing in the bottom left of each camera. I also tried the initialization code in "MJPEGViewer" sample, all I got was a black window with "empty frame". It seems like all the cameras are connected but don't work. Is it the case?

Thank you for your time and hope to get your help.

Jason
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Cannot connect to cameras using SDK

Post by beckdo »

Hey Jason,

I've reviewed your code. There are a couple issues with it. Primarily you don't want to make assumptions about what order and the total number of items in the CameraList. For example, if you have 10 cameras, don't assume that the first 10 items in the CameraList are the 10 cameras.

It may seem counter intuitive at first, but the CameraList reflects that status of all of the OptiTrack devices. Rather than assume 10 entries means 10 cameras, count the number of cameras in the list. Case and point, if you have a hardware key or an eSync connected, they will also appear in the list. Also, if for some reason, you have hot-plugged a device during initialization or perhaps one of your cameras has performed a firmware upgrade, those can all result in additional entries in the list.

You definitely should not have to wait 50 seconds to initialize the cameras. I would suggest grabbing the latest beta when it's available, probably within the next 24 hours, Camera SDK v1.5 Beta 1. Then just use

Code: Select all

CameraManager::X().WaitForInitialization();
That should reliably wait until your cameras are ready for use. Alternatively if you have no devices connected it will return within 2 seconds.

In regards to the status right lighting up and the numeric showing the camera number, those are features of the Motive software. The Camera SDK provides functionality but does not make any assumptions about what number you want to show and what color or intensity you'd like to make the status ring.

If you want to make a camera show the number '1', just do camera->SetNumeric(true,1);

If you want to light up the status ring for a camera, use the function camera->SetStatusRingLights(...);

In regards to the status ring lighting up after execution, or when you stop on a breakpoint for a very long time, the 'blue with throbbing white lights' status ring signifies that the camera is in stand-by.

This is normal behavior. If you'd like to prevent the cameras from going into stand-by while stopping in the debugger for an extended period of time, make sure to do this at the top of your main function:

Code: Select all

CameraLibrary_EnableDevelopment();
Thanks,
Doug
Jason_VV
Posts: 4
Joined: Mon Aug 19, 2013 2:53 pm

Re: Cannot connect to cameras using SDK

Post by Jason_VV »

Thank you so much, Doug. Your suggestion really helps.

Although I haven't seen the new version of Camera SDK, the cameras work well using the samples. You are right, the initialization of cameras happens almost at the same time, and it is impossible to initialize them one by one. Your code of LED indicators also works well. In addition, it might be necessary to add some sleep after camera-> start in the frame calculation sample, at least for my camera system.

Regards,
Jason
Last edited by Birch on Wed Aug 28, 2013 3:00 pm, edited 1 time in total.
Reason: Trim quoting down
Post Reply