125 lines
3.4 KiB
C++
125 lines
3.4 KiB
C++
|
|
// FindCamera.cpp
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This example shows users how to find available cameras. */
|
|||
|
|
|
|||
|
|
#include <Windows.h>
|
|||
|
|
#include <malloc.h>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
|
|||
|
|
#include "IKapC.h"
|
|||
|
|
#pragma comment(lib, "IKapC.lib")
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
* @param[in] errc<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>Determine whether the function is called successfully.
|
|||
|
|
* @param[in] errc<EFBFBD><EFBFBD>Function return value. */
|
|||
|
|
#define CHECK(errc) \
|
|||
|
|
if (ITKSTATUS_OK != errc) \
|
|||
|
|
printErrorAndExit(errc)
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>Users enter Enter to exit the program. */
|
|||
|
|
void pressEnterToExit(void);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
* @param[in] errc<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>Print error message and exit the program.
|
|||
|
|
* @param[in] errc<EFBFBD><EFBFBD>Function return value. */
|
|||
|
|
void printErrorAndExit(ITKSTATUS errc);
|
|||
|
|
|
|||
|
|
int main(void)
|
|||
|
|
{
|
|||
|
|
// IKapC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
|
//
|
|||
|
|
// Return value of IKapC functions.
|
|||
|
|
ITKSTATUS res = ITKSTATUS_OK;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// The number of available devices.
|
|||
|
|
uint32_t numDevices = 0;
|
|||
|
|
|
|||
|
|
printf("Itek Console Find Camera Example (C version)\n");
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// Initialize IKapC runtime environment.
|
|||
|
|
res = ItkManInitialize();
|
|||
|
|
CHECK(res);
|
|||
|
|
|
|||
|
|
// ö<>ٿ<EFBFBD><D9BF><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>豸ǰ<E8B1B8><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ItkManGetDeviceCount() <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// Enumerate the number of available devices. Before opening the device, ItkManGetDeviceCount() function must be called.
|
|||
|
|
res = ItkManGetDeviceCount(&numDevices);
|
|||
|
|
CHECK(res);
|
|||
|
|
|
|||
|
|
// <20><>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>豸ʱ<E8B1B8><CAB1>
|
|||
|
|
//
|
|||
|
|
// When there is no connected devices.
|
|||
|
|
if (numDevices == 0) {
|
|||
|
|
fprintf(stderr, "No device.\n");
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ӡ<EFBFBD><D3A1><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
|||
|
|
//
|
|||
|
|
// Print information of connected cameras.
|
|||
|
|
uint32_t i = 0;
|
|||
|
|
for (; i < numDevices; ++i) {
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD>塣
|
|||
|
|
//
|
|||
|
|
// Camera information structure.
|
|||
|
|
ITKDEV_INFO di;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>
|
|||
|
|
//
|
|||
|
|
// Get device information.
|
|||
|
|
ItkManGetDeviceInfo(i, &di);
|
|||
|
|
|
|||
|
|
// <20><>ӡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
|||
|
|
//
|
|||
|
|
// 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\n",
|
|||
|
|
di.FullName, di.FriendlyName, di.VendorName, di.ModelName, di.SerialNumber, di.DeviceClass, di.DeviceVersion,
|
|||
|
|
di.UserDefinedName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ͷ<EFBFBD> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// Release IKapC runtime environment.
|
|||
|
|
ItkManTerminate();
|
|||
|
|
|
|||
|
|
pressEnterToExit();
|
|||
|
|
return EXIT_SUCCESS;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// Print error message and exit the program.
|
|||
|
|
void printErrorAndExit(ITKSTATUS errc)
|
|||
|
|
{
|
|||
|
|
fprintf(stderr, "Error Code:%08x\n", errc);
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// Users enter Enter to exit the program.
|
|||
|
|
void pressEnterToExit(void)
|
|||
|
|
{
|
|||
|
|
fprintf(stderr, "\nPress enter to exit.\n");
|
|||
|
|
while (getchar() != '\n')
|
|||
|
|
;
|
|||
|
|
}
|