Overview
The DenoiserJetPack C++ library implements noise cancellation algorithm based on Nvidia VPI. This library is suitable for various types of camera (daylight, SWIR, MWIR and LWIR) and it provides simple programming interface. Each instance of the DenoiserJetPack C++ class object performs frame-by-frame processing of a video data stream, processing each video frame independently. DenoiserJetPack library at the moment supports only YUV24 pixel format. The library depends on VFilter library (provides interface for video filter, source code included, Apache 2.0 license) and Nvidia VPI API. Also test application and example depend on OpenCV library (version >= 4.5, linked, Apache 2.0 license). The library utilizes C++17 standard.
Downloads
Documentation: GO TO DOCUMENTATION
Simple interface
class DenoiserJetPack : public VFilter
{
public:
/// Get the version of the DenoiserJetPack class.
static std::string getVersion();
/// Initialize DenoiserJetPack.
bool initVFilter(VFilterParams& params) override;
/// Set VFilter parameter.
bool setParam(VFilterParam id, float value) override;
/// Get the value of a specific VFilter parameter.
float getParam(VFilterParam id) override;
/// Get the structure containing all VFilter parameters.
void getParams(VFilterParams& params) override;
/// Execute a VFilter action command.
bool executeCommand(VFilterCommand id) override;
/// Process frame.
bool processFrame(cr::video::Frame& frame) override;
/// Set mask for filter. Not supported.
bool setMask(cr::video::Frame mask) override;
/// Decode and execute command.
bool decodeAndExecuteCommand(uint8_t* data, int size) override;
};
Simple example
#include <iostream>
#include <cstdint>
#include <opencv2/opencv.hpp>
#include "DenoiserJetPack.h"
using namespace cv;
using namespace std;
using namespace cr::video;
int main(void)
{
cout << "DenoiserJetPack v" << DenoiserJetPack::getVersion() << endl;
// Prepare filter params.
VFilterParams params;
params.mode = 1; // Enable filter.
params.level = 80; // %80 filter strength.
params.type = 1; // Outdoor low light
params.custom1 = 0; // VIC backend.
// Create and init denoiser.
DenoiserJetPack denoiser;
if (!denoiser.initVFilter(params))
return -1;
// Open video file.
VideoCapture capture("test.mp4");
if (!capture.isOpened())
return -1;
int width = capture.get(CAP_PROP_FRAME_WIDTH);
int height = capture.get(CAP_PROP_FRAME_HEIGHT);
cr::video::Frame frame(width, height, cr::video::Fourcc::YUV24);
// Main loop.
Mat bgrMat;
while(true)
{
// Capture frame.
capture >> bgrMat;
if (bgrMat.empty())
break;
cv::Mat yuvMat(height, width, CV_8UC3, frame.data);
// Convert to YUV.
cvtColor(bgrMat, yuvMat, COLOR_BGR2YUV);
// Denoise.
denoiser.processFrame(frame);
// Convert back to BGR to display.
cvtColor(yuvMat, bgrMat, COLOR_YUV2BGR);
// Display.
imshow("Denoised Frame", bgrMat);
if (waitKey(1) == 27)
break;
}
return 1;
}