Skip to content
⚡ Developer documentation for INFINICAM, the real-time high-speed camera (UC-1.1 / GbE-2)

Setting up OpenCV 4 (C++)

This page is for when you want to use OpenCV 4 (4.14.0). If you are installing OpenCV for the first time, see Setting up OpenCV (C++), which uses the latest OpenCV 5.


OpenCV (Open Source Computer Vision Library) is a collection of program building blocks for working with images and video. It is a free library that covers most of the features commonly used in image processing, and it is close to a standard tool in computer vision (CV) and machine vision (MV) research and development.

  • Display and save: show video in a window, save images as PNG or JPEG
  • Edit: resize, rotate, adjust brightness, blur, binarize (split clearly into black and white)
  • Detect shapes and features: find contours, edges, circles, and lines
  • Recognize and track objects: detect markers (such as ArUco), track moving objects
  • Correct the camera: correct lens distortion, measure distance with a stereo camera

How the work is split with the INFINICAM SDK

Section titled “How the work is split with the INFINICAM SDK”
Role Handled by
Receiving images from the camera and decoding them into image data (an array of numbers) INFINICAM SDK
Displaying and analyzing the image data, and using it for decisions OpenCV

For example, to “find the position of a ball in 1,000 fps video and move a device”, you can leave receiving from the camera to the SDK and finding the ball to OpenCV.

OpenCV 4.5.0 and later are released under the Apache License 2.0 (as of 2026; up to 4.4.0 it was the 3-clause BSD license). It is free to use and fine for commercial use. You are not required to publish the source code of programs you write with OpenCV.


OpenCV provides official prebuilt packages for Windows. You can use them just by extracting the downloaded file.

  1. Download

    Open the releases page on the official OpenCV site, click “Windows” under “OpenCV – 4.14.0” (not 5.0.0 at the top), and download opencv-4.14.0-windows.exe (about 200 MB).

  2. Extract to C:\

    Run the downloaded opencv-4.14.0-windows.exe, type C:\ in “Extract to:”, and click “Extract”. Extraction takes a few minutes.

    The extraction window with C:\ entered in Extract to
  3. Check the extracted folder

    You are done when C:\opencv\ exists. All explanations on this site assume OpenCV is extracted to C:\opencv. These are the 3 folders you mainly use.

    • Directoryopencv/ Folder created directly under C:\
      • Directorybuild/
        • Directoryinclude/ Header files (opencv2/opencv.hpp and others)
          • …
        • Directoryx64/
          • Directoryvc16/
            • Directorylib/ Used when building (opencv_world4140.lib, opencv_world4140d.lib)
              • …
            • Directorybin/ Used when running (opencv_world4140.dll, opencv_world4140d.dll)
              • …
      • Directorysources/ OpenCV’s own source code (not used)
        • …

Add the OpenCV settings to the project where you set up the SDK in Setting up a C/C++ development environment. Keep the SDK settings; don’t delete them.

  1. Header file location (C/C++ > General)

    Set Configuration to “All Configurations” and Platform to “x64”, then add the following to “Additional Include Directories”, separated by ;.

    C:\infinicam_sdk\include;C:\opencv\build\include
  2. Library location (Linker > General)

    Add the following to “Additional Library Directories”.

    C:\infinicam_sdk\lib;C:\opencv\build\x64\vc16\lib
  3. Library names (Linker > Input)

    For this setting only, set Debug and Release separately instead of using “All Configurations”.
    • Set Configuration at the top of the window to “Debug” and add the following to the start of “Additional Dependencies” (ending in d).

      PUCLIB.lib;opencv_world4140d.lib;
    • Switch Configuration to “Release” and add the following to the start of “Additional Dependencies” (without d).

      PUCLIB.lib;opencv_world4140.lib;
  4. Copy the DLLs automatically (Build Events > Post-Build Event)

    Set Configuration back to “All Configurations” and add the following as the second line of “Command Line”. Keep the first line, which copies the SDK DLLs.

    xcopy /Y /D "C:\infinicam_sdk\dll\*.dll" "$(OutDir)"
    xcopy /Y /D "C:\opencv\build\x64\vc16\bin\opencv_world*.dll" "$(OutDir)"

    Finally, click “Apply” > “OK” to close the properties window.


Check that OpenCV can be used, without a camera. Replace the contents of your .cpp file with the following code and run it with Ctrl + F5.

#include <stdio.h>
#include <PUCLIB.h> // INFINICAM SDK header
#include <opencv2/opencv.hpp> // OpenCV header
#include <opencv2/core/utils/logger.hpp> // For setting which messages OpenCV prints
int main()
{
// Stop the notices (INFO) that OpenCV prints, and show only warnings and errors
cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);
printf("OpenCV version: %s\n", CV_VERSION);
// Draw a white circle on a black image and show it in a window
cv::Mat image(240, 320, CV_8UC1, cv::Scalar(0));
cv::circle(image, cv::Point(160, 120), 60, cv::Scalar(255), -1);
cv::imshow("OpenCV test", image);
printf("Press any key in the window to exit.\n");
cv::waitKey(0);
return 0;
}

If the console shows the OpenCV version and a window with a white circle opens, you are ready.


Symptom / error Likely cause What to do
C1083: Cannot open include file: 'opencv2/opencv.hpp' The OpenCV header location is set incorrectly Check the path in step 3-1, and that C:\opencv\build\include\opencv2\opencv.hpp exists
LNK1104: cannot open file 'opencv_world4140.lib' The library location, or the version number in the file name, is wrong Check the path in step 3-2 and the actual file names in the lib folder
“The code execution cannot proceed because opencv_world4140.dll was not found” The OpenCV DLL is not in the same folder as the EXE Check the post-build event in step 3-4
Many lines such as [ INFO:…] … opencv_highgui_gtk… => FAILED appear in the console This is not an error. The Debug build of OpenCV is reporting that it looked for optional components that are not included in the Windows package You can ignore it. Adding cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);, as in the sample, hides these lines
The program crashes immediately, or Debug runs very slowly The Debug and Release libraries are mixed up Check the step 3-3 settings for each configuration

Used with permission from Microsoft.