Syntax


 PXL_RETURN_CODE PxLGetNumberCameras (

   U32*    pSerialNumbers,

   U32*    pNumSerialNumbers );


Description 


This function determines the number of Pixelink cameras connected to the system. 


pSerialNumbers  is the pointer to an array of the serial numbers of the cameras connected to the system.  To ignore, set to NULL—the function will return the number of connected cameras (that is, the required number of array entries for pSerialNumbers) in pNumberSerial., for the purpose of memory space allocation.    

 

pNumSerialNumbers is the pointer to the number of cameras connected (that is, the number of entries in the array pointed to by pSerialNumbers ).  Each entry is 4 bytes in size.



Comments, Restrictions and Limitations


PxLGetNumberCameras is provided for backward compatibility; new applications should use PxLGetNumberCamerasEx.


PxLGetNumberCameras will only detect FireWire, USB2.0 and network cameras that are available to be controlled*.  To detect network cameras that do not yet have valid IP addresses or are currently being controlled, use the extended function

PxLGetNumberCamerasEx.


Before this function is called, memory space should be allocated for the pSerialNumbers array (that is, pNumberSerial × 4 bytes).  Set pSerialNumbers to NULL to have pNumSerialNumbers set to the number of camera detected.


This function is typically used at the beginning of a session, to determine the number of cameras connected to the system.  It requires a longer response time than other functions, although it is well within the time needed to open an application or for a user to change settings within a GUI.  It is expected that this function will be called when high speed is not critical to the performance of the application, such as on startup or reinitialization, when the response time will be transparent to the user.  It is not typically necessary to use this function within image display and capture routines.  To avoid undue system delays, this function should be used only when necessary.


The list of serial numbers can be used with PxLInitialize to specify a specific camera to initialize.


*NOTE: Calling PxLGetNumberCameras after an application has successfully called PxLInitialize for a given network camera will return the serial numbers of all cameras, including the network camera the application has already initialized. 


Example


rc = PxLGetNumberCameras(NULL, &numCameras);

if (API_SUCCESS(rc)) {

    if(numCameras > 0) {

        /* Malloc an array to hold the serial numbers */

        U32* pSerialNumbers = (U32*)malloc(sizeof(U32) * numCameras);

        if (NULL != pSerialNumbers) {

            /* Read in all the serial numbers */

            rc = PxLGetNumberCameras(&pSerialNumbers[0], &numCameras);

            if (API_SUCCESS(rc)) {

                // Process list of cameras here
            }
        }
    }
}


See also: PxLGetNumberCamerasEx