Compare commits
2 Commits
39333c4d33
...
6fdedfa320
Author | SHA1 | Date |
---|---|---|
yangjiaxuan | 6fdedfa320 | |
yangjiaxuan | 3ac12a1047 |
|
@ -39,6 +39,7 @@ std::vector<AnalysisJson::json_node> AnalysisJson::GetNode()
|
||||||
obj[key].toObject()["err-level"].toInt(),
|
obj[key].toObject()["err-level"].toInt(),
|
||||||
obj[key].toObject()["desc"].toString(),
|
obj[key].toObject()["desc"].toString(),
|
||||||
obj[key].toObject()["station"].toString(),
|
obj[key].toObject()["station"].toString(),
|
||||||
|
obj[key].toObject()["dynamic-correct-data"].toString(),
|
||||||
obj[key].toObject()["resolution"].toInt(),
|
obj[key].toObject()["resolution"].toInt(),
|
||||||
obj[key].toObject()["correct-value"].toInt()});
|
obj[key].toObject()["correct-value"].toInt()});
|
||||||
}
|
}
|
||||||
|
@ -57,8 +58,8 @@ AnalysisJson::json_global AnalysisJson::GetGlobal()
|
||||||
obj["speed-mode"].toInt(),
|
obj["speed-mode"].toInt(),
|
||||||
obj["sleep-time"].toInt(),
|
obj["sleep-time"].toInt(),
|
||||||
obj["device-model"].toString(),
|
obj["device-model"].toString(),
|
||||||
obj["cpu-size"].toInt(),
|
obj["cpu-size"].toDouble(),
|
||||||
obj["disk-size"].toInt(),
|
obj["disk-size"].toDouble(),
|
||||||
obj["firmware-version"].toString()};
|
obj["firmware-version"].toString()};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
std::int32_t err_level;
|
std::int32_t err_level;
|
||||||
QString desc;
|
QString desc;
|
||||||
QString station;
|
QString station;
|
||||||
|
QString dynamic_correct_data;
|
||||||
int resolution;
|
int resolution;
|
||||||
int correct_value;
|
int correct_value;
|
||||||
};
|
};
|
||||||
|
@ -26,8 +27,8 @@ public:
|
||||||
std::int32_t speed_mode;
|
std::int32_t speed_mode;
|
||||||
std::int32_t sleep_time;
|
std::int32_t sleep_time;
|
||||||
QString device_model;
|
QString device_model;
|
||||||
std::int32_t cpu_size;
|
double cpu_size;
|
||||||
std::int32_t disk_size;
|
double disk_size;
|
||||||
QString firmware_version;
|
QString firmware_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,8 @@ void Form_mainInterface::on_testGetDevCpuDisk(int cpu, int disk)
|
||||||
{
|
{
|
||||||
AnalysisJson analysisJson(m_profileName);
|
AnalysisJson analysisJson(m_profileName);
|
||||||
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
||||||
int cpu_size = jsonGlobal.cpu_size;
|
float cpu_size = jsonGlobal.cpu_size;
|
||||||
int disk_size = jsonGlobal.disk_size;
|
float disk_size = jsonGlobal.disk_size;
|
||||||
|
|
||||||
float devCpuSize = (float)cpu / 1024 / 1024;
|
float devCpuSize = (float)cpu / 1024 / 1024;
|
||||||
char buf[10] = { 0 };
|
char buf[10] = { 0 };
|
||||||
|
@ -757,6 +757,22 @@ void Form_mainInterface::writeTestLog(QString logContent)
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Form_mainInterface::str_to_wchar(std::string str, wchar_t *s, size_t *strlen)
|
||||||
|
{
|
||||||
|
if (str.empty())
|
||||||
|
return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
|
len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
|
||||||
|
if (*strlen < len)
|
||||||
|
{
|
||||||
|
*strlen = len;
|
||||||
|
return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
}
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, s, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous)
|
void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||||
{
|
{
|
||||||
(void)previous;
|
(void)previous;
|
||||||
|
@ -854,7 +870,7 @@ void Form_mainInterface::on_pbtn_start_clicked()
|
||||||
if (name == "AUTO_FLAT_FIELD")
|
if (name == "AUTO_FLAT_FIELD")
|
||||||
correct_value = 0;
|
correct_value = 0;
|
||||||
|
|
||||||
wchar_t buf[5] = {0};
|
wchar_t buf[128] = {0};
|
||||||
if (dpi > 0)
|
if (dpi > 0)
|
||||||
{
|
{
|
||||||
m_curDpi = dpi;
|
m_curDpi = dpi;
|
||||||
|
@ -865,6 +881,13 @@ void Form_mainInterface::on_pbtn_start_clicked()
|
||||||
swprintf(buf, L"%d", correct_value);
|
swprintf(buf, L"%d", correct_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string correctData = m_map_title_name.value(title).dynamic_correct_data.toStdString();
|
||||||
|
if (!correctData.empty())
|
||||||
|
{
|
||||||
|
size_t len = sizeof(buf) / sizeof(buf[0]);
|
||||||
|
str_to_wchar(correctData, buf, &len);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_hg != nullptr)
|
if (m_hg != nullptr)
|
||||||
{
|
{
|
||||||
updateUiEnabled(false);
|
updateUiEnabled(false);
|
||||||
|
@ -872,10 +895,15 @@ void Form_mainInterface::on_pbtn_start_clicked()
|
||||||
m_mainwnd->addTestingRef();
|
m_mainwnd->addTestingRef();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (buf != nullptr && (dpi > 0 || (correct_value > -1 && correct_value < 7)))
|
if (buf != nullptr || (dpi > 0 || (correct_value > -1 && correct_value < 7)))
|
||||||
|
{
|
||||||
ret = func_test_go(name.toStdWString().c_str(), (const wchar_t*)buf, m_hg);
|
ret = func_test_go(name.toStdWString().c_str(), (const wchar_t*)buf, m_hg);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ret = func_test_go(name.toStdWString().c_str(), L"null", m_hg);
|
ret = func_test_go(name.toStdWString().c_str(), L"null", m_hg);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret > SANE_STATUS_GOOD)
|
if (ret > SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
//getLogInfo(ret);
|
//getLogInfo(ret);
|
||||||
|
|
|
@ -99,6 +99,7 @@ private:
|
||||||
void getLogInfo(int ret);
|
void getLogInfo(int ret);
|
||||||
QString getLogPath();
|
QString getLogPath();
|
||||||
void writeTestLog(QString logContent);
|
void writeTestLog(QString logContent);
|
||||||
|
int str_to_wchar(std::string str, wchar_t* s, size_t* strlen);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union VIDPID
|
union VIDPID
|
||||||
|
|
|
@ -90,16 +90,12 @@
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<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>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huagao\x86\Debug\</Command>
|
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huagao\x86\Debug\</Command>
|
||||||
|
@ -111,17 +107,14 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<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>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x86\Release\
|
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x86\Release\
|
||||||
|
@ -132,15 +125,12 @@ copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huag
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;ZIP_STATIC</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<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>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -149,28 +139,23 @@ copy $(OutDir)test.dll $(SolutionDir)..\..\..\code_app\build2\build\windows\huag
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<AdditionalIncludeDirectories>../../../code_app/third_party/opencv/windows/include;../../../code_app/third_party/libzip/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<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>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
<Command>copy $(OutDir)test.dll $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="correctProcess.cpp" />
|
|
||||||
<ClCompile Include="test_base.cpp" />
|
<ClCompile Include="test_base.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="correctProcess.h" />
|
|
||||||
<ClInclude Include="test_base.h" />
|
<ClInclude Include="test_base.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -18,16 +18,10 @@
|
||||||
<ClCompile Include="test_base.cpp">
|
<ClCompile Include="test_base.cpp">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="correctProcess.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="test_base.h">
|
<ClInclude Include="test_base.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="correctProcess.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,18 +1,11 @@
|
||||||
#include "test_base.h"
|
#include"test_base.h"
|
||||||
#include <string>
|
#include<string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <io.h>
|
|
||||||
#include "correctProcess.h"
|
|
||||||
#include "huagao/hgscanner_error.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
|
static struct Test_Map
|
||||||
{
|
{
|
||||||
const wchar_t* name; // DIAL_SWITCH
|
const wchar_t* name; // DIAL_SWITCH
|
||||||
|
@ -57,12 +50,12 @@ static struct Test_Map
|
||||||
{HGPDTTOOLDB_NAME_BACKUP ,HGPDTTOOLDB_TITLE_BACKUP},
|
{HGPDTTOOLDB_NAME_BACKUP ,HGPDTTOOLDB_TITLE_BACKUP},
|
||||||
{HGPDTTOOLDB_NAME_SHUTDOWN ,HGPDTTOOLDB_TITLE_SHUTDOWN},
|
{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_IMAGE_CORRECTION_RGB_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_200DPI},
|
||||||
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_200DPI},
|
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_200DPI},
|
||||||
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_300DPI},
|
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_300DPI},
|
||||||
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_300DPI},
|
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_300DPI},
|
||||||
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_600DPI},
|
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_600DPI},
|
||||||
{HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI ,HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_600DPI}
|
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_600DPI}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string StringToUtf(std::string strValue)
|
static std::string StringToUtf(std::string strValue)
|
||||||
|
@ -138,130 +131,12 @@ int get_json_config_file()
|
||||||
fread(buf, len, 1, fp);
|
fread(buf, len, 1, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
std::cout << buf << std::endl;
|
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"";
|
static std::wstring set_test_name_ =L"";
|
||||||
//bool is_distortion_get_image = false;
|
//bool is_distortion_get_image = false;
|
||||||
//bool is_distortion_get_image_abnormal = false;
|
//bool is_distortion_get_image_abnormal = false;
|
||||||
std::atomic<bool> is_distortion_get_image_abnormal(false);
|
std::atomic<bool> is_distortion_get_image_abnormal(false);
|
||||||
std::atomic<bool> is_distortion_get_image(false);
|
std::atomic<bool> is_distortion_get_image(false);
|
||||||
cv::Mat m_image1, m_image2;
|
|
||||||
class test
|
class test
|
||||||
{
|
{
|
||||||
ui_helper* helper_;
|
ui_helper* helper_;
|
||||||
|
@ -488,12 +363,6 @@ public:
|
||||||
//std::string str = StringToUtf((char*)data);
|
//std::string str = StringToUtf((char*)data);
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case SANE_EVENT_WORKING:
|
|
||||||
{
|
|
||||||
m_image1 = cv::Mat();
|
|
||||||
m_image2 = cv::Mat();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SANE_EVENT_SCAN_FINISHED:
|
case SANE_EVENT_SCAN_FINISHED:
|
||||||
{
|
{
|
||||||
SANE_Bool close = false;
|
SANE_Bool close = false;
|
||||||
|
@ -632,103 +501,11 @@ public:
|
||||||
wcscpy(buf, L"单张测试失败, 原因--->");
|
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());
|
wcscat(buf, wstr.c_str());
|
||||||
//ret = h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
|
//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);
|
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;
|
break;
|
||||||
case SANE_EVENT_ERROR:
|
case SANE_EVENT_ERROR:
|
||||||
|
@ -747,10 +524,10 @@ public:
|
||||||
case SANE_EVENT_IMAGE_OK:
|
case SANE_EVENT_IMAGE_OK:
|
||||||
{
|
{
|
||||||
if ( wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0
|
if ( wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0
|
||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0
|
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0
|
||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0
|
||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 0
|
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY) == 0
|
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY) == 0
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY) == 0
|
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY) == 0
|
||||||
|
@ -761,38 +538,13 @@ public:
|
||||||
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_300DPI) == 0
|
|| 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_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_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)
|
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0)
|
||||||
{
|
{
|
||||||
is_distortion_get_image = true;
|
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);
|
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,12 +613,12 @@ public:
|
||||||
test_map_[HGPDTTOOLDB_NAME_BACKUP] = &test::test_backup;
|
test_map_[HGPDTTOOLDB_NAME_BACKUP] = &test::test_backup;
|
||||||
test_map_[HGPDTTOOLDB_NAME_SHUTDOWN] = &test::test_shutdown;
|
test_map_[HGPDTTOOLDB_NAME_SHUTDOWN] = &test::test_shutdown;
|
||||||
test_map_[HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE] = &test::test_set_firmware_language;
|
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_IMAGE_CORRECTION_RGB_200DPI] = &test::test_image_correct_rgb_200dpi;
|
||||||
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI] = &test::test_auto_color_correction_gray_200dpi;
|
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI] = &test::test_image_correct_gray_200dpi;
|
||||||
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI] = &test::test_auto_color_correction_rgb_300dpi;
|
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI] = &test::test_image_correct_rgb_300dpi;
|
||||||
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI] = &test::test_auto_color_correction_gray_300dpi;
|
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI] = &test::test_image_correct_gray_300dpi;
|
||||||
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI] = &test::test_auto_color_correction_rgb_600dpi;
|
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI] = &test::test_image_correct_rgb_600dpi;
|
||||||
test_map_[HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI] = &test::test_auto_color_correction_gray_600dpi;
|
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI] = &test::test_image_correct_gray_600dpi;
|
||||||
}
|
}
|
||||||
int set_test(const wchar_t* name,const wchar_t* oper)
|
int set_test(const wchar_t* name,const wchar_t* oper)
|
||||||
{
|
{
|
||||||
|
@ -1858,67 +1610,6 @@ public:
|
||||||
|
|
||||||
return ret;
|
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)
|
int test_set_devs_model(void* data)
|
||||||
{
|
{
|
||||||
|
@ -1943,11 +1634,76 @@ public:
|
||||||
}
|
}
|
||||||
unsigned int l = str.size();
|
unsigned int l = str.size();
|
||||||
ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_MODEL, &str[0], &l);
|
ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_MODEL, &str[0], &l);
|
||||||
if (ret != SCANNER_ERR_OK)return ret;
|
if (ret != SCANNER_ERR_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置设备类型成功", true);
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置设备类型成功", true);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
int public_test_image_correct(void* data, int dpi, bool isColor)
|
||||||
|
{
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
return SCANNER_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
wchar_t* sc = (wchar_t*)data;
|
||||||
|
std::string str;
|
||||||
|
size_t len = 0;
|
||||||
|
int ret = wchar_to_char(str, sc, &len);
|
||||||
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
str.resize(len);
|
||||||
|
ret = wchar_to_char(str, sc, &len);
|
||||||
|
}
|
||||||
|
if (str.empty())
|
||||||
|
{
|
||||||
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正失败", false);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int l = str.size();
|
||||||
|
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &l);
|
||||||
|
const char* color = isColor ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
|
||||||
|
unsigned int colorlen = strlen(color);
|
||||||
|
ret = helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen);
|
||||||
|
|
||||||
|
SANE_Bool isOriImg = true;
|
||||||
|
ret = ret = helper_->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
|
||||||
|
|
||||||
|
ret = helper_->io_control(IO_CTRL_CODE_SET_CORRECT_IMAGE, &str[0], &l);
|
||||||
|
ret = helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
|
||||||
|
|
||||||
|
if (ret != SCANNER_ERR_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
//helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正完成", true);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int test_image_correct_rgb_200dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 200, true);
|
||||||
|
}
|
||||||
|
int test_image_correct_gray_200dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 200, false);
|
||||||
|
}
|
||||||
|
int test_image_correct_rgb_300dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 300, true);
|
||||||
|
}
|
||||||
|
int test_image_correct_gray_300dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 300, false);
|
||||||
|
}
|
||||||
|
int test_image_correct_rgb_600dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 600, true);
|
||||||
|
}
|
||||||
|
int test_image_correct_gray_600dpi(void* data)
|
||||||
|
{
|
||||||
|
return public_test_image_correct(data, 600, false);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,19 +98,18 @@
|
||||||
#define HGPDTTOOLDB_TITLE_SHUTDOWN L"关机"
|
#define HGPDTTOOLDB_TITLE_SHUTDOWN L"关机"
|
||||||
/*设置固件语言模式*/
|
/*设置固件语言模式*/
|
||||||
#define HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE L"设置固件语言模式"
|
#define HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE L"设置固件语言模式"
|
||||||
/* 自动图像校正彩色+200dpi */
|
/*彩色图像扫描校正+200dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_200DPI L"自动图像校正彩色_200dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_200DPI L"彩色图像扫描校正+200dpi"
|
||||||
/* 自动图像校正灰度+200dpi */
|
/*灰度图像扫描校正+200dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_200DPI L"自动图像校正灰度_200dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_200DPI L"灰度图像扫描校正+200dpi"
|
||||||
/* 自动图像校正彩色+300dpi */
|
/*彩色图像扫描校正+300dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_300DPI L"自动图像校正彩色_300dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_300DPI L"彩色图像扫描校正+300dpi"
|
||||||
/* 自动图像校正灰度+300dpi */
|
/*灰度图像扫描校正+300dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_300DPI L"自动图像校正灰度_300dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_300DPI L"灰度图像扫描校正+300dpi"
|
||||||
/* 自动图像校正彩色+600dpi */
|
/*彩色图像扫描校正+600dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_RGB_600DPI L"自动图像校正彩色_600dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_600DPI L"彩色图像扫描校正+600dpi"
|
||||||
/* 自动图像校正灰度+600dpi */
|
/*灰度图像扫描校正+600dpi*/
|
||||||
#define HGPDTTOOLDB_TITLE_AUTO_COLOR_CORRECTION_GRAY_600DPI L"自动图像校正灰度_600dpi"
|
#define HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_600DPI L"灰度图像扫描校正+600dpi"
|
||||||
|
|
||||||
//////////////////////////////////////NAME//////////////////////////////////////
|
//////////////////////////////////////NAME//////////////////////////////////////
|
||||||
#define WRITE_CFG_NAME L"write-cfg"
|
#define WRITE_CFG_NAME L"write-cfg"
|
||||||
/* 设置json序列号 */
|
/* 设置json序列号 */
|
||||||
|
@ -215,18 +214,18 @@
|
||||||
#define HGPDTTOOLDB_NAME_SHUTDOWN L"SHUTDOWN"
|
#define HGPDTTOOLDB_NAME_SHUTDOWN L"SHUTDOWN"
|
||||||
/*设置固件语言模式*/
|
/*设置固件语言模式*/
|
||||||
#define HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE L"SET_FIRMWARE_LANGUAGE"
|
#define HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE L"SET_FIRMWARE_LANGUAGE"
|
||||||
/* 自动图像校正彩色+200dpi */
|
/*彩色图像扫描校正+200dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_200DPI L"AUTO_COLOR_CORRECTION_RGB_200DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI L"IMAGE_CORRECTION_RGB_200DPI"
|
||||||
/* 自动图像校正灰度+200dpi */
|
/*灰度图像扫描校正+200dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_200DPI L"AUTO_COLOR_CORRECTION_GRAY_200DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI L"IMAGE_CORRECTION_GRAY_200DPI"
|
||||||
/* 自动图像校正彩色+300dpi */
|
/*彩色图像扫描校正+300dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_300DPI L"AUTO_COLOR_CORRECTION_RGB_300DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI L"IMAGE_CORRECTION_RGB_300DPI"
|
||||||
/* 自动图像校正灰度+300dpi */
|
/*灰度图像扫描校正+300dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_300DPI L"AUTO_COLOR_CORRECTION_GRAY_300DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI L"IMAGE_CORRECTION_GRAY_300DPI"
|
||||||
/* 自动图像校正彩色+600dpi */
|
/*彩色图像扫描校正+600dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_RGB_600DPI L"AUTO_COLOR_CORRECTION_RGB_600DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI L"IMAGE_CORRECTION_RGB_600DPI"
|
||||||
/* 自动图像校正灰度+600dpi */
|
/*灰度图像扫描校正+600dpi*/
|
||||||
#define HGPDTTOOLDB_NAME_AUTO_COLOR_CORRECTION_GRAY_600DPI L"AUTO_COLOR_CORRECTION_GRAY_600DPI"
|
#define HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI L"IMAGE_CORRECTION_GRAY_600DPI"
|
||||||
|
|
||||||
#define TEST_DLL
|
#define TEST_DLL
|
||||||
#ifdef TEST_DLL
|
#ifdef TEST_DLL
|
||||||
|
|
Loading…
Reference in New Issue