Overview
The I3Camera C++ library is a video capture and software controller for THERMAL EXPERT cameras. The I3Camera library supports Q1, Q2, V1, V2, EQ1, EQ2, EV1 and EV2 USB camera models. The library inherits interfaces from VSource and Camera. It depends on libraries: VSource (provides interface and data structures to capture video from cameras, source code included, Apache 2.0 license), Camera (provides interface and data structures to control cameras, source code, Apache 2.0 license), Logger (provides function to print logs, source code included, Apache 2.0 license). The I3Camera library provides simple interface to be integrated in any C++ projects. The library depends on i3camera SDK that provides communication with camera via an USB port. Additionally test application depends on OpenCV. It is developed with C++17 standard and compatible with Linux and Windows.
Documentation
Documentation: GO TO DOCUMENTATION
Camera + video capture interface
class I3Camera : public VSource, public cr::camera::Camera
{
public:
/// Get version of the library.
static std::string getVersion();
/// Detect available cameras.
static std::vector<std::string> detectAvailableCameras();
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t *data, int size) override;
// #######################################
// VIDEO SOURCE INTERFACE
// #######################################
/// Open video source by initialization string.
bool openVSource(std::string &initString) override;
/// Init video source by parameters structure.
bool initVSource(VSourceParams ¶ms) override;
/// Check if video source is open.
bool isVSourceOpen() override;
/// Close video source.
void closeVSource() override;
/// Get video source frame.
bool getFrame(Frame &frame, int32_t timeoutMsec = 0) override;
/// Set video source parameter.
bool setParam(VSourceParam id, float value) override;
/// Get video source parameter.
float getParam(VSourceParam id) override;
/// Get video source params.
void getParams(VSourceParams ¶ms) override;
/// Execute video source command.
bool executeCommand(VSourceCommand id) override;
// #######################################
// CAMERA CONTROL INTERFACE
// #######################################
/// Open camera controller by initialization string.
bool openCamera(std::string initString) override;
/// Init camera controller by parameters structure.
bool initCamera(cr::camera::CameraParams ¶ms) override;
/// Close camera controller.
void closeCamera() override;
/// Check if camera controller is open.
bool isCameraOpen() override;
/// Check if camera controller is connected.
bool isCameraConnected() override;
/// Set camera parameter.
bool setParam(cr::camera::CameraParam id, float value) override;
/// Get camera parameter.
float getParam(cr::camera::CameraParam id) override;
/// Get camera params.
void getParams(cr::camera::CameraParams ¶ms) override;
/// Execute camera command.
bool executeCommand(cr::camera::CameraCommand id) override;
};
Simple example
#include <iostream>
#include <opencv2/opencv.hpp>
#include "I3Camera.h"
int main()
{
auto availableCameras = cr::video::I3Camera::detectAvailableCameras();
std::string cameraId = availableCameras[0]; // Get first camera id.
cr::video::I3Camera i3Camera;
if (!i3Camera.openVSource(cameraId))
{
std::cerr << "Camera can't open." << std::endl;
return -1;
}
if (!i3Camera.setParam(cr::video::VSourceParam::LOG_LEVEL, 0))
{
std::cerr << "Log level setting failed." << std::endl;
return -1;
}
cr::video::Frame sourceFrame;
while (true)
{
if (!i3Camera.getFrame(sourceFrame))
{
std::cerr << "No frame from camera." << std::endl;
continue;
}
// Get frame time in us.
float cycleTimeUs = i3Camera.getParam(cr::video::VSourceParam::CYCLE_TIME_MKS);
float fps = 1000000.0f / cycleTimeUs;
// Gray scale image.
cv::Mat showFrame(sourceFrame.height, sourceFrame.width, CV_8UC1, sourceFrame.data);
// Draw cycle time on the image.
cv::putText(showFrame, "FPS : " + std::to_string(int(fps)), cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1);
// Display the grayscale image.
cv::imshow("Gray Frame", showFrame);
// Wait for a key press.
cv::waitKey(33);
}
return 0;
}