121 lines
4.9 KiB
C++
121 lines
4.9 KiB
C++
#ifndef POINTCLOUDIMAGEUTILS_H
|
|
#define POINTCLOUDIMAGEUTILS_H
|
|
|
|
#include <QImage>
|
|
#include <QColor>
|
|
#include <vector>
|
|
#include <utility> // for std::pair
|
|
|
|
#include "VZNL_Types.h"
|
|
|
|
// 简单的颗粒信息结构 - 避免依赖OpenCV
|
|
struct SimpleParticleInfo {
|
|
SVzNL3DPoint vertix[8]; // 8个顶点
|
|
struct {
|
|
double width;
|
|
double height;
|
|
} size;
|
|
};
|
|
|
|
// 通用检测目标结构体 - 替代算法SDK的 SSG_peakRgnInfo
|
|
struct DetectionTargetInfo {
|
|
struct {
|
|
double x;
|
|
double y;
|
|
double z_yaw; // 偏航角(度)
|
|
} centerPos;
|
|
|
|
struct {
|
|
double dWidth;
|
|
double dHeight;
|
|
} objSize;
|
|
|
|
int orienFlag = 0; // 朝向标记: 0=无, 1=正面, 2=反面
|
|
};
|
|
|
|
class PointCloudImageUtils
|
|
{
|
|
public:
|
|
// 点云转图像 - 使用通用检测目标结构体
|
|
static QImage GeneratePointCloudImage(SVzNL3DLaserLine* scanData,
|
|
int lineNum,
|
|
const std::vector<DetectionTargetInfo>& objOps);
|
|
|
|
static QImage GeneratePointCloudImage(SVzNLXYZRGBDLaserLine* scanData,
|
|
int lineNum,
|
|
const std::vector<DetectionTargetInfo>& objOps);
|
|
|
|
// 新的点云图像生成函数 - 基于X、Y范围创建图像
|
|
static QImage GeneratePointCloudImage(SVzNLXYZRGBDLaserLine* scanData,
|
|
int lineNum);
|
|
|
|
// LapWeld点云和检测结果转图像 - 基于scan lines格式
|
|
static QImage GeneratePointCloudImage(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
const std::vector<std::vector<SVzNL3DPoint>>& weldResults,
|
|
int imageWidth = 800, int imageHeight = 600);
|
|
|
|
// Workpiece点云和角点检测结果转图像 - 将角点画成圆点
|
|
static QImage GeneratePointCloudRetPointImage(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
const std::vector<std::vector<SVzNL3DPoint>>& cornerPoints,
|
|
double margin = 0.0);
|
|
|
|
// ParticleSize点云和颗粒检测结果转图像 - 生成带颗粒标记的点云图像 (直接返回QImage)
|
|
static QImage GeneratePointCloudImageWithParticles(
|
|
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
const std::vector<SimpleParticleInfo>& particles,
|
|
int cameraIndex);
|
|
|
|
// WheelMeasure点云和轮眉检测结果转图像 - 生成带轮眉标记的点云图像
|
|
static QImage GenerateWheelArchImage(
|
|
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
const SVzNL3DPoint& wheelArchPos,
|
|
const SVzNL3DPoint& wheelUpPos,
|
|
const SVzNL3DPoint& wheelDownPos,
|
|
double archToCenterHeight,
|
|
bool hasResult = true);
|
|
|
|
// 从检测数据缓存生成深度图像
|
|
static int GenerateDepthImage(
|
|
const std::vector<std::pair<EVzResultDataType, SVzLaserLineData>>& detectionDataCache,
|
|
QImage& outImage);
|
|
|
|
private:
|
|
// 定义线特征颜色和大小获取函数
|
|
static void GetLineFeatureStyle(int vType, int hType, int objId,
|
|
QColor& pointColor, int& pointSize);
|
|
|
|
// 获取对象颜色
|
|
static QColor GetObjectColor(int index);
|
|
|
|
// 计算点云范围
|
|
static void CalculatePointCloudRange(SVzNL3DLaserLine* scanData, int lineNum,
|
|
double& xMin, double& xMax,
|
|
double& yMin, double& yMax);
|
|
|
|
// 计算scan lines格式点云的范围
|
|
static void CalculateScanLinesRange(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
double& xMin, double& xMax,
|
|
double& yMin, double& yMax);
|
|
|
|
// 绘制LapWeld检测结果
|
|
static void DrawLapWeldResults(QPainter& painter,
|
|
const std::vector<std::vector<SVzNL3DPoint>>& weldResults,
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
int imageWidth, int imageHeight);
|
|
|
|
// 绘制scan lines点云数据
|
|
static void DrawScanLinesPointCloud(QPainter& painter,
|
|
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
int imageWidth, int imageHeight);
|
|
|
|
// 绘制检测目标(使用通用结构体)
|
|
static void DrawDetectionTargets(QPainter& painter,
|
|
const std::vector<DetectionTargetInfo>& objOps,
|
|
double xMin, double xScale, int xSkip,
|
|
double yMin, double yScale, int ySkip,
|
|
int imgCols, int imgRows);
|
|
};
|
|
|
|
#endif // POINTCLOUDIMAGEUTILS_H
|