You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.4 KiB

#ifndef COLORCOMPARISONBFACE_H
#define COLORCOMPARISONBFACE_H
#include <string>
#include <vector>
#include <map>
#include <opencv2/opencv.hpp>
// 不使用前向声明,直接定义简单的颜色结构
struct MeshColor {
unsigned char r, g, b;
MeshColor() : r(0), g(0), b(0) {}
MeshColor(unsigned char r, unsigned char g, unsigned char b)
: r(r), g(g), b(b) {}
unsigned char operator[](size_t idx) const {
if (idx == 0) return r;
if (idx == 1) return g;
if (idx == 2) return b;
return 0;
}
};
class ColorComparisonFace {
private:
struct FaceColorInfo {
int faceId; // 面的ID
MeshColor gaussianColor; // 高斯颜色
MeshColor originalColor; // 原始颜色
cv::Mat triangleRegion; // 带透明通道的三角形区域
cv::Mat visualization; // 三角形可视化图像
float colorDistance; // 颜色距离
float threshold; // 阈值
std::string filename; // 文件名
};
// 使用嵌套map: faceid -> filename -> FaceColorInfo列表
std::map<int, std::map<std::string, std::vector<FaceColorInfo>>> faceViewColorMap;
std::string outputDir;
public:
// 构造函数
ColorComparisonFace(const std::string& dir);
// 析构函数
virtual ~ColorComparisonFace() {}
// 添加精确三角形信息(替代原来的addColorInfo)
void addExactTriangleInfo(int faceId,
MeshColor gaussianColor,
MeshColor originalColor,
const cv::Mat& triangleRegionWithAlpha, // 带透明通道
const cv::Mat& visualization, // 可视化图像
float colorDistance,
float threshold,
const std::string& filename);
// 创建三角形区域对比图
void createBatchComparison(int maxBlocksPerRow = 6, int maxFacesPerImage = 20);
// 保存颜色信息到CSV文件
void saveColorInfoToFile();
// 获取总face数
int getTotalFaces() const;
// 获取总记录数
int getTotalRecords() const;
// 获取faceid列表
std::vector<int> getFaceIds() const;
};
#endif // COLORCOMPARISONBFACE_H