VSourceOpenCv C++ lib. Video capture and video source control based on OpenCV
VSourceOpenCv C++ library version 2.0.4 provides video capture based on OpenCV library (version >=4.5).
We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE. You can buy technical support service for this product.
VSourceOpenCv C++ library version 2.0.4 provides video capture based on OpenCV library (version >=4.5).
We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE. You can buy technical support service for this product.
VSourceOpenCv C++ library version 2.0.4 provides video capture based on OpenCV library (version >=4.5).
We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE. You can buy technical support service for this product.
Purchase options
You can buy the software by bank transfer. Bank transfer available only for companies. To buy software by bank transfer please send us request to info@constantrobotics.com. Also, you can buy technical support service for this product.
Downloads
Programmer’s manual: DOWNLOAD
Overview
VSourceOpenCv C++ library provides video capture and video source control function based on OpenCV library (version >=4.5). It provides simple interface for video capture from video files (*.mp4, *.avi, *.mov, *.wmv, *.flv, *.swf, *.f4v and *.webm), video streams (rtp, rtsp, http) and UVC (Universal Video Class) compatible devices (e.g. web cameras) or other devices supported by OpenCV. The library supports automatic reconnection to the video source in case of connection loss. The library also plays video files continuously (starts over when playback ends). The library supports BGR24 output video frame pixel format and H264, HEVC, JPEG for video streams (configurable by user). The library inherits interface from open source VSource interface class. VSource.h file contains data structures VSourceParams class (contains video source params and provides methods for serialization/deserialization params), VSourceCommand enum (describes video source action commands), VSourceParam enum (describes video source params) and includes VSourceOpenCv class declaration. VSourceOpenCv depends on: OpenCV (version >=4.5, linked, Apache 2.0 license), VSource interface class (provides interface for video sources, source code included, Apache 2.0 license) and open source Logger library (provides method to write logs, source code included, Apache 2.0 license). The library supports C++17 standard.
Simple interface
namespace cr
{
namespace video
{
/// Video source class based on OpenCV.
class VSourceOpenCv : public VSource
{
public:
/// Class constructor.
VSourceOpenCv();
/// Class destructor.
~VSourceOpenCv();
/// Get string of current library version.
static std::string getVersion();
/// Open video source.
bool openVSource(std::string& initString) override;
/// Init video source.
bool initVSource(VSourceParams& params) override;
/// Get open status.
bool isVSourceOpen() override;
/// Close video source.
void closeVSource() override;
/// Get new video frame.
bool getFrame(Frame& frame, int32_t timeoutMsec = 0) override;
/// Set video source param.
bool setParam(VSourceParam id, float value) override;
/// Get video source param value.
float getParam(VSourceParam id) override;
/// Get video source params structure.
void getParams(VSourceParams& params) override;
/// Execute command.
bool executeCommand(VSourceCommand id) override;
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
};
}
}
Simple example
#include <iostream>
#include "VSourceOpenCv.h"
int main(void)
{
// Open video source.
cr::video::VSource* source = new cr::video::VSourceOpenCv();
std::string initString = "0;640;480";
if (!source->openVSource(initString))
return -1;
cr::video::Frame frame;
while (true)
{
// Wait new frame 1000 msec.
if (!source->getFrame(frame, 1000))
continue;
// Get current params.
cr::video::VSourceParams params;
source->getParams(params);
// Display cycle time.
cv::Mat openCvFrame(frame.height, frame.width, CV_8UC3, frame.data);
cv::putText(openCvFrame, "Frame ID " + std::to_string(frame.frameId) +
" Cycle time " + std::to_string(params.cycleTimeMks / 1000) + " msec.",
cv::Point(5, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1);
// Show frame with OpenCV.
cv::imshow("VIDEO", openCvFrame);
if (cv::waitKey(1) == 27)
break;
}
return 1;
}