PXL_RETURN_CODE PxLGetNumberCamerasEx (

 CAMERA_ID_INFO* pCameraIdInfo,

 U32*            pNumberCameraIds );



This function is an extended version of PxLGetNumberCameras which will also detect network cameras that do not have IP addresses.  As well as the number of cameras connected, PxLGetNumberCameras returns information about the serial number and network connection info for all connected cameras of all interface types.

  • pCameraIdInfo is the pointer to an array of the CAMERA_ID_INFO structures of the cameras connected to the system.  To ignore, set to NULL and the function will return the number of connected cameras (i.e. the required number of array entries for pCameraIdInfo will be in pNumberCameraIds).

  • pNumberCameraIds is the pointer to the number of cameras connected (i.e. the number of entries in the array pointed to by pCameraIdInfo).   

PxLGetNumberCamerasEx behaves as follows:

  • If pCameraIdInfo is set to NULL, it will be ignored and pNumberCameraIds will be set to the required number of array entries for the purpose of memory space allocation.
  • If pCameraIdInfo is set to a properly allocated memory address, then the pCameraIdInfo structure will be filled in as follows: 
    • For non-networked cameras, it will return CameraSerialNum; all other fields will be set to zero.
    • For network cameras that DO NOT have an IP address, it will return the CameraMac, NicIpAddress, and SubnetMask fields; all other fields will be set to zero (including CameraSerialNum).
    • For network cameras that DO have a valid IP address, all fields will be valid.

Comments, Restrictions and Limitations

This function is supported by Pixelink API 7.01 and later.

Before this function is called, memory space should be allocated for the pCameraIdInfo array (i.e. pNumberCameraIds × sizeof(CAMERA_ID_INFO)).  Set pCameraIDInfo to NULL to return pNumberCameraIds to determine the space allocation.

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.

For networked cameras that do not have an IP address, PxLGetNumberCamerasEx can be used to find the camera MAC address, NIC IP Address and the subnet mask that will be required to determine a suitable IP address.   The IP address can be assigned with PxLSetCameraIPAddress.  These cameras can be identified by an expression like ((cameraSerialNum == 0) || (cameraIpAddress == 0)), 

Once all the IP addresses have been set, PxLGetNumberCamerasEx or PxLGetNumberCameras can be called to read the serial numbers of all the connected cameras.

Any of the serial numbers can then be used with PxLInitialize to specify a specific camera to initialize.


Recommended method of using PxLGetNumberCamerasEx:


  • Call the function with pCameraIdInfo set to NULL. The number of cameras is returned in pNumberCameraIds.
  • Allocate the required space to hold a contiguous array of CAMERA_ID_INFO structs, one for each camera.
  • Call the PGetNumberCamerasEx with a pointer to the array.




 // Query how many cameras there are

 U32 numCameras;

 PXL_RETURN_CODE rc = PxLGetNumberCamerasEx(NULL, &numCameras);

 if (!API_SUCCESS(rc)) {

 // Error handling here


 if (numCameras > 0) {

     // Declare a vector/array of CAMERA_ID_INFO structs, one for each camera

     std::vector<CAMERA_ID_INFO> cameraIdInfo(numCameras);

     // Don't forget to set the StructSize of the first element of the array

     cameraIdInfo[0].StructSize = sizeof(cameraIdInfo[0]); // or sizeof(CAMERA_ID_INFO) 


     rc = PxLGetNumberCamerasEx(&cameraIdInfo[0], &numCameras);

     if (!API_SUCCESS(rc)) {

         // Error handling here



     // Print some info about each camera

     for(U32 i=0; i < numCameras; i++) {

         printf("Camera %d:\n", i);

         printf("\tSerial Number: %d\n", cameraIdInfo[i].CameraSerialNum);

         printf("\tIP Address: %d.%d.%d.%d\n", 








dotNet Example

 // Query the number of cameras

 int numCameras = 0;

 Api.GetNumberCameras2(null, ref numCameras);

 // Create and populate an array of CameraIDInformation structs, one for each camera..

 CameraIdInformation[] cameraID = new CameraIdInformation[numCameras];

 Api.GetNumberCameras2(cameraID, ref numCameras);

 // Print the serial number for each camera.
 for (int i = 0; i < numCameras; i++)

     System.Console.WriteLine("Serial Number : ", cameraID[i].SerialNumber);