KtLibProc.cpp
4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "JZsdkLib.h"
#include "../IRC_data_deal/IRC_data_deal.h"
#include <vector>
#include "KTv330_CPP.h"
#include "MediaProc/MediaProc_Param.h"
#include "KtLibProc.h"
#include "MediaProc/ImageProc/PseudoColor/PseudoColor.h"
#include "../IRC_Param.h"
// 创建一个 ClassKT 类对象
KTv330Space::ClassKT* KtObject = new KTv330Space::ClassKT();
T_JZsdkReturnCode KtLib_DataDeal(U16_t* U16_data, unsigned int U16_dataSize,
U8_t **RGB_data, unsigned int *RGB_dataSize,
struct IRC_param *dealInfo)
{
T_JZsdkReturnCode ret;
// 创建一个存储转换后数据的 vector<int>
std::vector<int> inputDataVector(U16_data, U16_data + U16_dataSize);
// 创建一个用于保存校正数据的
std::vector<int> currentDataVector = inputDataVector;
//JZSDK_LOG_INFO("校正前1:%d 2:%d 3:%d 4:%d",currentDataVector[5000],currentDataVector[15000],currentDataVector[30000],currentDataVector[45000]);
// 如果打开了单点校正
if (dealInfo->FrameCorrectMode == IRC_CORRCTION_SPC)
{
// 创建一个用于放置spc的数据
U16_t *dataPtr = NULL;
if (dealInfo->SPC_mode == 0 && dealInfo->LowT_NineFrame_Avg != NULL) // 低温打档
{
//JZSDK_LOG_INFO("正在用低温数据");
dataPtr = (U16_t *)dealInfo->LowT_NineFrame_Avg;
}
else
{
//JZSDK_LOG_INFO("正在用标记数据");
dataPtr = (U16_t *)dealInfo->SPC_Mark_Data;
}
// 使用 std::span 来避免不必要的拷贝
std::vector<int> spcMarkDataVector(dataPtr, dataPtr + dealInfo->PixelNum);
//JZSDK_LOG_INFO("dataPtr 1:%d 2:%d 3:%d 4:%d",dataPtr[5000],dataPtr[15000],dataPtr[30000],dataPtr[45000]);
bool retSPC = KtObject->KT_V330_CPP_supportFun_SPC(currentDataVector, inputDataVector, spcMarkDataVector, dealInfo->ImgDataBits);
if (retSPC == false)
{
printf("SPC失败\n");
}
}
//JZSDK_LOG_INFO("校正后1:%d 2:%d 3:%d 4:%d",currentDataVector[5000],currentDataVector[15000],currentDataVector[30000],currentDataVector[45000]);
// 如果打开了两点校正
if (dealInfo->FrameCorrectMode == IRC_CORRCTION_TPC)
{
std::vector<int> highDataVector(dealInfo->HighT_NineFrame_Avg, dealInfo->HighT_NineFrame_Avg + dealInfo->PixelNum);
std::vector<int> lowDataVector(dealInfo->LowT_NineFrame_Avg, dealInfo->LowT_NineFrame_Avg + dealInfo->PixelNum);
currentDataVector = KtObject->ifTPC(inputDataVector, lowDataVector, highDataVector, (unsigned short)dealInfo->ImgDataBits);
}
std::vector<unsigned char> outVector;
// 调用 KT_V330_CPP_supportFun_Histogram_vKT 进行直方图均衡化处理 得到灰度图
KtObject->KT_V330_CPP_supportFun_Histogram_vKT(outVector, currentDataVector, dealInfo->ImgDataBits, dealInfo->Gain, dealInfo->LeftDrop, dealInfo->RightDrop);
// 将vector灰度图转换为 数组灰度图
U8_t *GrayImage = (U8_t *)malloc(sizeof(U8_t) * dealInfo->PixelNum);
std::copy(outVector.begin(), outVector.end(), GrayImage);
// 图像输出模式
switch (dealInfo->OutputPixelColorMode)
{
case 0: // 默认输出模式
{
// 灰度图转rgb888
IRC_GrayTo_RGB(GrayImage, RGB_data, RGB_dataSize, dealInfo);
}
break;
case 1: // 伪彩输出模式
{
// 灰度图转伪彩rgb888
ret = PseudoColor_Gray2Rgb(GrayImage, RGB_data, RGB_dataSize, dealInfo->PixelNum);
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
IRC_GrayTo_RGB(GrayImage, RGB_data, RGB_dataSize, dealInfo);
}
}
break;
case 2: // 气体色彩增强输出模式
{
// 转为rgb
IRC_GrayTo_RGB(GrayImage, RGB_data, RGB_dataSize, dealInfo);
// 灰度图转气体增强rgb888
IRC_DynamicGasesColorEnhance(*RGB_data, U16_data, dealInfo);
}
break;
default:
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
break;
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
T_JZsdkReturnCode KtLib_Init()
{
KtObject->KT_M330_InfraredLogin("192.168.1.3", 6666, "192.168.1.2", 6666, 320, 256, 14, NULL, 0, 0);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}