89 lines
2.2 KiB
C
89 lines
2.2 KiB
C
|
|
// FindCamera.c
|
||
|
|
|
||
|
|
/* @brief: This example shows users how to find available cameras. */
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
|
||
|
|
#include "IKapC.h"
|
||
|
|
|
||
|
|
/* @brief: Determine whether the function is called successfully.
|
||
|
|
* @param[in] errc: Function return value. */
|
||
|
|
#define CHECK(errc) if (ITKSTATUS_OK != errc) printErrorAndExit(errc)
|
||
|
|
|
||
|
|
/* @brief: Users enter Enter to exit the program. */
|
||
|
|
void pressEnterToExit(void);
|
||
|
|
|
||
|
|
/* @brief: Print error message and exit the program.
|
||
|
|
* @param[in] errc: Function return value. */
|
||
|
|
void printErrorAndExit(ITKSTATUS errc);
|
||
|
|
|
||
|
|
int main(void)
|
||
|
|
{
|
||
|
|
// Return value of IKapC functions.
|
||
|
|
ITKSTATUS res = ITKSTATUS_OK;
|
||
|
|
|
||
|
|
// The number of available devices.
|
||
|
|
uint32_t numDevices = 0;
|
||
|
|
|
||
|
|
// Initialize IKapC runtime environment.
|
||
|
|
res = ItkManInitialize();
|
||
|
|
CHECK(res);
|
||
|
|
|
||
|
|
// Enumerate the number of available devices. Before opening the device, ItkManGetDeviceCount() function must be called.
|
||
|
|
res = ItkManGetDeviceCount(&numDevices);
|
||
|
|
CHECK(res);
|
||
|
|
|
||
|
|
// When there is no connected devices.
|
||
|
|
if (numDevices == 0)
|
||
|
|
{
|
||
|
|
fprintf(stderr, "No device.\n");
|
||
|
|
ItkManTerminate();
|
||
|
|
pressEnterToExit();
|
||
|
|
exit(EXIT_FAILURE);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Print information of connected cameras.
|
||
|
|
uint32_t i = 0;
|
||
|
|
for (; i < numDevices; ++i)
|
||
|
|
{
|
||
|
|
// Camera information structure.
|
||
|
|
ITKDEV_INFO di;
|
||
|
|
|
||
|
|
// Get device information.
|
||
|
|
ItkManGetDeviceInfo(i, &di);
|
||
|
|
|
||
|
|
// Print information.
|
||
|
|
printf("Device Full Name:%s\n Friendly Name:%s\n Vendor Name:%s\n Model Name:%s\n Serial Name:%s\n Device Class:%s\n Device Version:%s\n User Defined Name:%s\n",
|
||
|
|
di.FullName,
|
||
|
|
di.FriendlyName,
|
||
|
|
di.VendorName,
|
||
|
|
di.ModelName,
|
||
|
|
di.SerialNumber,
|
||
|
|
di.DeviceClass,
|
||
|
|
di.DeviceVersion,
|
||
|
|
di.UserDefinedName);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Release IKapC runtime environment.
|
||
|
|
ItkManTerminate();
|
||
|
|
|
||
|
|
pressEnterToExit();
|
||
|
|
return EXIT_SUCCESS;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Print error message and exit the program.
|
||
|
|
void printErrorAndExit(ITKSTATUS errc)
|
||
|
|
{
|
||
|
|
fprintf(stderr, "Error Code:%08x\n", errc);
|
||
|
|
ItkManTerminate();
|
||
|
|
pressEnterToExit();
|
||
|
|
exit(EXIT_FAILURE);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Users enter Enter to exit the program.
|
||
|
|
void pressEnterToExit(void)
|
||
|
|
{
|
||
|
|
fprintf(stderr, "\nPress enter to exit.\n");
|
||
|
|
while (getchar() != '\n');
|
||
|
|
}
|