Dehazer C++ lib. Fast video dehaze/defog algorithm
Dehazer C++ library version 2.0.3 implements video dehazing algorithm based on histogram manipulations. The library utilizes different histogram manipulations to improve the contrast of the video frame and to reduce the effect of haze.
LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free 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.
Dehazer C++ library version 2.0.3 implements video dehazing algorithm based on histogram manipulations. The library utilizes different histogram manipulations to improve the contrast of the video frame and to reduce the effect of haze.
LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free 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.
Dehazer C++ library version 2.0.3 implements video dehazing algorithm based on histogram manipulations. The library utilizes different histogram manipulations to improve the contrast of the video frame and to reduce the effect of haze.
LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free 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.
Overview
Dehazer C++ library implements video defog / dehaze algorithm based on histogram manipulations. The library utilizes different histogram manipulations to improve the contrast of the video frame and to reduce the effect of haze. The library is implemented in C++ (C++17 standard) and exclusively relies on OpenCV library (version 4.5.0 and higher). This library is suitable for various types of camera (daylight, SWIR, MWIR and LWIR) and it provides simple programming interface. Each instance of the Dehazer C++ class object performs frame-by-frame processing of a video data stream, processing each video frame independently. The library depends on open source VFilter library (provides interface as well as defines data structures for various video filters implementation, source code included, Apache 2.0 license) and OpenCV library (version >=4.5.0, linked, Apache 2.0 license). Additionally demo application depends on open source SimpleFileDialog (provides dialog to open files, source code included, Apache 2.0 license).
Performance
The library uses only one CPU core for processing. Processing time per fame for different CPU platforms (processing time / frame):
- Intel(TM) i7-13700H : 4096x2160 - 8.5 msec, 1920x1080 - 2.5 msec, 1280x720 - 0.9 msec, 640x360 - 0.27 msec.
- Raspberry Pi 5 : 4096x2160 - 23.1 msec, 1920x1080 - 4.9 msec, 1280x720 - 1.9 msec, 640x360 - 0.55 msec.
- Raspberry Pi 4B : 4096x2160 - 44.1 msec, 1920x1080 - 10.1 msec, 1280x720 - 4.5 msec, 640x360 - 0.9 msec.
VFilter compatible interface
namespace cr
{
namespace video
{
class Dehazer : public VFilter
{
public:
/// Class constructor.
Dehazer();
/// Class destructor.
~Dehazer();
/// Get string of current library version.
static std::string getVersion();
/// Initialize video filter.
bool initVFilter(VFilterParams& params) override;
/// Set parameter.
bool setParam(VFilterParam id, float value) override;
/// Get parameter value.
float getParam(VFilterParam id) override;
/// Get all library parameters.
void getParams(VFilterParams& params) override;
/// Execute action command.
bool executeCommand(VFilterCommand id) override;
/// Process frame.
bool processFrame(Frame& frame) override;
/// Set mask for the filter.
bool setMask(cr::video::Frame mask) override;
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
};
}
}
Simple example
#include <iostream>
#include <opencv2/opencv.hpp>
#include "Dehazer.h"
int main(void)
{
// Open video source.
cv::VideoCapture source;
if (!source.open("test.mp4"))
return -1;
// Init dehazer and set initial params.
cr::video::Dehazer dehazer;
dehazer.setParam(cr::video::VFilterParam::TYPE, 1);
dehazer.setParam(cr::video::VFilterParam::LEVEL, 30);
// Get frame size.
int width = (int)source.get(cv::CAP_PROP_FRAME_WIDTH);
int height = (int)source.get(cv::CAP_PROP_FRAME_HEIGHT);
// Init frames.
cv::Mat openCvBgrImg(height, width, CV_8UC3);
cr::video::Frame frame(width, height, cr::video::Fourcc::YUV24);
// Main loop.
while (true)
{
// Capture next video frame.
source >> openCvBgrImg;
if (openCvBgrImg.empty())
return 0;
// Convert BGR to YUV.
cv::Mat yuvImg(frame.height, frame.width, CV_8UC3, frame.data);
cvtColor(openCvBgrImg, yuvImg, cv::COLOR_BGR2YUV);
// Dehaze.
dehazer.processFrame(frame);
// Convert YUV to BGR.
cvtColor(yuvImg, openCvBgrImg, cv::COLOR_YUV2BGR);
// Show results.
imshow("Result", openCvBgrImg);
if (cv::waitKey(1) == 27)
return 0;
}
return 1;
}