The Camera Driver Library is a simple and easy-to-use C++ library designed to interact with standard cameras. It simplifies the process of capturing frames, displaying video feeds, and obtaining camera information. This library can be used to integrate camera functionality into your projects effortlessly.
The Camera Driver package relies on the following dependency:
- OpenCV 4
To build the Camera Driver package, follow these steps:
-
Clone the Repository: Clone the Camera Driver repository to your local machine.
git clone https://github.com/jrendon102/ros_utils.git
-
Navigate to the Project Directory: Go to the directory where you cloned the repository.
cd camera_driver
-
Build the Package: Use CMake and your preferred C++ compiler to build the package.
mkdir build cd build cmake ../ cmake --build .
-
Install the Package (Optional): If you want to install the package system-wide, you can use the following command:
sudo make install
After installation, the Camera Driver package should be available for other CMake projects on your system.
-
Use
find package(camera_driver)
in Your Project: In your project'sCMakeLists.txt
, usefind_package
to locate the Camera Driver package:find_package(camera_driver REQUIRED)
Finally, you can now link your project's targets to the Camera Driver package, build and execute your code.
To uninstall the Camera Driver package, follow these steps:
-
Navigate to the Project Directory: Go to the directory where you cloned the repository.
cd camera_driver
-
Uninstall the package: Uninstall using the following command:
cd build/ sudo make uninstall
Here's a basic example of how to use the Camera Driver Library:
#include <iostream>
#include <stdexcept>
#include <camera_driver/camera.h>
int main() {
// Create a Camera instance
Camera camera("Camera", "USB", 0, 60);
// Get camera specs
CameraInfo cameraInfo = camera.GetCameraSpecs();
// Print camera info
std::cout << "Camera Info:" << std::endl;
std::cout << "Name: " << cameraInfo.name << std::endl;
std::cout << "Type: " << cameraInfo.type << std::endl;
std::cout << "Index: " << cameraInfo.index << std::endl;
std::cout << "FPS: " << cameraInfo.fps << std::endl;
try
{
cv::VideoCapture videoCapture(0);
while (true)
{
// Capture a frame from the camera (assuming the camera is at index 0)
cv::Mat frame = camera.CaptureFrame(videoCapture, cameraInfo.index);
// Display the captured frame for 5 seconds
camera.DisplayFrame("Camera Feed", frame);
}
}
catch(std::exception &e)
{
std::cout << "Caught Exception: " << e.what() << std::endl;
}
return 0;
}
This example demonstrates the basic usage of the Camera Driver Library, capturing frames from a camera and displaying a video stream.
- Julian Rendon
- Email: julianrendon514@gmail.com