Creating the HelloWorld Project
You create a C++ console app in Visual Studio, set up the INFINICAM SDK (PUCLIB), and write a program that detects and connects to the camera and shows its serial number.
-
Create a new project
- Start Visual Studio and choose “Create a new project”.
- From the template list, choose “Console App” (C++ / Windows / Console) and click “Next”.
- Enter
HelloWorldas the project name andC:\infinicam_projectsas the location, check “Place solution and project in the same directory”, and click “Create”. Avoid folders with non-ASCII characters or spaces, and folders synced by OneDrive or similar (for the reasons, see notes on where to save).
-
Set the platform to x64
Set the platform box in the toolbar at the top of the window to
x64. -
Open the properties window
From the menu at the top of the window, choose “Project” > “HelloWorld Properties” (your own project name appears in place of “HelloWorld”). At the top of the window, set “Configuration” to “All Configurations” and “Platform” to “x64” (if it shows “Active(x64)”, you can leave it as it is).
-
Header file location (C/C++ > General)
Enter the following in “Additional Include Directories”.
C:\infinicam_sdk\include -
Read source files as UTF-8 (C/C++ > Command Line)
Enter the following in “Additional Options”. It is needed when your source code contains non-ASCII text, such as the Japanese comments in the sample code bundle.
/utf-8 -
Library location and name (Linker)
-
Enter the following in “Additional Library Directories” under “Linker” > “General”.
C:\infinicam_sdk\lib -
Add the following to the start of “Additional Dependencies” under “Linker” > “Input”.
PUCLIB.lib;
-
-
Copy the DLLs automatically (Build Events)
Enter the following in “Command Line” under “Build Events” > “Post-Build Event”, then close with “Apply” > “OK”.
xcopy /Y /D "C:\infinicam_sdk\dll\*.dll" "$(OutDir)" -
Enter the source code
Open the
.cppfile with the same name as the project (for exampleHelloWorld.cpp) and replace its contents with the following code.#include <stdio.h>#include <stdlib.h>#include <PUCLIB.h> // INFINICAM SDK headerint main(){printf("Initializing INFINICAM...\n");// 1. Initialize the SDKPUCRESULT ret = PUC_Initialize();if (ret != PUC_SUCCEEDED) {printf("Error: failed to initialize the SDK. ErrorCode: %d\n", ret);return EXIT_FAILURE;}// 2. Search for connected camerasPUC_DETECT_FILTER filter = { 0 };filter.nDeviceTypeFlags = PUC_DETECT_TARGET_ALL; // Search for both UC-1.1 and GbE-2PUC_DETECT_INFO detectInfo = { 0 };ret = PUC_DetectDevice2(&filter, &detectInfo);if (ret != PUC_SUCCEEDED || detectInfo.nDeviceCount == 0) {printf("Error: no camera was found. ErrorCode: %d\n", ret);printf("Check the cable connection and the network settings.\n");return EXIT_FAILURE;}printf("Camera detected. (count: %u)\n", detectInfo.nDeviceCount);// 3. Open the first camera foundPUC_HANDLE hDevice = NULL;ret = PUC_OpenDevice2(0, &hDevice);if (ret != PUC_SUCCEEDED) {printf("Error: could not open the camera. ErrorCode: %d\n", ret);return EXIT_FAILURE;}printf("SUCCESS: connected to the camera!\n");// 4. Show camera informationUINT64 serialNo = 0;if (PUC_GetSerialNo(hDevice, &serialNo) == PUC_SUCCEEDED) {printf("Serial number: %llu\n", serialNo);}// 5. Close the cameraPUC_CloseDevice(hDevice);return EXIT_SUCCESS;} -
Connect the camera and run it
Connect the camera to the PC and press
Ctrl+F5(Start Without Debugging). If you see the following, it worked.Initializing INFINICAM...Camera detected. (count: 1)SUCCESS: connected to the camera!Serial number: (your camera's serial number)
