This is a C++ sample program that uses the OpenCV library to capture images from a camera and display them in real time on a window.
- Create a directory named build in the project root directory.
- Enter the build directory.
- Run the command cmake .. to configure the project.
- Run the command make to build the project.
- Run the program with the command ./program.
The program uses the VideoCapture class from OpenCV to access the camera and the Mat class to store the captured images. The imshow function is used to display the images on a window. The waitKey function is used to wait for a key pressed by the user.
The program uses the default API to open the camera and display the images in real time. If desired, the API and/or camera device can be changed by modifying the apiID and deviceID variables, respectively.
If the program is unable to open the camera, it will display an error message and terminate.