Shutdown() exception

Post Reply
noraxon
Posts: 3
Joined: Fri Mar 29, 2013 1:05 pm

Shutdown() exception

Post by noraxon »

I am seeing an exception 0xC0000008 (An invalid handle was specified) when calling CameraManager::X().Shutdown() under the following conditions:

1) 2 cameras are attached to the PC. (one V100:R2 and another V100:R2 FS.)

2) I unplug the camera with serial #197925.

3) I call CameraManager::X().GetCameraBySerial(197925) and zero is returned as expected. (I am testing for user errors.)

4) I plug the camera back in and repeat step 3 and start/stop a capture. Everything works as expected. I can even start/stop multiple captures.

5) Before exiting my application I call Shutdown() and the exception is thrown.


This doesn't happen if I don't have the extra camera plugged in.
noraxon
Posts: 3
Joined: Fri Mar 29, 2013 1:05 pm

Re: Shutdown() exception

Post by noraxon »

I failed to include that I am calling the following before step 3:

CameraManager::X().WaitForInitialization();
//scan for newly connected cameras
CameraManager::X().ScanForCameras();
//wait for initialization again after scanning
CameraManager::X().WaitForInitialization();

If I don't call ScanForCameras(), GetCameraBySerial() does not ever see the newly connected camera and Shutdown() produces an access violation writing to location 0xfeeefef2. (always the same address.)
noraxon
Posts: 3
Joined: Fri Mar 29, 2013 1:05 pm

Re: Shutdown() exception

Post by noraxon »

Full example code. Of course the serial number needs to be changed.

Code: Select all


#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

#include "cameralibrary.h"
using namespace CameraLibrary;

int _tmain(int argc, _TCHAR* argv[])
{
    printf("==============================================================================\n");
    printf("== Camera Library Camera Test                             NaturalPoint 2010 ==\n");
    printf("==============================================================================\n\n");

    printf("Waiting for cameras to spin up...");
    
    //== Initialize Camera Library ==----

   CameraManager::X().WaitForInitialization();  
   //scan for newly connected cameras
   CameraManager::X().ScanForCameras();
   //wait for initialization again after scanning
   CameraManager::X().WaitForInitialization();

    CameraLibrary::Camera* c = CameraManager::X().GetCameraBySerial(197925);

    if( c != 0 )
    {
      c->Start();
      c->Stop();
      c->Release();
    }
           
   CameraManager::X().WaitForInitialization();  //set breakpoint here for testing. plug in missing camera here
   //scan for newly connected cameras
   CameraManager::X().ScanForCameras();
   //wait for initialization again after scanning
   CameraManager::X().WaitForInitialization();
    
    c = CameraManager::X().GetCameraBySerial(197925);

    if( c != 0 )
    {
      c->Start();
      c->Stop();
      c->Release();
    }

    //== Disconnect devices and shutdown Camera Library ==--
    CameraManager::X().Shutdown();
	return 0;
}


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

Re: Shutdown() exception

Post by beckdo »

I'm going to add a ticket for this as well as take a look here on my end to make sure we get this resolved as soon as possible.
Post Reply