增加自动图像校正测试项

This commit is contained in:
luoliangyi 2024-06-21 16:43:36 +08:00
parent ca0cc40cf6
commit 39333c4d33
6 changed files with 922 additions and 12 deletions

View File

@ -0,0 +1,508 @@
#include "correctProcess.h"
#include <opencv2/core/types_c.h>
#include <opencv2/core/core_c.h>
#include <opencv2/imgproc/imgproc_c.h>
#include <iostream>
#include <fstream>
bool getMeanColors(const cv::Mat& image, std::vector<std::vector<uchar>>& colors)
{
std::vector<std::vector<int>> sections;
cv::Mat resizeMat(image.rows, 2, CV_8UC1);
cv::resize(image(cv::Rect(0, 0, 10, image.rows)), resizeMat(cv::Rect(0, 0, 1, image.rows)), cv::Size(1, image.rows));
cv::resize(image(cv::Rect(image.cols - 11, 0, 10, image.rows)), resizeMat(cv::Rect(1, 0, 1, image.rows)), cv::Size(1, image.rows));
for (int i = 0; i < resizeMat.cols; i++)
{
cv::Mat col = resizeMat(cv::Rect(i, 0, 1, resizeMat.rows)).clone();
std::vector<int> section;
uchar* ptr = col.data;
int thre = 55;
for (int j = 2, rows = col.rows - 2; j < rows; j++)
{
if (abs(ptr[j - 2] - ptr[j + 2]) > thre)
{
if (section.size() > 1)
{
if (j - *(section.end() - 1) < 15)
continue;
}
else if (section.size() == 1)
if (j - section[0] < 50)
continue;
section.push_back(j);
j += 5;
}
}
if (section.size() < 53)
return false;
section.erase(section.begin());
sections.push_back(section);
}
std::vector<double> steps;
for (int i = 0, length = 52; i < length; i++)
steps.push_back(static_cast<double>(sections[1][i] - sections[0][i]) / (image.cols - 1));
for (int i = 0; i < image.cols; i++)
{
cv::Mat col = image(cv::Rect(i, 0, 1, image.rows)).clone();
std::vector<uchar> section_color;
for (size_t j = 0; j < 52; j += 2)
{
int top = sections[0][j] + i * steps[j] + 5;
int bottom = sections[0][j + 1] + i * steps[j + 1] - 5;
if (bottom <= top)
return false;
section_color.push_back(cv::mean(col(cv::Rect(0, top, 1, bottom - top + 1)))[0]);
}
for (size_t j = 1; j < section_color.size() - 1; j++)
if (section_color[j] < section_color[j - 1] || section_color[j] > section_color[j + 1])
section_color[j] = (int)(section_color[j - 1] + section_color[j + 1]) / 2;
colors.push_back(section_color);
}
return true;
}
bool calTable(const cv::Mat& image, uchar* lut_data, int blackLevel, char* data)
{
std::vector<std::vector<uchar>> colors;
if (!getMeanColors(image, colors))
return false;
int level = blackLevel;
#if 1
int index = 0;
for (size_t i = 0; i < colors.size(); i++)
for (size_t j = 0, length = colors[i].size(); j < length; j++)
{
data[index] = colors[i][j];
index++;
}
#endif
for (int i = 0; i < colors.size(); i++)
for (int j = 0; j < level; j++)
colors[i].erase(colors[i].begin());
double ss = 250.0 / (colors[0].size() - 1);
for (int i = 0, length = image.cols; i < length; i++)
{
uchar* ptr = lut_data + 256 * i;
memset(ptr, 255, 256);
memset(ptr, 0, 100);
for (int y = 1; y < colors[i].size(); y++)
{
int index_0 = colors[i][y - 1];
int index_1 = colors[i][y];
double value_0 = (y - 1) * ss;
double value_1 = cv::min(y * ss, 255.0);
double step = (double)(value_1 - value_0) / (double)(index_1 - index_0);
for (int x = index_0; x < index_1; x++)
ptr[x] = cv::min((int)(value_0 + (x - index_0) * step), 255);
}
}
return true;
}
cv::Mat createTable(const cv::Mat& image, int blackLevel, char* data)
{
cv::Mat grey(image.rows, image.cols * image.channels(), CV_8UC1, image.data);
cv::Mat lut_data(grey.cols, 256, CV_8UC1);
if (!calTable(grey, lut_data.data, blackLevel, data))
return cv::Mat();
const int channels = (lut_data.rows % 408 == 0) ? 408 : 432;
for (size_t i = 0, block = lut_data.rows / channels; i < block; i++)
{
cv::Mat lutROI = lut_data(cv::Rect(0, i * channels, 256, channels));
cv::Mat tran;
cv::transpose(lutROI, tran);
memcpy(lutROI.data, tran.data, tran.total());
}
return lut_data;
}
int mean(const cv::Mat& image, const cv::Mat& mask)
{
cv::Mat mask1, mask2;
cv::threshold(image, mask1, 127, 255, cv::THRESH_BINARY);
mask2 = (~mask1) & mask;
mask1 &= mask;
double num1 = cv::sum(mask1)[0] / 255;
double num2 = cv::sum(mask2)[0] / 255;
double sum1 = cv::sum(mask1 & image)[0];
double sum2 = cv::sum(mask2 & image)[0];
if (num1 == 0 && num2 == 0)
return 0;
else if (num1 == 0 && num2 != 0)
return sum2 / num2;
else if (num1 != 0 && num2 == 0)
return sum1 / num1;
else if (abs(sum1 / num1 - sum2 / sum2) < 200)
return (sum1 + sum2) / (num1 + num2);
else
return (sum1 + sum2 + num2 * 255) / (num1 + num2);
}
void myFindContours(const cv::Mat& src, std::vector<std::vector<cv::Point>>& contours, std::vector<cv::Vec4i>& hierarchy, int retr, int method, cv::Point offset)
{
CvMat c_image = cvMat(src);
cv::MemStorage storage(cvCreateMemStorage());
CvSeq* _ccontours = 0;
cvFindContours(&c_image, storage, &_ccontours, sizeof(CvContour), retr, method, cvPoint(offset.x, offset.y));
if (!_ccontours)
{
contours.clear();
return;
}
cv::Seq<CvSeq*> all_contours(cvTreeToNodeSeq(_ccontours, sizeof(CvSeq), storage));
int total = (int)all_contours.size();
contours.resize(total);
cv::SeqIterator<CvSeq*> it = all_contours.begin();
for (int i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
((CvContour*)c)->color = (int)i;
int count = (int)c->total;
int* data = new int[count * 2];
cvCvtSeqToArray(c, data);
for (int j = 0; j < count; j++)
{
contours[i].push_back(cv::Point(data[j * 2], data[j * 2 + 1]));
}
delete[] data;
}
hierarchy.resize(total);
it = all_contours.begin();
for (int i = 0; i < total; i++, ++it)
{
CvSeq* c = *it;
int h_next = c->h_next ? ((CvContour*)c->h_next)->color : -1;
int h_prev = c->h_prev ? ((CvContour*)c->h_prev)->color : -1;
int v_next = c->v_next ? ((CvContour*)c->v_next)->color : -1;
int v_prev = c->v_prev ? ((CvContour*)c->v_prev)->color : -1;
hierarchy[i] = cv::Vec4i(h_next, h_prev, v_next, v_prev);
}
storage.release();
}
void myFillPolys(cv::Mat& image, const std::vector<std::vector<cv::Point>>& contours, const cv::Scalar& color)
{
if (contours.empty()) return;
size_t count = contours.size();
cv::Point** pointss = new cv::Point * [count];
int* npts = new int[count];
for (size_t i = 0; i < count; i++)
{
size_t length = contours[i].size();
npts[i] = length;
pointss[i] = new cv::Point[length];
for (size_t j = 0; j < length; j++)
pointss[i][j] = contours[i][j];
}
cv::fillPoly(image, const_cast<const cv::Point**>(pointss), npts, count, color);
for (size_t i = 0; i < count; i++)
delete[] pointss[i];
delete[] pointss;
delete[] npts;
}
void createTable(const std::vector<double>& points_x, const std::vector<uchar>& points_y, uchar* table)
{
int table_temp[256]{};
for (size_t i = 0; i < points_x.size(); i++)
{
int current_index = static_cast<int>(points_x[i]);
if (current_index == 255)
current_index = 0;
if (current_index < 0)
current_index += 255;
int next_index = static_cast<int>(points_x[(i + 1) % points_x.size()]);
double low = points_y[i];
double up = points_y[(i + 1) % points_y.size()];
if (low == 255)
low = 0;
if (up < low)
up += 255;
if (next_index < current_index)
next_index += 256;
int length = next_index - current_index + 1;
double step = (up - low) / length;
for (int j = 0; j < length; j++)
table_temp[(j + current_index) % 256] = step * j + low;
for (size_t j = 0; j < 256; j++)
table[j] = table_temp[j] % 255;
}
}
cv::Mat createColorCastTable(const cv::Mat& image, const std::vector<uchar>& points_y)
{
cv::Mat resizeMat;
cv::resize(image, resizeMat, cv::Size(800, 800));
cv::Mat hsv, mv[3];
cv::cvtColor(resizeMat, hsv, cv::COLOR_BGR2HSV_FULL);
cv::split(hsv, mv);
cv::threshold(mv[1], mv[1], 80, 255, cv::THRESH_BINARY);
cv::threshold(mv[2], mv[2], 30, 255, cv::THRESH_BINARY);
cv::Mat mask = mv[1] & mv[2];
cv::erode(mask, mask, cv::Mat());
std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy;
myFindContours(mask, contours, hierarchy, 0, 2, cv::Point(-1, -1));
for (std::vector<std::vector<cv::Point>>::iterator iter = contours.begin(); iter != contours.end();)
if (cv::contourArea(*iter) < 400)
iter = contours.erase(iter);
else
iter++;
if (contours.size() < 12)
return cv::Mat();
for (size_t i = 0; i < contours.size() - 1; i++)
for (size_t j = i + 1; j < contours.size(); j++)
if (contours[j][0].x < contours[i][0].x)
std::swap(contours[j], contours[i]);
std::vector<double> points_x;
std::vector<std::vector<cv::Point>> contours_temp;
for (size_t i = 0; i < 12; i++)
{
contours_temp.clear();
contours_temp.push_back(contours[i]);
mask = cv::Mat::zeros(resizeMat.size(), CV_8UC1);
myFillPolys(mask, contours_temp, cv::Scalar::all(255));
int mean_value = mean(mv[0], mask);
if (mean_value >= 255)
mean_value -= 255;
points_x.push_back(mean_value);
}
if (points_x[0] + points_x[1] + points_x[2] > points_x[8] + points_x[9] + points_x[10])
std::reverse(points_x.begin(), points_x.end());
cv::Mat table(256, 1, CV_8UC1);
createTable(points_x, points_y, table.data);
return table;
}
void correctLUT(cv::Mat& image, const cv::Mat& lut)
{
cv::Mat image_temp(image.rows, image.step / lut.channels(), CV_8UC(lut.channels()), image.data);
for (size_t i = 0; i < image_temp.cols; i++)
cv::LUT(image_temp(cv::Rect(i, 0, 1, image_temp.rows)), lut(cv::Rect(0, i, 256, 1)), image_temp(cv::Rect(i, 0, 1, image_temp.rows)));
}
std::vector<cv::Mat> correctProcess(cv::Mat& image, int blackLevel, bool colorCastEnable, const std::vector<uchar>& referValues, int dpi, const std::string& path)
{
std::vector<cv::Mat> ret;
if (image.empty())
return ret;
char* data = new char[image.step * 26];
cv::Mat lut1 = createTable(image(cv::Rect(0, 0, image.cols / 2, image.rows)).clone(), blackLevel, data);
if (lut1.empty())
{
delete[] data;
return ret;
}
cv::Mat lut2 = createTable(image(cv::Rect(image.cols / 2, 0, image.cols / 2, image.rows)).clone(), blackLevel, data + image.step * 13);
if (lut2.empty())
{
delete[] data;
return ret;
}
std::ofstream file;
file.open(path + std::to_string(dpi) + (image.channels() == 3 ? "c" : "g") + ".dat", std::ios::binary | std::ios::out);
file.write(data, image.step * 26);
file.close();
delete[] data;
cv::Mat lut(lut1.rows + lut2.rows, 256, CV_8UC1);
lut1.copyTo(lut(cv::Rect(0, 0, 256, lut1.rows)));
lut2.copyTo(lut(cv::Rect(0, lut1.rows, 256, lut2.rows)));
ret.push_back(lut);
if (!blackLevel || image.channels() == 1)
return ret;
int channel = (lut.rows % 408 == 0) ? 408 : 432;
cv::Mat lutMat(lut.rows / channel, 256, CV_8UC(channel), lut.data);
correctLUT(image, lutMat);
cv::Mat colorCastTable = createColorCastTable(image(cv::Rect(0, 0, image.cols / 2, image.rows)), referValues);
ret.push_back(colorCastTable);
if (!colorCastTable.empty())
{
file.open(path + "cc" + std::to_string(dpi) + "f.dat", std::ios::binary | std::ios::out);
file.write((char*)colorCastTable.data, 256);
file.close();
}
colorCastTable = createColorCastTable(image(cv::Rect(image.cols / 2, 0, image.cols / 2, image.rows)), referValues);
ret.push_back(colorCastTable);
if (!colorCastTable.empty())
{
file.open(path + "cc" + std::to_string(dpi) + "b.dat", std::ios::binary | std::ios::out);
file.write((char*)colorCastTable.data, 256);
file.close();
}
return ret;
}
std::vector<cv::Mat> correctProcess(cv::Mat& image1, cv::Mat& image2, int blackLevel, bool colorCastEnable, const std::vector<uchar>& referValues, int dpi, const std::string& path)
{
std::vector<cv::Mat> ret;
char* data = new char[(image1.step + image2.step) * 26];
cv::Mat lut1 = createTable(image1, blackLevel, data);
if (lut1.empty())
return ret;
cv::Mat lut2 = createTable(image2, blackLevel, data);
if (lut2.empty())
return ret;
std::ofstream file;
file.open(path + std::to_string(dpi) + (image1.channels() == 3 ? "c" : "g") + ".dat", std::ios::binary | std::ios::out);
file.write(data, (image1.step + image2.step) * 26);
file.close();
delete[] data;
cv::Mat lut(lut1.rows + lut2.rows, 256, CV_8UC1);
lut1.copyTo(lut(cv::Rect(0, 0, 256, lut1.rows)));
lut2.copyTo(lut(cv::Rect(0, lut1.rows, 256, lut2.rows)));
ret.push_back(lut);
if (!blackLevel || image1.channels() == 1 || image2.channels() == 1)
return ret;
cv::Mat image(cv::max(image1.rows, image2.rows), image1.cols + image2.cols, CV_8UC3);
image1.copyTo(image(cv::Rect(0, 0, image1.cols, image1.rows)));
image2.copyTo(image(cv::Rect(image1.cols, 0, image2.cols, image2.rows)));
int channel = (lut.rows % 408 == 0) ? 408 : 432;
cv::Mat lutMat(lut.rows / channel, 256, CV_8UC(channel), lut.data);
correctLUT(image, lutMat);
cv::Mat colorCastTable = createColorCastTable(image(cv::Rect(0, 0, image.cols / 2, image.rows)), referValues);
ret.push_back(colorCastTable);
if (!colorCastTable.empty())
{
file.open(path + "cc" + std::to_string(dpi) + "f.dat", std::ios::binary | std::ios::out);
file.write((char*)colorCastTable.data, 256);
file.close();
}
colorCastTable = createColorCastTable(image(cv::Rect(image.cols / 2, 0, image.cols / 2, image.rows)), referValues);
ret.push_back(colorCastTable);
if (!colorCastTable.empty())
{
file.open(path + "cc" + std::to_string(dpi) + "b.dat", std::ios::binary | std::ios::out);
file.write((char*)colorCastTable.data, 256);
file.close();
}
return ret;
}
cv::Mat readZipCorrect(uchar* data, int len, int blackLevel)
{
std::vector<std::vector<uchar>> colors;
int index = 0, cols = len / 26;
cv::Mat lut(cols, 256, CV_8UC1);
for (size_t i = 0; i < cols; i++)
{
std::vector<uchar> color;
for (size_t j = 0; j < 26; j++, index++)
color.push_back(data[index]);
colors.push_back(color);
}
for (int i = 0; i < colors.size(); i++)
for (int j = 0; j < blackLevel; j++)
colors[i].erase(colors[i].begin());
double ss = 250.0 / (colors[0].size() - 1);
for (int i = 0; i < cols; i++)
{
uchar* ptr = lut.data + 256 * i;
memset(ptr, 255, 256);
memset(ptr, 0, 100);
for (int y = 1; y < colors[i].size(); y++)
{
int index_0 = colors[i][y - 1];
int index_1 = colors[i][y];
double value_0 = (y - 1) * ss;
double value_1 = cv::min(y * ss, 255.0);
double step = (double)(value_1 - value_0) / (double)(index_1 - index_0);
for (int x = index_0; x < index_1; x++)
ptr[x] = cv::min((int)(value_0 + (x - index_0) * step), 255);
}
}
const int channels = (lut.rows % 408 == 0) ? 408 : 432;
for (size_t i = 0, block = lut.rows / channels; i < block; i++)
{
cv::Mat lutROI = lut(cv::Rect(0, i * channels, 256, channels));
cv::Mat tran;
cv::transpose(lutROI, tran);
memcpy(lutROI.data, tran.data, tran.total());
}
cv::Mat lutMat(lut.rows / channels, 256, CV_8UC(channels));
memcpy(lutMat.data, lut.data, lut.total());
return lutMat;
}

View File

@ -0,0 +1,35 @@
#ifndef CORRECT_PROCESS_H
#define CORRECT_PROCESS_H
#include <opencv2/opencv.hpp>
//uchar m_byteArray[78336 * 26];
//int m_index[] = { 0, 4896 * 26 * 3, 4896 * 26 * 4, 4896 * 26 * 7, 4896 * 26 * 8, (78336 - 9796 * 4) * 26, (78336 - 9796) * 26 };
/// <summary>
/// 校正处理。灰阶校正+色偏校正。
/// </summary>
/// <param name="image">灰阶校正原图</param>
/// <param name="blackLevel">黑色等级</param>
/// <param name="colorCastEnable">色偏校正使能。true为进行色偏校正false为禁止</param>
/// <param name="referValues">色偏校正参考数据</param>
/// <param name="path">校正数据关键点文件保存路径</param>
/// <returns>[0]为灰阶校正数据;[1]为正面色偏校正数据;[2]为反面校正数据</returns>
std::vector<cv::Mat> correctProcess(cv::Mat& image, int blackLevel, bool colorCastEnable, const std::vector<uchar>& referValues, int dpi, const std::string& path);
/// <summary>
/// 校正处理。灰阶校正+色偏校正。
/// </summary>
/// <param name="image1">灰阶校正原图(正)</param>
/// <param name="image2">灰阶校正原图(反)</param>
/// <param name="blackLevel">黑色等级</param>
/// <param name="colorCastEnable">色偏校正使能。true为进行色偏校正false为禁止</param>
/// <param name="referValues">色偏校正参考数据</param>
/// <param name="path">校正数据关键点文件保存路径</param>
/// <returns>[0]为灰阶校正数据;[1]为正面色偏校正数据;[2]为反面校正数据</returns>
std::vector<cv::Mat> correctProcess(cv::Mat& image1, cv::Mat& image2, int blackLevel, bool colorCastEnable, const std::vector<uchar>& referValues, int dpi, const std::string& path);
void correctLUT(cv::Mat& image, const cv::Mat& lut);
cv::Mat readZipCorrect(uchar* data, int len, int blackLevel);
#endif

View File

@ -90,12 +90,16 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>../../../code_app/third_party/opencv/windows/lib/x86/opencv_core3416d.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_highgui3416d.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_features2d3416d.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_imgproc3416d.lib;../../../code_app/third_party/opencv/windows/lib/x86/ittnotifyd.lib;../../../code_app/third_party/opencv/windows/lib/x86/zlibd.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_imgcodecs3416d.lib;../../../code_app/third_party/opencv/windows/lib/x86/IlmImfd.lib;../../../code_app/third_party/opencv/windows/lib/x86/libjasperd.lib;../../../code_app/third_party/opencv/windows/lib/x86/libjpeg-turbod.lib;../../../code_app/third_party/opencv/windows/lib/x86/libpngd.lib;../../../code_app/third_party/opencv/windows/lib/x86/libtiffd.lib;../../../code_app/third_party/opencv/windows/lib/x86/libwebpd.lib;../../../code_app/third_party/libzip/windows/lib/x86/zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huagao\x86\Debug\</Command>
@ -107,14 +111,17 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>../../../code_app/third_party/opencv/windows/lib/x86/opencv_core3416.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_highgui3416.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_features2d3416.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_imgproc3416.lib;../../../code_app/third_party/opencv/windows/lib/x86/ittnotify.lib;../../../code_app/third_party/opencv/windows/lib/x86/zlib.lib;../../../code_app/third_party/opencv/windows/lib/x86/opencv_imgcodecs3416.lib;../../../code_app/third_party/opencv/windows/lib/x86/IlmImf.lib;../../../code_app/third_party/opencv/windows/lib/x86/libjasper.lib;../../../code_app/third_party/opencv/windows/lib/x86/libjpeg-turbo.lib;../../../code_app/third_party/opencv/windows/lib/x86/libpng.lib;../../../code_app/third_party/opencv/windows/lib/x86/libtiff.lib;../../../code_app/third_party/opencv/windows/lib/x86/libwebp.lib;../../../code_app/third_party/libzip/windows/lib/x86/zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x86\Release\
@ -125,12 +132,15 @@ copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huag
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;ZIP_STATIC</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>../../../code_app/third_party/opencv/windows/lib/x64/opencv_core3416d.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_highgui3416d.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_features2d3416d.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_imgproc3416d.lib;../../../code_app/third_party/opencv/windows/lib/x64/ittnotifyd.lib;../../../code_app/third_party/opencv/windows/lib/x64/zlibd.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_imgcodecs3416d.lib;../../../code_app/third_party/opencv/windows/lib/x64/IlmImfd.lib;../../../code_app/third_party/opencv/windows/lib/x64/libjasperd.lib;../../../code_app/third_party/opencv/windows/lib/x64/libjpeg-turbod.lib;../../../code_app/third_party/opencv/windows/lib/x64/libpngd.lib;../../../code_app/third_party/opencv/windows/lib/x64/libtiffd.lib;../../../code_app/third_party/opencv/windows/lib/x64/libwebpd.lib;../../../code_app/third_party/libzip/windows/lib/x64/zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -139,23 +149,28 @@ copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huag
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>../../../code_app/third_party/opencv/windows/lib/x64/opencv_core3416.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_highgui3416.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_features2d3416.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_imgproc3416.lib;../../../code_app/third_party/opencv/windows/lib/x64/ittnotify.lib;../../../code_app/third_party/opencv/windows/lib/x64/zlib.lib;../../../code_app/third_party/opencv/windows/lib/x64/opencv_imgcodecs3416.lib;../../../code_app/third_party/opencv/windows/lib/x64/IlmImf.lib;../../../code_app/third_party/opencv/windows/lib/x64/libjasper.lib;../../../code_app/third_party/opencv/windows/lib/x64/libjpeg-turbo.lib;../../../code_app/third_party/opencv/windows/lib/x64/libpng.lib;../../../code_app/third_party/opencv/windows/lib/x64/libtiff.lib;../../../code_app/third_party/opencv/windows/lib/x64/libwebp.lib;../../../code_app/third_party/libzip/windows/lib/x64/zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="correctProcess.cpp" />
<ClCompile Include="test_base.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="correctProcess.h" />
<ClInclude Include="test_base.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -18,10 +18,16 @@
<ClCompile Include="test_base.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="correctProcess.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="test_base.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="correctProcess.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -4,8 +4,15 @@
#include <windows.h>
#include <map>
#include <iostream>
#include <io.h>
#include "correctProcess.h"
#include "huagao/hgscanner_error.h"
#include "sane/sane_option_definitions.h";
#include "sane/sane_option_definitions.h"
extern "C"
{
#include "zip.h"
};
static struct Test_Map
{
const wchar_t* name; // DIAL_SWITCH
@ -49,7 +56,13 @@ static struct Test_Map
{HGPDTTOOLDB_NAME_GET_DEVICE_CPU_DISK ,HGPDTTOOLDB_TITLE_GET_DEVICE_CPU_DISK},
{HGPDTTOOLDB_NAME_BACKUP ,HGPDTTOOLDB_TITLE_BACKUP},
{HGPDTTOOLDB_NAME_SHUTDOWN ,HGPDTTOOLDB_TITLE_SHUTDOWN},
{HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE ,HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE}
{HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE ,HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_200DPI},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_200DPI},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_300DPI},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_300DPI},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_600DPI},
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_600DPI}
};
static std::string StringToUtf(std::string strValue)
@ -125,12 +138,130 @@ int get_json_config_file()
fread(buf, len, 1, fp);
fclose(fp);
std::cout << buf << std::endl;
return 0;
}
static std::string AnsiToUtf8(const char* text)
{
int wlen = ::MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
WCHAR* pUnicode = new WCHAR[wlen];
::MultiByteToWideChar(CP_ACP, 0, text, -1, pUnicode, wlen);
int len = ::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, NULL, 0, NULL, NULL);
CHAR* pUTF8 = new CHAR[len];
::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, pUTF8, len, NULL, NULL);
delete[] pUnicode;
std::string ret = pUTF8;
delete[] pUTF8;
return ret;
}
static bool GetFileName(const char* fileName, char* name, unsigned int maxLen)
{
if (NULL == fileName || NULL == name || 0 == maxLen)
{
return false;
}
const char* pcName = strrchr(fileName, '\\');
if (NULL == pcName)
{
pcName = strrchr(fileName, '/');
if (NULL == pcName)
return false;
}
++pcName;
if (maxLen < strlen(pcName) + 1)
return false;
strcpy(name, pcName);
return true;
}
static bool FileZip(const std::string& srcFile, const std::string& destFile)
{
int error = 0;
zip* z = zip_open(AnsiToUtf8(destFile.c_str()).c_str(), ZIP_CREATE | ZIP_TRUNCATE, &error);
if (NULL == z)
{
return false;
}
zip_source_t* s = zip_source_file(z, AnsiToUtf8(srcFile.c_str()).c_str(), 0, 0);
if (NULL == s)
{
zip_close(z);
return false;
}
char name[256];
GetFileName(srcFile.c_str(), name, 256);
if (zip_file_add(z, AnsiToUtf8(name).c_str(), s, ZIP_FL_OVERWRITE) < 0)
{
zip_source_free(s);
zip_close(z);
return false;
}
zip_close(z);
return true;
}
static void correctProcess(cv::Mat& image1, cv::Mat& image2, int blackLevel, bool colorCastEnable, const std::vector<uchar>& referValues, int dpi, const std::string& path,
std::vector<std::string>& imgFiles, std::vector<std::string>& zipFiles)
{
imgFiles.clear();
zipFiles.clear();
std::vector<std::string> datFiles;
datFiles.push_back(path + std::to_string(dpi) + (image1.channels() == 3 ? "c" : "g") + ".dat");
datFiles.push_back(path + "cc" + std::to_string(dpi) + "f.dat");
datFiles.push_back(path + "cc" + std::to_string(dpi) + "b.dat");
DeleteFileA(datFiles[0].c_str());
DeleteFileA(datFiles[1].c_str());
DeleteFileA(datFiles[2].c_str());
imgFiles.push_back(path + "Textlut" + std::to_string(dpi) + (image1.channels() == 3 ? "clr" : "gray") + ".bmp");
imgFiles.push_back(path + "ColorCast" + std::to_string(dpi) + "_F.bmp");
imgFiles.push_back(path + "ColorCast" + std::to_string(dpi) + "_B.bmp");
DeleteFileA(imgFiles[0].c_str());
DeleteFileA(imgFiles[1].c_str());
DeleteFileA(imgFiles[2].c_str());
zipFiles.push_back(path + std::to_string(dpi) + (image1.channels() == 3 ? "c" : "g") + ".zip");
zipFiles.push_back(path + "cc" + std::to_string(dpi) + "f.zip");
zipFiles.push_back(path + "cc" + std::to_string(dpi) + "b.zip");
DeleteFileA(zipFiles[0].c_str());
DeleteFileA(zipFiles[1].c_str());
DeleteFileA(zipFiles[2].c_str());
std::vector<cv::Mat> retImgs = correctProcess(image1, image2, blackLevel, colorCastEnable, referValues, dpi, path);
assert(retImgs.size() == 3);
if (retImgs[0].empty() || !cv::imwrite(imgFiles[0], retImgs[0]))
imgFiles[0].clear();
if (retImgs[1].empty() || !cv::imwrite(imgFiles[1], retImgs[1]))
imgFiles[1].clear();
if (retImgs[2].empty() || !cv::imwrite(imgFiles[2], retImgs[2]))
imgFiles[2].clear();
if (!FileZip(datFiles[0], zipFiles[0]))
zipFiles[0].clear();
if (!FileZip(datFiles[1], zipFiles[1]))
zipFiles[1].clear();
if (!FileZip(datFiles[2], zipFiles[2]))
zipFiles[2].clear();
DeleteFileA(datFiles[0].c_str());
DeleteFileA(datFiles[1].c_str());
DeleteFileA(datFiles[2].c_str());
}
static std::wstring set_test_name_ =L"";
//bool is_distortion_get_image = false;
//bool is_distortion_get_image_abnormal = false;
std::atomic<bool> is_distortion_get_image_abnormal(false);
std::atomic<bool> is_distortion_get_image(false);
cv::Mat m_image1, m_image2;
class test
{
ui_helper* helper_;
@ -357,6 +488,12 @@ public:
//std::string str = StringToUtf((char*)data);
switch (code)
{
case SANE_EVENT_WORKING:
{
m_image1 = cv::Mat();
m_image2 = cv::Mat();
}
break;
case SANE_EVENT_SCAN_FINISHED:
{
SANE_Bool close = false;
@ -495,11 +632,103 @@ public:
wcscpy(buf, L"单张测试失败, 原因--->");
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI) == 0)
{
if (m_image1.empty() || m_image2.empty())
{
type = false;
wcscpy(buf, L"自动图像校正测试失败, 原因--->图像缺失");
}
else
{
int dpi = 200;
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI) == 0)
dpi = 300;
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI) == 0)
dpi = 600;
int blackLevel = 4;
std::vector<uchar> referValues;
referValues.push_back(252);
referValues.push_back(12);
referValues.push_back(29);
referValues.push_back(37);
referValues.push_back(74);
referValues.push_back(131);
referValues.push_back(158);
referValues.push_back(168);
referValues.push_back(189);
referValues.push_back(231);
referValues.push_back(245);
referValues.push_back(249);
CHAR tmpPath[MAX_PATH] = { 0 };
DWORD len = GetTempPathA(MAX_PATH, tmpPath);
if (tmpPath[strlen(tmpPath) - 1] != '\\')
strcat(tmpPath, "\\");
std::string path = tmpPath;
std::vector<std::string> imgFiles, zipFiles;
correctProcess(m_image1, m_image2, blackLevel, true, referValues, dpi, path, imgFiles, zipFiles);
if (1) // 是否是7010
{
if (m_image1.channels() == 3 && 0 == _access(zipFiles[0].c_str(), 0)
&& 0 == _access(zipFiles[1].c_str(), 0) && 0 == _access(zipFiles[2].c_str(), 0))
{
// 上传zipFiles[0]、zipFiles[1]、zipFiles[2]到设备
}
else if (m_image1.channels() == 1 && 0 == _access(zipFiles[0].c_str(), 0))
{
// 上传zipFiles[0]到设备
}
else
{
type = false;
wcscpy(buf, L"自动图像校正测试失败, 原因--->校正算法处理出错");
}
}
else
{
if (m_image1.channels() == 3 && 0 == _access(imgFiles[0].c_str(), 0)
&& 0 == _access(imgFiles[1].c_str(), 0) && 0 == _access(imgFiles[2].c_str(), 0))
{
// 上传imgFiles[0]、imgFiles[1]、imgFiles[2]到设备
}
else if (m_image1.channels() == 1 && 0 == _access(imgFiles[0].c_str(), 0))
{
// 上传imgFiles[0]到设备
}
else
{
type = false;
wcscpy(buf, L"自动图像校正测试失败, 原因--->校正算法处理出错");
}
}
DeleteFileA(imgFiles[0].c_str());
DeleteFileA(imgFiles[1].c_str());
DeleteFileA(imgFiles[2].c_str());
DeleteFileA(zipFiles[0].c_str());
DeleteFileA(zipFiles[1].c_str());
DeleteFileA(zipFiles[2].c_str());
}
}
wcscat(buf, wstr.c_str());
//ret = h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
m_image1 = cv::Mat();
m_image2 = cv::Mat();
}
break;
case SANE_EVENT_ERROR:
@ -532,13 +761,38 @@ public:
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_600DPI) == 0)
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI) == 0)
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0)
{
is_distortion_get_image = true;
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI) == 0)
{
SANE_Image* sane_img = (SANE_Image*)data;
cv::Mat img(sane_img->header.lines, sane_img->header.pixels_per_line,
CV_8UC(sane_img->header.format == SANE_FRAME_RGB ? 3 : 1), sane_img->data, sane_img->header.bytes_per_line);
cvCvtColor(&img, &img, CV_RGB2BGR);
if (m_image1.empty())
m_image1 = img.clone();
else if (m_image2.empty())
m_image2 = img.clone();
}
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true);
}
}
@ -607,6 +861,12 @@ public:
test_map_[HGPDTTOOLDB_NAME_BACKUP] = &test::test_backup;
test_map_[HGPDTTOOLDB_NAME_SHUTDOWN] = &test::test_shutdown;
test_map_[HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE] = &test::test_set_firmware_language;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI] = &test::test_auto_color_correction_rgb_200dpi;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI] = &test::test_auto_color_correction_gray_200dpi;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI] = &test::test_auto_color_correction_rgb_300dpi;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI] = &test::test_auto_color_correction_gray_300dpi;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI] = &test::test_auto_color_correction_rgb_600dpi;
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI] = &test::test_auto_color_correction_gray_600dpi;
}
int set_test(const wchar_t* name,const wchar_t* oper)
{
@ -1598,6 +1858,67 @@ public:
return ret;
}
int test_auto_color_correction_rgb_200dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 200;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test_auto_color_correction_gray_200dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 200;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test_auto_color_correction_rgb_300dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 300;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test_auto_color_correction_gray_300dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 300;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test_auto_color_correction_rgb_600dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 600;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test_auto_color_correction_gray_600dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 600;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
/*设置设备型号*/
int test_set_devs_model(void* data)
{

View File

@ -98,6 +98,19 @@
#define HGPDTTOOLDB_TITLE_SHUTDOWN L"关机"
/*设置固件语言模式*/
#define HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE L"设置固件语言模式"
/* 自动图像校正彩色+200dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_200DPI L"自动图像校正彩色_200dpi"
/* 自动图像校正灰度+200dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_200DPI L"自动图像校正灰度_200dpi"
/* 自动图像校正彩色+300dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_300DPI L"自动图像校正彩色_300dpi"
/* 自动图像校正灰度+300dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_300DPI L"自动图像校正灰度_300dpi"
/* 自动图像校正彩色+600dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_600DPI L"自动图像校正彩色_600dpi"
/* 自动图像校正灰度+600dpi */
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_600DPI L"自动图像校正灰度_600dpi"
//////////////////////////////////////NAME//////////////////////////////////////
#define WRITE_CFG_NAME L"write-cfg"
/* 设置json序列号 */
@ -202,6 +215,18 @@
#define HGPDTTOOLDB_NAME_SHUTDOWN L"SHUTDOWN"
/*设置固件语言模式*/
#define HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE L"SET_FIRMWARE_LANGUAGE"
/* 自动图像校正彩色+200dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI L"AUTO_COLOR_CORRECTION_RGB_200DPI"
/* 自动图像校正灰度+200dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI L"AUTO_COLOR_CORRECTION_GRAY_200DPI"
/* 自动图像校正彩色+300dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI L"AUTO_COLOR_CORRECTION_RGB_300DPI"
/* 自动图像校正灰度+300dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI L"AUTO_COLOR_CORRECTION_GRAY_300DPI"
/* 自动图像校正彩色+600dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI L"AUTO_COLOR_CORRECTION_RGB_600DPI"
/* 自动图像校正灰度+600dpi */
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI L"AUTO_COLOR_CORRECTION_GRAY_600DPI"
#define TEST_DLL
#ifdef TEST_DLL