点阵完成,加入opencv
This commit is contained in:
49
src/globalhelper.h
Normal file
49
src/globalhelper.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Created by Lenn on 2026/1/20.
|
||||
//
|
||||
|
||||
#ifndef TACTILEIPC3D_GLOBALHELPER_H
|
||||
#define TACTILEIPC3D_GLOBALHELPER_H
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
class GlobalHelper {
|
||||
public:
|
||||
const std::string fuck = "fuck you lsp!!!";
|
||||
static GlobalHelper* Instance() {
|
||||
static GlobalHelper ins;
|
||||
return &ins;
|
||||
}
|
||||
|
||||
static void transToMultiMatrix(const cv::Mat& raw_data, float min_threshold,
|
||||
float max_range, cv::Size display_res, cv::Mat& out_image) {
|
||||
CV_Assert(raw_data.type() == CV_32F);
|
||||
|
||||
cv::Mat raw = raw_data.clone();
|
||||
raw.setTo(0.0f, raw < min_threshold);
|
||||
|
||||
double maxVal = 0.0;
|
||||
cv::minMaxLoc(raw, nullptr, &maxVal);
|
||||
if (maxVal > 0.0) {
|
||||
cv::GaussianBlur(raw, raw, cv::Size(3, 3), 0.8, 0.8, cv::BORDER_DEFAULT);
|
||||
}
|
||||
|
||||
cv::Mat norm_data = raw / max_range;
|
||||
cv::min(norm_data, 1.0f, norm_data);
|
||||
cv::max(norm_data, 0.0f, norm_data);
|
||||
|
||||
cv::pow(norm_data, 0.7, norm_data);
|
||||
|
||||
cv::Mat smoothed;
|
||||
cv::resize(norm_data, smoothed, display_res, 0.0, 0.0, cv::INTER_CUBIC);
|
||||
|
||||
cv::GaussianBlur(smoothed, smoothed, cv::Size(31, 31), 0.0, 0.0, cv::BORDER_DEFAULT);
|
||||
|
||||
cv::transpose(smoothed, out_image);
|
||||
}
|
||||
private:
|
||||
GlobalHelper() {}
|
||||
};
|
||||
|
||||
#endif //TACTILEIPC3D_GLOBALHELPER_H
|
||||
Reference in New Issue
Block a user