2022-05-03 03:56:07 +00:00
|
|
|
|
#include "hg_scanner_300.h"
|
2022-05-30 03:04:26 +00:00
|
|
|
|
#include "../wrapper/hg_log.h"
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
#include "scanner_manager.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2022-05-23 08:54:55 +00:00
|
|
|
|
static std::string jsontext("{\"device_type\":\"G300\",\"option_count\":54,\"1\":{\"category\":\"base\",\"name\":\"cfg-1\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"type\":\"button\",\"cur\":\"button\",\"default\":\"button\",\"size\":0},\"2\":{\"category\":\"advanced\",\"name\":\"cfg-2\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"type\":\"button\",\"cur\":\"true\",\"default\":\"true\",\"size\":4},\"3\":{\"category\":\"base\",\"name\":\"grp-1\",\"title\":\"\\u57fa\\u672c\\u8bbe\\u7f6e\",\"type\":\"group\"},\"4\":{\"category\":\"base\",\"name\":\"cfg-4\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"5\":{\"category\":\"base\",\"name\":\"cfg-5\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"4==true\"]},\"6\":{\"category\":\"base\",\"name\":\"cfg-6\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u8bbe\\u7f6e\\u989c\\u8272\\u4f4d\\u6df1\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"4==false\"]},\"7\":{\"category\":\"base\",\"name\":\"cfg-7\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\",\"desc\":\"\\u9664\\u53bb\\u56fe\\u50cf\\u5f69\\u8272\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"range\":[\"\\u4e0d\\u9664\\u8272\",\"\\u9664\\u7ea2\\u8272\",\"\\u9664\\u7eff\\u8272\",\"\\u9664\\u84dd\\u8272\",\"\\u7ea2\\u8272\\u589e\\u5f3a\",\"\\u7eff\\u8272\\u589e\\u5f3a\",\"\\u84dd\\u8272\\u589e\\u5f3a\"],\"depend_and\":[\"4!=true\",\"6!=24\\u4f4d\\u5f69\\u8272\",\"6!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"8\":{\"category\":\"base\",\"name\":\"cfg-8\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u591a\\u901a\\u9053\\u8f93\\u51fa\\u4e2d\\uff0c\\u53bb\\u9664\\u7ea2\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"4!=true\",\"6!=256\\u7ea7\\u7070\\u5ea6\",\"6!=\\u9ed1\\u767d\",\"6!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"9\":{\"category\":\"base\",\"name\":\"cfg-9\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u7b54\\u9898\\u5361\\u626b\\u63cf\\u4e2d\\u53bb\\u9664\\u7ea2\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"4!=true\",\"6!=256\\u7ea7\\u7070\\u5ea6\",\"6!=\\u9ed1\\u767d\",\"6!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"10\":{\"category\":\"base\",\"name\":\"cfg-10\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u5f69\\u8272\\u56fe\\u50cf\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"4!=true\",\"6!=256\\u7ea7\\u7070\\u5ea6\",\"6!=\\u9ed1\\u767d\",\"6!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"11\":{\"category\":\"base\",\"name\":\"cfg-11\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u8bbe\\u5b9a\\u80cc\\u666f\\u8272\\u5f69\\u7684\\u6d6e\\u52a8\\u8303\\u56f4\\uff0c\\u5728\\u8be5\\u8303\\u56f4\\u5185\\u7684\\u90fd\\u5f53\\u4f5c\\u80cc\\u666f\\u79fb\\u9664\",\"type\":\"int\",\"cur\":20,\"default\":20,\"size\":4,\"range\":{\"min\":1,\"max\":128},\"depend_or\":[\"10==true\"]},\"12\":{\"category\":\"base\",\"name\":\"cfg-12\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"type\":\"string\",\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"size\":24,\"ra
|
2022-05-03 03:56:07 +00:00
|
|
|
|
namespace settingsdsp_300
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
scanner_err device_status_to_hg_err(int usbdata)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
scanner_err code = SCANNER_ERR_NO_DATA;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
switch (usbdata)
|
|
|
|
|
{
|
|
|
|
|
case HAVE_IMAGE:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case STOP_SCAN:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_STOPPED;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case COUNT_MODE:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_COUNT_MODE;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case NO_FEED:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_NO_PAPER;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case OPEN_COVER:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_COVER_OPENNED;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case FEED_IN_ERROR:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_FEEDING_PAPER;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case PAPER_JAM:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_PAPER_JAMMED;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case DETECT_DOUBLE_FEED:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_DOUBLE_FEEDING;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case DETECT_STAPLE:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_STAPLE_ON;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case PAPER_SKEW:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_PAPER_SKEW;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case HARDWARE_ERROR:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case PC_SCAN_BUSY_or_ERROR:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_PC_BUSY;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case SIZE_ERROR:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_DEVICE_SIZE_CHECK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2022-05-17 07:04:55 +00:00
|
|
|
|
code = SCANNER_ERR_NO_DATA;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct
|
|
|
|
|
{
|
|
|
|
|
int paper;
|
|
|
|
|
TwSS type;
|
|
|
|
|
int dev_value;
|
|
|
|
|
}paper_map[] =
|
|
|
|
|
{
|
|
|
|
|
{PAPER_A3, TwSS::A3, G400_A3},
|
|
|
|
|
{PAPER_A4, TwSS::A4, G400_A4},
|
|
|
|
|
{PAPER_A4_LATERAL, TwSS::A4, G400_A4R},
|
|
|
|
|
{PAPER_A5, TwSS::A5, G400_A5},
|
|
|
|
|
{PAPER_A5_LATERAL, TwSS::A5, G400_A5R},
|
|
|
|
|
{PAPER_A6, TwSS::A6, G400_A6},
|
|
|
|
|
{PAPER_A6_LATERAL, TwSS::A6, G400_A6R},
|
|
|
|
|
{PAPER_B4, TwSS::B4, G400_B4},
|
|
|
|
|
{PAPER_B5, TwSS::B5, G400_B5},
|
|
|
|
|
{PAPER_B5_LATERAL, TwSS::B5, G400_B5R},
|
|
|
|
|
{PAPER_B6, TwSS::B6, G400_B6},
|
|
|
|
|
{PAPER_B6_LATERAL, TwSS::B6, G400_B6R},
|
|
|
|
|
{PAPER_LETTER, TwSS::USLetter, G400_LETTER},
|
|
|
|
|
{PAPER_LETTER_LATERAL, TwSS::USLetter, G400_LETTERR},
|
|
|
|
|
{PAPER_DOUBLE_LETTER, TwSS::USLedger, G400_DOUBLELETTER},
|
|
|
|
|
{PAPER_LEGAL, TwSS::USLegal, G400_LEGAL},
|
|
|
|
|
{PAPER_AUTO_MATCH, TwSS::None, G400_A4},
|
|
|
|
|
{PAPER_MAX_SIZE_CLIP, TwSS::USStatement, G400_MAXSIZE},
|
|
|
|
|
{PAPER_MAX_SIZE, TwSS::MaxSize, G400_MAXSIZE}
|
|
|
|
|
};
|
|
|
|
|
int match_best_paper(int& paper, bool* exact, TwSS* type)
|
|
|
|
|
{
|
|
|
|
|
int ind = 0;
|
|
|
|
|
bool good = true, * r = exact ? exact : &good;
|
|
|
|
|
for (int i = 0; i < ARRAY_SIZE(paper_map); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (paper == paper_map[i].paper)
|
|
|
|
|
{
|
|
|
|
|
ind = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (paper == paper_map[ind].paper)
|
|
|
|
|
*r = true;
|
|
|
|
|
else
|
|
|
|
|
*r = false;
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "Paper '%s' index = %d, device value = %d\n", paper_string(paper).c_str(), ind, paper_map[ind].dev_value);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
paper = paper_map[ind].paper;
|
|
|
|
|
if (type)
|
|
|
|
|
*type = paper_map[ind].type;
|
|
|
|
|
|
|
|
|
|
return ind;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum hg_239_setting_item
|
|
|
|
|
{
|
|
|
|
|
HG_239_SETTING_RESTORE = 1, // 恢复默认设置
|
|
|
|
|
HG_239_SETTING_HELP, // 帮助
|
|
|
|
|
|
|
|
|
|
HG__239_SETTING_GROUP_1,
|
|
|
|
|
|
|
|
|
|
HG_239_SETTING_COLOR_MODE, // 颜色模式
|
|
|
|
|
|
|
|
|
|
HG_239_SETTING_ERASE_COLOR, // 除色
|
|
|
|
|
HG_239_SETTING_ERASE_MULTI_RED, // 多流输出除红
|
|
|
|
|
HG_239_SETTING_ERASE_ANSWER_RED, // 答题卡除红
|
|
|
|
|
HG_239_SETTING_ERASE_BACKGROUND, // 移除背景
|
|
|
|
|
HG_239_SETTING_ERASE_BKG_RANGE, // 移除背景范围
|
|
|
|
|
HG_239_SETTING_NOISE, // 黑白图像噪点优化
|
|
|
|
|
HG_239_SETTING_NOISE_SIZE, // 噪点优化尺寸
|
|
|
|
|
HG_239_SETTING_PAPER_SIZE, // 纸张尺寸
|
2022-05-07 07:39:48 +00:00
|
|
|
|
|
|
|
|
|
HG_300_SETTING_CUSTOM_AREA, // 自定义扫描区域
|
|
|
|
|
HG_300_SETTING_CUSTOM_AREA_LEFT, // 扫描区域左侧(mm)
|
|
|
|
|
HG_300_SETTING_CUSTOM_AREA_RIGHT, // 扫描区域右侧(mm)
|
|
|
|
|
HG_300_SETTING_CUSTOM_AREA_TOP, // 扫描区域上侧(mm)
|
|
|
|
|
HG_300_SETTING_CUSTOM_AREA_BOTTOM, // 扫描区域下侧(mm)
|
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
//HG_239_SETTING_PAPER_SIZE_CHECK, // 尺寸检测
|
|
|
|
|
HG_239_SETTING_PAGE, // 扫描页面
|
|
|
|
|
HG_239_SETTING_SKIP_NILL, // 跳过空白页灵敏度
|
|
|
|
|
HG_239_SETTING_RESOLUTION, // 分辨率
|
|
|
|
|
HG_239_SETTING_REVERSE, // 交换正反面
|
|
|
|
|
HG_239_SETTING_SPLIT, // 图像拆分
|
|
|
|
|
HG_239_SETTING_CORRECT, // 自动纠偏
|
|
|
|
|
HG_239_SETTING_ERASE_HOLE, // 穿孔移除
|
|
|
|
|
HG_239_SETTING_HOLE_SEARCH, // 穿孔搜索范围
|
|
|
|
|
|
|
|
|
|
HG__239_SETTING_GROUP_2,
|
|
|
|
|
|
2022-05-07 07:39:48 +00:00
|
|
|
|
HG_300_SETTING_CUSTOM_GAMMA, // 启用色调曲线
|
2022-05-03 03:56:07 +00:00
|
|
|
|
HG_239_SETTING_LIGHT, // 亮度
|
|
|
|
|
HG_239_SETTING_CONTRAST, // 对比度
|
|
|
|
|
HG_239_SETTING_GAMMA, // 伽玛
|
|
|
|
|
|
|
|
|
|
HG__239_SETTING_GROUP_3,
|
|
|
|
|
|
|
|
|
|
HG_239_SETTING_SHARP, // 锐化与模糊
|
|
|
|
|
HG_239_SETTING_ERASE_BLACK_BORDER, // 消除黑框
|
|
|
|
|
HG_239_SETTING_SAMPLE, // 深色样张
|
|
|
|
|
HG_239_SETTING_THRESHOLD, // 阈值
|
|
|
|
|
HG_239_SETTING_ANTI_NOISE, // 背景抗噪等级
|
|
|
|
|
HG_239_SETTING_MARGIN, // 边缘缩进
|
|
|
|
|
HG_239_SETTING_FILLING, // 背景填充方式
|
|
|
|
|
HG_239_SETTING_PERMEATE, // 防止渗透
|
|
|
|
|
HG_239_SETTING_PERMEATE_lv, // 防止渗透等级
|
|
|
|
|
HG_239_SETTING_REMOVE_MORR, // 去除摩尔纹
|
|
|
|
|
HG_239_SETTING_ERROR_EXTENTION, // 错误扩散
|
|
|
|
|
HG_239_SETTING_REMOVE_TXTTURE, // 除网纹
|
|
|
|
|
|
|
|
|
|
HG__239_SETTING_GROUP_4,
|
|
|
|
|
|
|
|
|
|
HG_239_SETTING_ULTRASONIC, // 超声波检测
|
|
|
|
|
HG_239_SETTING_SCAN_METHOD, // 连续扫描或扫描指定张数
|
|
|
|
|
HG_239_SETTING_SCAN_COUNT, // 扫描指定数量
|
|
|
|
|
HG_239_SETTING_DIRECTION, // 文稿方向 删除文稿自动识别
|
|
|
|
|
HG_239_SETTING_ROTATE, // 背面旋转180°
|
|
|
|
|
|
|
|
|
|
HG_239_SETTING_END,
|
|
|
|
|
|
|
|
|
|
//暂时屏蔽
|
|
|
|
|
HG_239_SETTING_MULTI_OUT = 500, // 多流输出
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-04 08:57:05 +00:00
|
|
|
|
hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) : hg_scanner(G100Serial, dev_name, io),pid_(pid),papersize(pid)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
string fw = get_firmware_version();
|
|
|
|
|
|
|
|
|
|
initdevice();
|
2022-05-09 08:59:22 +00:00
|
|
|
|
#ifndef MAPPING_FUNCTION_IN_BASE
|
2022-05-03 03:56:07 +00:00
|
|
|
|
init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//优先初始化
|
2022-05-09 08:59:22 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
init_settings(jsontext.c_str());
|
|
|
|
|
|
|
|
|
|
printf_devconfig();
|
|
|
|
|
}
|
|
|
|
|
hg_scanner_300::~hg_scanner_300()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hg_scanner_300::init_setting_map(int* setting_map, int count)
|
|
|
|
|
{
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_RESTORE_DEFAULT_SETTINGS] = HG_239_SETTING_RESTORE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_HELP] = HG_239_SETTING_HELP;
|
|
|
|
|
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_COLOR_MODE] = HG_239_SETTING_COLOR_MODE;
|
2022-05-09 08:59:22 +00:00
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_MULTI_OUT] = HG_239_SETTING_MULTI_OUT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_COLOR] = HG_239_SETTING_ERASE_COLOR;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_MULTI_OUT_RED] = HG_239_SETTING_ERASE_MULTI_RED;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_ANSWER_RED] = HG_239_SETTING_ERASE_ANSWER_RED;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_BACKGROUND] = HG_239_SETTING_ERASE_BACKGROUND;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_BACKGROUND_RANGE] = HG_239_SETTING_ERASE_BKG_RANGE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_NOISE_OPTIMIZE] = HG_239_SETTING_NOISE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_NOISE_OPTIMIZE_SIZE] = HG_239_SETTING_NOISE_SIZE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_PAPER] = HG_239_SETTING_PAPER_SIZE;
|
2022-05-07 07:39:48 +00:00
|
|
|
|
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_IS_CUSTOM_AREA] = HG_300_SETTING_CUSTOM_AREA;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_CUSTOM_AREA_LEFT] = HG_300_SETTING_CUSTOM_AREA_LEFT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_CUSTOM_AREA_RIGHT] = HG_300_SETTING_CUSTOM_AREA_RIGHT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_CUSTOM_AREA_TOP] = HG_300_SETTING_CUSTOM_AREA_TOP;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_CUSTOM_AREA_BOTTOM] = HG_300_SETTING_CUSTOM_AREA_BOTTOM;
|
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
//setting_map[HG_BASE_SETTING_INDEX_PAPER_SIZE_CHECK] = HG_239_SETTING_PAPER_SIZE_CHECK;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_PAGE] = HG_239_SETTING_PAGE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_PAGE_OMIT_EMPTY_LEVEL] = HG_239_SETTING_SKIP_NILL;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_RESOLUTION] = HG_239_SETTING_RESOLUTION;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_EXCHANGE] = HG_239_SETTING_REVERSE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_SPLIT] = HG_239_SETTING_SPLIT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_AUTO_CORRECT] = HG_239_SETTING_CORRECT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_RID_HOLE] = HG_239_SETTING_ERASE_HOLE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_RID_HOLE_RANGE] = HG_239_SETTING_HOLE_SEARCH;
|
|
|
|
|
|
2022-05-07 07:39:48 +00:00
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_IS_CUSTOM_GAMMA] = HG_300_SETTING_CUSTOM_GAMMA;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_BRIGHT] = HG_239_SETTING_LIGHT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_CONTRAST] = HG_239_SETTING_CONTRAST;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_GAMMA] = HG_239_SETTING_GAMMA;
|
|
|
|
|
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_SHARPEN] = HG_239_SETTING_SHARP;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_DARK_SAMPLE] = HG_239_SETTING_SAMPLE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERASE_BLACK_FRAME] = HG_239_SETTING_ERASE_BLACK_BORDER;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_THRESHOLD] = HG_239_SETTING_THRESHOLD;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ANTI_NOISE_LEVEL] = HG_239_SETTING_ANTI_NOISE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_MARGIN] = HG_239_SETTING_MARGIN;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_FILL_BACKGROUND] = HG_239_SETTING_FILLING;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_PERMEATE] = HG_239_SETTING_PERMEATE;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_PERMEATE_LV] = HG_239_SETTING_PERMEATE_lv;
|
2022-05-09 08:59:22 +00:00
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_REMOVE_MORR] = HG_239_SETTING_REMOVE_MORR;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ERROR_EXTENTION] = HG_239_SETTING_ERROR_EXTENTION;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_REMOVE_TXTTURE] = HG_239_SETTING_REMOVE_TXTTURE;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ULTRASONIC_CHECK] = HG_239_SETTING_ULTRASONIC;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_SCAN_MODE] = HG_239_SETTING_SCAN_METHOD;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_SCAN_COUNT] = HG_239_SETTING_SCAN_COUNT;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_TEXT_DIRECTION] = HG_239_SETTING_DIRECTION;
|
|
|
|
|
setting_map[HG_BASE_SETTING_INDEX_ROTATE_BKG_180] = HG_239_SETTING_ROTATE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::on_scanner_closing(bool force)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
void hg_scanner_300::thread_handle_usb_read(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
|
|
|
|
status = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
StopWatch sw;
|
|
|
|
|
savestatus_.clear();
|
|
|
|
|
|
|
|
|
|
while (run_)
|
|
|
|
|
{
|
|
|
|
|
if (user_cancel_)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
USBCB usb={0};
|
|
|
|
|
ret = get_scanner_status(usb);
|
|
|
|
|
//printf("usb.u32_Data = %d ret = %d\r\n",usb.u32_Data,ret);
|
|
|
|
|
////如果设备出现卡纸 或者双张等设备信息问题,需要等到设备进行发送stop才能停止。 所以始终以 "停止" 消息为结束信号
|
|
|
|
|
////如果有图的情况下,并且卡纸或双张等,设备会先发送卡纸双张信息。所以接受到错误信息之后,仍需要把图像取出来。
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_DEVICE_STOPPED)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (!savestatus_.empty())
|
|
|
|
|
{
|
|
|
|
|
status_ = savestatus_[0]; //以第一个消息为准
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
status_ = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
savestatus_.clear();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK && ret != SCANNER_ERR_DEVICE_STOPPED && ret != SCANNER_ERR_NO_DATA)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
savestatus_.push_back(ret);
|
|
|
|
|
}
|
|
|
|
|
if (sw.elapsed_ms() > 30000)//防止状态信息一直取不上来导致卡死
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!savestatus_.empty())
|
|
|
|
|
{
|
|
|
|
|
status_ = savestatus_[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
status_ = SCANNER_ERR_TIMEOUT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
savestatus_.clear();
|
2022-05-17 07:04:55 +00:00
|
|
|
|
hg_log::log(LOG_LEVEL_WARNING, "get status timeout,get image out\n");
|
2022-05-03 03:56:07 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK && usb.u32_Count > 0)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
int totalNum = usb.u32_Count;
|
2022-06-01 03:04:10 +00:00
|
|
|
|
std::shared_ptr<tiny_buffer> imagedata(aquire_memory(totalNum));
|
2022-05-23 06:10:18 +00:00
|
|
|
|
|
|
|
|
|
if (!imagedata.get())
|
|
|
|
|
{
|
|
|
|
|
status_ = SCANNER_ERR_INSUFFICIENT_MEMORY;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
ret = get_img_data(imagedata);
|
|
|
|
|
io_->set_timeout(200);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
ret = pop_image();
|
|
|
|
|
sw.reset();
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this_thread::sleep_for(chrono::milliseconds(10));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::start(void)
|
|
|
|
|
{
|
2022-05-20 09:11:50 +00:00
|
|
|
|
bool handled = false;
|
|
|
|
|
int ret = try_third_app_handle_start(handled),
|
2022-05-03 03:56:07 +00:00
|
|
|
|
count = -1;
|
2022-05-20 09:11:50 +00:00
|
|
|
|
|
|
|
|
|
user_cancel_ = false;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
2022-05-20 06:46:25 +00:00
|
|
|
|
// for third-sane-app invoking, added on 2022-05-19
|
2022-05-20 09:11:50 +00:00
|
|
|
|
if (handled)
|
|
|
|
|
return ret;
|
2022-05-20 06:46:25 +00:00
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
ret = writedown_device_configuration(true);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
writedown_image_configuration();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
printf_devconfig();
|
|
|
|
|
|
|
|
|
|
ret = get_scan_is_sleep();
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_DEVICE_SLEEPING)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
2022-05-17 07:04:55 +00:00
|
|
|
|
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING, SANE_EVENT_ERROR, status_);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
ret = get_scanner_paperon();
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_DEVICE_NO_PAPER)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
2022-05-17 07:04:55 +00:00
|
|
|
|
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER, SANE_EVENT_ERROR, status_);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_NO_PAPER);
|
2022-05-04 03:07:55 +00:00
|
|
|
|
return ret;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USBCB usb = {START_COMMAND, img_conf_.scannum, 0};
|
|
|
|
|
ret = writeusb(usb);
|
|
|
|
|
io_->set_timeout(500);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if(ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-06-01 09:16:09 +00:00
|
|
|
|
//status_ = SCANNER_ERR_DEVICE_BUSY;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
wait_usb_.notify();
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
2022-06-01 09:16:09 +00:00
|
|
|
|
ret = try_third_app_after_start(ret);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2022-06-01 09:16:09 +00:00
|
|
|
|
status_ = ret;
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "start result: %s\n", hg_scanner_err_name(ret));
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::stop(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
USBCB usbcb = {STOP, 0, 0};
|
|
|
|
|
ret = writeusb(usbcb);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (status_ == SCANNER_ERR_DEVICE_BUSY)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-05-30 03:04:26 +00:00
|
|
|
|
LOG_INFO(LOG_LEVEL_DEBUG_INFO,"stop status is busy\r\n");
|
2022-05-03 03:56:07 +00:00
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
|
|
|
|
}
|
|
|
|
|
//user_cancel_ = true;
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
status_ = SCANNER_ERR_DEVICE_STOPPED;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
2022-06-01 03:04:10 +00:00
|
|
|
|
final_imgs_.clear();
|
2022-05-23 03:52:53 +00:00
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
return status_;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::writeusb(USBCB &usb)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(io_lock_);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
int len = sizeof(usb);
|
|
|
|
|
|
|
|
|
|
ret = io_->write_bulk(&usb,&len);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::readusb(USBCB &usb)
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(io_lock_);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
int len = sizeof(USBCB);
|
|
|
|
|
|
|
|
|
|
ret = io_->read_bulk(&usb,&len);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::pop_image()
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
USBCB usbcb = {POP_IMAGE, 0, 0};
|
|
|
|
|
ret = writeusb(usbcb);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::get_scanner_status(USBCB &usb)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
usb = {GET_DSP_STATUS, 0, 0};
|
|
|
|
|
|
|
|
|
|
ret = writeusb(usb);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
io_->set_timeout(200); //必要延时,且不能小于这个数值
|
|
|
|
|
|
|
|
|
|
ret = readusb(usb);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2022-05-17 07:04:55 +00:00
|
|
|
|
scanner_err code = settingsdsp_300::device_status_to_hg_err(usb.u32_Data);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
return code ;
|
|
|
|
|
}
|
2022-06-01 03:04:10 +00:00
|
|
|
|
int hg_scanner_300::get_img_data(std::shared_ptr<tiny_buffer> &imagedata)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
int total = imagedata->size(),
|
2022-05-17 07:04:55 +00:00
|
|
|
|
ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
index = 0,
|
|
|
|
|
block = total;
|
|
|
|
|
|
|
|
|
|
USBCB usb{GET_IMAGE, 0, total};
|
|
|
|
|
ret = writeusb(usb);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
io_->set_timeout(500);
|
|
|
|
|
|
|
|
|
|
printf_devconfig();
|
|
|
|
|
|
|
|
|
|
while (total > 0)
|
|
|
|
|
{
|
|
|
|
|
block = 512 * 1024;
|
|
|
|
|
|
|
|
|
|
if (total < block)
|
|
|
|
|
block = total;
|
|
|
|
|
|
|
|
|
|
ret = io_->read_bulk(imagedata->data() + index,&block);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
index += block;
|
|
|
|
|
total -= block;
|
|
|
|
|
}
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
ret = save_usb_data(imagedata);
|
|
|
|
|
}
|
|
|
|
|
status_ = ret;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 03:04:10 +00:00
|
|
|
|
void hg_scanner_300::image_process(std::shared_ptr<tiny_buffer>& buffer)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
hg_imgproc::IMGPRCPARAM param;
|
|
|
|
|
hg_imgproc::HIMGPRC handle = NULL;
|
|
|
|
|
hg_imgproc::IMGHEAD ih;
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int err = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
index = 0;
|
|
|
|
|
void* buf = NULL;
|
|
|
|
|
|
|
|
|
|
param.bits = 8;
|
|
|
|
|
param.black_white = img_conf_.pixtype == COLOR_MODE_BLACK_WHITE;
|
|
|
|
|
param.channels = img_conf_.pixtype == COLOR_MODE_24_BITS ? 3 : 1;
|
|
|
|
|
param.color_mode = img_conf_.pixtype;
|
|
|
|
|
param.double_side = img_conf_.is_duplex;
|
|
|
|
|
param.dpi = img_conf_.resolution_dst;
|
|
|
|
|
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-04 08:57:05 +00:00
|
|
|
|
handle = hg_imgproc::init(&img_conf_,¶m,pid_);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
hg_imgproc::load_buffer(handle, buffer);
|
|
|
|
|
hg_imgproc::decode(handle,pid_);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////111111111111111111111111111//////////////////////////////////
|
|
|
|
|
ret = hg_imgproc::auto_crop(handle); //首次必须先调用这个算法
|
|
|
|
|
|
2022-05-19 09:37:52 +00:00
|
|
|
|
// if (img_conf_.en_sizecheck)
|
|
|
|
|
// {
|
2022-05-30 03:04:26 +00:00
|
|
|
|
// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck :%d\r\n",img_conf_.en_sizecheck);
|
2022-05-19 09:37:52 +00:00
|
|
|
|
// printf("img_conf_.en_sizecheck = %d\r\n",img_conf_.en_sizecheck);
|
|
|
|
|
// ret = hg_imgproc::size_detection(handle);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"img_conf_.en_sizecheck ret:%d\r\n",ret);
|
2022-05-19 09:37:52 +00:00
|
|
|
|
// if (ret == SCANNER_ERR_DEVICE_SIZE_CHECK)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// status_ = SCANNER_ERR_DEVICE_SIZE_CHECK;
|
|
|
|
|
// return ;
|
|
|
|
|
// }
|
2022-05-19 06:35:38 +00:00
|
|
|
|
|
2022-05-19 09:37:52 +00:00
|
|
|
|
|
|
|
|
|
// }
|
2022-05-19 06:35:38 +00:00
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
if (img_conf_.fillhole.is_fillhole)
|
|
|
|
|
{
|
|
|
|
|
ret = hg_imgproc::fillhole(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"填穿孔开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (img_conf_.is_autodiscradblank_normal || img_conf_.is_autodiscradblank_vince)
|
|
|
|
|
{
|
|
|
|
|
ret = hg_imgproc::discardBlank(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"丢弃空白页开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if(img_conf_.fadeback)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::fadeback(handle,img_conf_.fadebackrange,param.double_side);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"背景除色开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.resolution_dst != img_conf_.resolution_native)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::resolution_change(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"dpi改变开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.cropRect.enable && !img_conf_.is_autocrop)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::croprect(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"手动裁图开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.filter != ColorFilter::FILTER_NONE && (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE || img_conf_.pixtype == COLOR_MODE_256_GRAY))
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::channel(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"除色开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
/////////////////////////////////////2222222222222222222222222222222222222//////////////////////////////////
|
2022-05-07 10:25:03 +00:00
|
|
|
|
int tableLength ;//= sizeof(custom_gamma_val_->table)/sizeof(custom_gamma_val_->table[0]);
|
|
|
|
|
|
2022-05-09 07:02:00 +00:00
|
|
|
|
unsigned char buffer_re[256 *3];
|
2022-05-07 10:25:03 +00:00
|
|
|
|
if (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE || img_conf_.pixtype == COLOR_MODE_256_GRAY)
|
|
|
|
|
tableLength = 256;
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-05-07 10:42:43 +00:00
|
|
|
|
|
2022-05-07 10:25:03 +00:00
|
|
|
|
tableLength = 768;
|
|
|
|
|
int index=0;
|
2022-05-09 08:59:22 +00:00
|
|
|
|
const int buffersize = 256;
|
2022-05-07 10:42:43 +00:00
|
|
|
|
|
|
|
|
|
unsigned char buf_01[buffersize];
|
|
|
|
|
memcpy(buf_01,custom_gamma_val_->table + index,buffersize);
|
|
|
|
|
index += buffersize;
|
2022-05-07 10:25:03 +00:00
|
|
|
|
|
2022-05-07 10:42:43 +00:00
|
|
|
|
unsigned char buf_02[buffersize];
|
|
|
|
|
memcpy(buf_02,custom_gamma_val_->table + index,buffersize);
|
|
|
|
|
index += buffersize;
|
2022-05-07 10:25:03 +00:00
|
|
|
|
|
2022-05-07 10:42:43 +00:00
|
|
|
|
unsigned char buf_03[buffersize];
|
|
|
|
|
memcpy(buf_03,custom_gamma_val_->table + index,buffersize);
|
|
|
|
|
index += buffersize;
|
2022-05-07 10:25:03 +00:00
|
|
|
|
|
2022-05-09 07:02:00 +00:00
|
|
|
|
int j = 0;
|
|
|
|
|
for (size_t i = 0;i < buffersize;i++)
|
2022-05-07 10:25:03 +00:00
|
|
|
|
{
|
2022-05-09 07:02:00 +00:00
|
|
|
|
memcpy(buffer_re + j,buf_01 + i,1);
|
|
|
|
|
memcpy(buffer_re + (++j),buf_02 + i,1);
|
|
|
|
|
memcpy(buffer_re + (++j),buf_03 + i,1);
|
2022-05-07 10:25:03 +00:00
|
|
|
|
++j;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-09 07:02:00 +00:00
|
|
|
|
|
|
|
|
|
hg_imgproc::customgamma(handle,custom_gamma_,buffer_re,tableLength);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
if (img_conf_.pixtype == COLOR_MODE_24_BITS && img_conf_.hsvcorrect)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::answerSheetFilterRed(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"答题卡出红开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.refuseInflow)
|
|
|
|
|
{
|
2022-05-07 07:39:48 +00:00
|
|
|
|
int lv = 5;
|
|
|
|
|
|
|
|
|
|
if (image_prc_param_.bits.is_permeate_lv_ == 0)
|
|
|
|
|
lv = 5;
|
|
|
|
|
else if (image_prc_param_.bits.is_permeate_lv_ == 1)
|
|
|
|
|
lv = 15;
|
|
|
|
|
else if (image_prc_param_.bits.is_permeate_lv_ == 2)
|
|
|
|
|
lv = 25;
|
|
|
|
|
else if (image_prc_param_.bits.is_permeate_lv_ == 3)
|
|
|
|
|
lv = 35;
|
|
|
|
|
else if (image_prc_param_.bits.is_permeate_lv_ == 4)
|
|
|
|
|
lv = 45;
|
|
|
|
|
|
|
|
|
|
hg_imgproc::antiInflow(handle,lv);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
if (img_conf_.colorCorrection && img_conf_.pixtype != COLOR_MODE_BLACK_WHITE)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::colorCorrection(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"颜色校正开启\r\n");
|
|
|
|
|
}
|
2022-05-11 03:27:11 +00:00
|
|
|
|
|
|
|
|
|
if ((img_conf_.imageRotateDegree != TEXT_DIRECTION_0 || img_conf_.is_backrotate180) && (!img_conf_.is_autotext))
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
hg_imgproc::orentation(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"自动旋转开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.removeMorr)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::textureRemove(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"除摩尔纹开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.detachnoise.is_detachnoise)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::nosieDetach(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"噪点优化开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::errorextention(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"黑白图处理开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.en_fold)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::fold(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"对折开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
|
|
|
|
if (img_conf_.multi_output_red && img_conf_.pixtype == COLOR_MODE_24_BITS)
|
|
|
|
|
{
|
|
|
|
|
err = hg_imgproc::multi_out_red(handle);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"多流出红开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (img_conf_.sharpen)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::sharpenType(handle);
|
|
|
|
|
}
|
|
|
|
|
if (image_prc_param_.bits.split)
|
|
|
|
|
{
|
|
|
|
|
int colormode=1;
|
|
|
|
|
if(img_conf_.filter == RID_COLOR_NONE)
|
|
|
|
|
colormode=img_conf_.pixtype;
|
|
|
|
|
|
|
|
|
|
err = hg_imgproc::split(handle,img_conf_.multiOutput,img_conf_.splitImage,img_conf_.multi_output_red,colormode,img_conf_.is_duplex);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "img split-> multiOutput is:%d splitImage is:%d multi_output_red is:%d pixtype is:%d is_duplex:%d\r\n"
|
2022-05-03 03:56:07 +00:00
|
|
|
|
,img_conf_.multiOutput
|
|
|
|
|
,img_conf_.splitImage
|
|
|
|
|
,img_conf_.multi_output_red
|
|
|
|
|
,img_conf_.pixtype
|
|
|
|
|
,img_conf_.is_duplex);
|
|
|
|
|
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"图像拆分开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 03:47:44 +00:00
|
|
|
|
if (!image_prc_param_.bits.split || !image_prc_param_.bits.rid_red || !is_multiout)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
if(img_conf_.automaticcolor)
|
|
|
|
|
{
|
|
|
|
|
hg_imgproc::auto_matic_color(handle,img_conf_.automaticcolortype);
|
|
|
|
|
//HG_LOGHG_LOG_LEVEL_DEBUG_INFO,"颜色自动识别开启\r\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-11 03:27:11 +00:00
|
|
|
|
if (img_conf_.is_autotext)
|
|
|
|
|
{
|
|
|
|
|
printf("文本方向自动识别\r\n");
|
|
|
|
|
hg_imgproc::ocr_auto_txtdirect(handle);
|
|
|
|
|
}
|
2022-05-21 08:56:14 +00:00
|
|
|
|
//多流输出最后处理
|
|
|
|
|
if (is_multiout)
|
|
|
|
|
{
|
2022-05-23 08:54:55 +00:00
|
|
|
|
int multi_out = image_prc_param_.bits.multi_out;
|
2022-05-21 08:56:14 +00:00
|
|
|
|
err = hg_imgproc::multi_out(handle,multi_out);
|
|
|
|
|
}
|
2022-05-03 03:56:07 +00:00
|
|
|
|
hg_imgproc::final(handle);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
while (hg_imgproc::get_final_data(handle, &ih, &buf, index++) == SCANNER_ERR_OK && !user_cancel_)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_5(LOG_LEVEL_DEBUG_INFO, "Final picture %d (%d * %d * %d) with %u bytes!\n", index
|
2022-05-03 03:56:07 +00:00
|
|
|
|
, ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes);
|
|
|
|
|
|
|
|
|
|
if(!img_type_.empty())
|
|
|
|
|
{
|
|
|
|
|
std::vector<unsigned char>bmpdata;
|
|
|
|
|
//cv::imencode(img_type_,*((cv::Mat*)buf),bmpdata);
|
|
|
|
|
hg_imgproc::imgtypechange(handle,img_type_,buf,bmpdata);
|
|
|
|
|
if(bmpdata.empty())
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
status_ = SCANNER_ERR_NO_DATA;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
buf = bmpdata.data();
|
|
|
|
|
ih.total_bytes = bmpdata.size();
|
|
|
|
|
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_6(LOG_LEVEL_DEBUG_INFO, "Set img type is:%s Final picture %d (%d * %d * %d) with %u bytes!\n",img_type_.c_str() ,index
|
2022-05-03 03:56:07 +00:00
|
|
|
|
, ih.width, ih.height, ih.bits * ih.channels, ih.total_bytes);
|
|
|
|
|
}
|
|
|
|
|
save_final_image(&ih, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hg_imgproc::release(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::writedown_device_configuration(bool type,HGSCANCONF_G400 *d)
|
|
|
|
|
{
|
|
|
|
|
if (!type)
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
|
d = &dsp_config;
|
|
|
|
|
|
|
|
|
|
USBCB usbcb = {CONFIGURED_DATA, d->value, 0};
|
|
|
|
|
len = sizeof(USBCB);
|
|
|
|
|
ret = io_->write_bulk(&usbcb,&len);
|
|
|
|
|
|
2022-05-30 03:42:16 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "writedown_device_configuration is .(%s)\n", hg_scanner_err_name(ret));
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::on_color_mode_changed(int& color_mode)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
// if ((((color_mode == COLOR_MODE_24_BITS || color_mode == COLOR_MODE_AUTO_MATCH) && !dsp_config.params.color) ||
|
|
|
|
|
// ((color_mode != COLOR_MODE_24_BITS && color_mode != COLOR_MODE_AUTO_MATCH) && dsp_config.params.color)) && color_mode != -1)
|
|
|
|
|
// {
|
|
|
|
|
// printf("color_mode111111111111111111111 =%d\r\n",color_mode);
|
|
|
|
|
// dsp_config.params.color ^= 1;
|
|
|
|
|
|
|
|
|
|
// //ret = writedown_device_configuration();
|
|
|
|
|
// printf("on_color_mode_changed ret =%d\r\n",ret);
|
|
|
|
|
// if(ret)
|
|
|
|
|
// dsp_config.params.color ^= 1;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (color_mode == COLOR_MODE_BLACK_WHITE || color_mode == COLOR_MODE_256_GRAY)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.isColor = 0;
|
|
|
|
|
}
|
|
|
|
|
else if(color_mode == COLOR_MODE_24_BITS || color_mode == COLOR_MODE_AUTO_MATCH)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.isColor = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HGSCANCONF_G400 d = dsp_config;
|
|
|
|
|
if(image_prc_param_.bits.rid_color != RID_COLOR_NONE && image_prc_param_.bits.color_mode == COLOR_MODE_256_GRAY && color_mode == -1)
|
|
|
|
|
{
|
|
|
|
|
d.params.isColor = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (image_prc_param_.bits.rid_color == RID_COLOR_NONE && image_prc_param_.bits.color_mode == COLOR_MODE_256_GRAY && color_mode == -1)
|
|
|
|
|
{
|
|
|
|
|
d.params.isColor = 0;
|
|
|
|
|
}
|
|
|
|
|
if(color_mode == -1)
|
|
|
|
|
ret = writedown_device_configuration(false,&d);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::on_paper_changed(int& paper)
|
|
|
|
|
{
|
|
|
|
|
bool exact = true;
|
|
|
|
|
int ind = settingsdsp_300::match_best_paper(paper, &exact, &paper_size_),
|
2022-05-17 07:04:55 +00:00
|
|
|
|
ret = exact ? SCANNER_ERR_OK : SCANNER_ERR_NOT_EXACT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
if (dsp_config.params.pageSize != settingsdsp_300::paper_map[ind].dev_value)
|
|
|
|
|
{
|
|
|
|
|
int old = dsp_config.params.pageSize;
|
|
|
|
|
|
|
|
|
|
dsp_config.params.pageSize = settingsdsp_300::paper_map[ind].dev_value;
|
|
|
|
|
ret = writedown_device_configuration();
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.pageSize = old;
|
|
|
|
|
for (int i = 0; i < ARRAY_SIZE(settingsdsp_300::paper_map); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (settingsdsp_300::paper_map[i].dev_value == old)
|
|
|
|
|
{
|
|
|
|
|
paper = settingsdsp_300::paper_map[i].paper;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!exact)
|
2022-05-17 07:04:55 +00:00
|
|
|
|
ret = SCANNER_ERR_NOT_EXACT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::on_paper_check_changed(bool& check)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
if(dsp_config.params.sizedetece ^ check)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.sizedetece = check;
|
|
|
|
|
ret = writedown_device_configuration();
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.sizedetece = !check;
|
|
|
|
|
check = dsp_config.params.sizedetece;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::on_resolution_changed(int& dpi)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
dsp_config.params.dpi = 1;
|
|
|
|
|
ret = writedown_device_configuration();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::on_ultrasonic_check_changed(bool& check)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
if (dsp_config.params.doubleFeeded ^ check)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.doubleFeeded = check;
|
|
|
|
|
ret = writedown_device_configuration();
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.doubleFeeded = !check;
|
|
|
|
|
check = dsp_config.params.doubleFeeded;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::agreement(TwSS tw,int align)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
SIZE size;
|
|
|
|
|
HGSCANCONF_G400 d = dsp_config;
|
|
|
|
|
size = papersize.GetPaperSize(TwSS::A4,200,align);
|
|
|
|
|
dsp_config.params.dstHeight = (int)((size.cy + 200)/100);
|
|
|
|
|
if (img_conf_.is_autocrop)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.pageSize = G400_AUTO;
|
|
|
|
|
}
|
|
|
|
|
if (img_conf_.filter != 3)
|
|
|
|
|
{
|
|
|
|
|
d.params.isColor = 1;
|
|
|
|
|
}
|
|
|
|
|
ret = writedown_device_configuration(true,&d);
|
|
|
|
|
io_->set_timeout(200);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::initdevice()
|
|
|
|
|
{
|
|
|
|
|
dsp_config.value = 0;
|
|
|
|
|
dsp_config.params.enableLed = 1;
|
|
|
|
|
dsp_config.params.isCorrect = 1;
|
|
|
|
|
dsp_config.params.reversed1 = 0;
|
|
|
|
|
dsp_config.params.reversed2 = 0;
|
|
|
|
|
dsp_config.params.sizedetece =0;
|
|
|
|
|
writedown_device_configuration(true);
|
|
|
|
|
printf_devconfig();
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void hg_scanner_300::writedown_image_configuration(void)
|
|
|
|
|
{
|
|
|
|
|
SCANCONF ic;
|
|
|
|
|
|
|
|
|
|
ic.papertype = paper_size_;
|
|
|
|
|
|
|
|
|
|
if (is_lateral(image_prc_param_.bits.paper))
|
|
|
|
|
ic.paperAlign = Rot270;
|
|
|
|
|
else if (image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO)
|
|
|
|
|
ic.paperAlign = AutoTextOrientation;
|
|
|
|
|
else
|
|
|
|
|
ic.paperAlign = Rot0;
|
|
|
|
|
|
|
|
|
|
ic.en_sizecheck = dsp_config.params.sizedetece;
|
2022-05-11 03:27:11 +00:00
|
|
|
|
|
|
|
|
|
if (image_prc_param_.bits.text_direction != TEXT_DIRECTION_AUTO)
|
|
|
|
|
ic.imageRotateDegree = image_prc_param_.bits.text_direction;
|
|
|
|
|
else
|
|
|
|
|
ic.imageRotateDegree = 0;
|
|
|
|
|
|
2022-05-03 03:56:07 +00:00
|
|
|
|
ic.is_duplex = (image_prc_param_.bits.page == PAGE_DOUBLE || image_prc_param_.bits.page == PAGE_OMIT_EMPTY ||
|
|
|
|
|
image_prc_param_.bits.page == PAGE_OMIT_EMPTY_RECEIPT || image_prc_param_.bits.page ==PAGE_FOLIO);
|
|
|
|
|
|
|
|
|
|
ic.en_fold = (image_prc_param_.bits.page == PAGE_FOLIO);
|
|
|
|
|
ic.pixtype = image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH ? 2 : image_prc_param_.bits.color_mode;
|
|
|
|
|
ic.automaticcolor = is_auto_matic_color;
|
|
|
|
|
ic.automaticcolortype = 1;// ic.pixtype; //存疑
|
|
|
|
|
ic.resolution_dst = resolution_;
|
|
|
|
|
ic.resolution_native = 200;
|
|
|
|
|
ic.gamma = (float)gamma_;
|
|
|
|
|
ic.contrast = (float)contrast_ ;
|
|
|
|
|
ic.brightness = (float)bright_ ;
|
|
|
|
|
ic.threshold = threshold_;
|
|
|
|
|
ic.is_autocontrast = 0; //无参数
|
|
|
|
|
ic.is_autocrop = (ic.papertype == TwSS::None || ic.papertype ==TwSS::USStatement);
|
|
|
|
|
ic.is_autodiscradblank_normal = image_prc_param_.bits.page == PAGE_OMIT_EMPTY;
|
|
|
|
|
ic.discardblank_percent = omit_empty_level_ > 70 ? 70 : omit_empty_level_; //默认20
|
|
|
|
|
ic.is_autodiscradblank_vince = image_prc_param_.bits.page == PAGE_OMIT_EMPTY_RECEIPT;
|
|
|
|
|
ic.is_switchfrontback = image_prc_param_.bits.exchange;
|
|
|
|
|
ic.autodescrew = image_prc_param_.bits.automatic_skew;
|
|
|
|
|
ic.multi_output_red = image_prc_param_.bits.rid_red;
|
|
|
|
|
ic.hsvcorrect = image_prc_param_.bits.rid_answer_red;
|
|
|
|
|
|
|
|
|
|
ic.sharpen = image_prc_param_.bits.sharpen;
|
|
|
|
|
//ic.enhance_color = image_prc_param_.bits.rid_color;
|
|
|
|
|
ic.fillbackground = image_prc_param_.bits.erase_black_frame;
|
|
|
|
|
ic.is_convex = (image_prc_param_.bits.fill_background == FILL_BKG_CONVEX_POLYGON);
|
|
|
|
|
ic.noise = image_prc_param_.bits.noise_optimize;
|
|
|
|
|
ic.indent = margin_;
|
|
|
|
|
ic.AutoCrop_threshold = threshold_;
|
|
|
|
|
if (test_1_paper_)
|
|
|
|
|
{
|
2022-05-30 03:04:26 +00:00
|
|
|
|
LOG_INFO(LOG_LEVEL_DEBUG_INFO, "scanning mode: testing ONE paper ...\n");
|
2022-05-03 03:56:07 +00:00
|
|
|
|
ic.scannum = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ic.scannum = scan_count_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ic.is_backrotate180 = image_prc_param_.bits.rotate_back_180;
|
|
|
|
|
ic.is_dogeardetection = image_prc_param_.bits.fractate_check;
|
|
|
|
|
ic.hardwarecaps.en_skrewdetect = 0;
|
|
|
|
|
ic.hardwarecaps.en_doublefeed = dsp_config.params.doubleFeeded;
|
|
|
|
|
ic.hardwarecaps.en_stapledetect = 0;
|
|
|
|
|
ic.hardwarecaps.skrewdetectlevel = 0;
|
|
|
|
|
// ic.hardwarecaps.is_autopaper = dsp_config.params.is_autopaper;
|
|
|
|
|
ic.hardwarecaps.capturepixtype = 0; //暂无参数 获取图像类型
|
|
|
|
|
ic.hardwarecaps.lowpowermode = LowPowerMode::Min_None; //暂无参数 设置休眠时间 两个参数3399未使用
|
|
|
|
|
ic.fillhole.is_fillhole = image_prc_param_.bits.rid_hole;
|
|
|
|
|
ic.fillhole.fillholeratio = rid_hole_range_;
|
|
|
|
|
ic.detachnoise.is_detachnoise = image_prc_param_.bits.noise_optimize;
|
|
|
|
|
ic.detachnoise.detachnoise = noise_range_;
|
2022-05-11 03:27:11 +00:00
|
|
|
|
ic.is_autotext = image_prc_param_.bits.text_direction == TEXT_DIRECTION_AUTO ? 1 :0;
|
2022-05-20 07:53:40 +00:00
|
|
|
|
ic.isfillcolor = is_color_fill;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
ic.refuseInflow = image_prc_param_.bits.is_permeate;
|
|
|
|
|
ic.colorCorrection = 0;
|
|
|
|
|
ic.removeMorr = image_prc_param_.bits.remove_morr;
|
|
|
|
|
ic.errorExtention = image_prc_param_.bits.error_extention ;//暂无参数
|
|
|
|
|
ic.textureRemove = image_prc_param_.bits.remove_txtture;//暂无参数
|
|
|
|
|
ic.splitImage = image_prc_param_.bits.split;
|
2022-05-07 07:39:48 +00:00
|
|
|
|
ic.cropRect.enable = custom_area_;
|
2022-05-16 09:56:07 +00:00
|
|
|
|
int height = (custom_area_br_y_ *ic.resolution_dst) /25.4 - (custom_area_lt_y_ *ic.resolution_dst /25.4);
|
|
|
|
|
int width = (custom_area_br_x_ *ic.resolution_dst) /25.4 - (custom_area_lt_x_ *ic.resolution_dst /25.4);
|
|
|
|
|
ic.cropRect.height = height;
|
|
|
|
|
ic.cropRect.width = width;
|
2022-05-07 07:39:48 +00:00
|
|
|
|
ic.cropRect.x = custom_area_lt_x_ *ic.resolution_dst /25.4;
|
|
|
|
|
ic.cropRect.y = custom_area_lt_y_ *ic.resolution_dst /25.4;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
ic.multiOutput = MultiOutput::Unused; //暂无参数
|
|
|
|
|
ic.normalCrop = image_prc_param_.bits.dark_sample;
|
|
|
|
|
ic.dogeardistabce = fractate_level_;
|
|
|
|
|
ic.fadeback = image_prc_param_.bits.erase_bakground;
|
|
|
|
|
ic.fadebackrange = erase_bkg_range_;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int filter_clr[] = { 3, 0, 1, 2, 5, 6, 7 };
|
|
|
|
|
if(image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH)
|
|
|
|
|
ic.filter = 3;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ic.filter = filter_clr[image_prc_param_.bits.rid_color];
|
|
|
|
|
// if(ic.filter != 3)
|
|
|
|
|
// ic.pixtype = 2;
|
|
|
|
|
|
|
|
|
|
ic.hsvcorrect = 0;
|
|
|
|
|
ic.multi_output_red = 0;
|
|
|
|
|
ic.multiOutput = MultiOutput::Unused;
|
|
|
|
|
ic.fadeback = false;
|
|
|
|
|
}
|
2022-06-02 03:47:44 +00:00
|
|
|
|
if (image_prc_param_.bits.multi_out == MULTI_GRAY_AND_BW && is_multiout)
|
2022-05-16 09:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
ic.pixtype = 1;
|
|
|
|
|
}
|
2022-06-02 03:47:44 +00:00
|
|
|
|
else if ((image_prc_param_.bits.multi_out == MULTI_OUT_ALL ||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_GRAY||image_prc_param_.bits.multi_out == MULTI_COLOR_AND_BW) && is_multiout)
|
|
|
|
|
{
|
|
|
|
|
ic.pixtype = 2;
|
|
|
|
|
}
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
img_conf_ = ic;
|
|
|
|
|
|
|
|
|
|
int ret = agreement((TwSS)img_conf_.papertype,img_conf_.paperAlign);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
status_ = ret;
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.pixtype=%d", ic.pixtype);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.papertype=%d", ic.papertype);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.AutoCrop_threshold=%d", ic.AutoCrop_threshold);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.autodescrew=%d", ic.autodescrew);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.automaticcolor=%d", ic.automaticcolor);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.brightness=%f", ic.brightness);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.contrast=%f", ic.contrast);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_fold=%d", ic.en_fold);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.en_sizecheck=%d", ic.en_sizecheck);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.enhance_color=%d", ic.enhance_color);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillbackground=%d", ic.fillbackground);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.filter=%d", ic.filter);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.gamma=%f", ic.gamma);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.capturepixtype=%d", ic.hardwarecaps.capturepixtype);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hardwarecaps.en_doublefeed=%d", ic.hardwarecaps.en_doublefeed);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.hsvcorrect=%d", ic.hsvcorrect);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.imageRotateDegree=%f", ic.imageRotateDegree);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.indent=%d", 5);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocontrast=%d", ic.is_autocontrast);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autocrop=%d", ic.is_autocrop);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_normal=%d", ic.is_autodiscradblank_normal);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autodiscradblank_vince=%d", ic.is_autodiscradblank_vince);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_autotext=%d", ic.is_autotext);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_backrotate180=%d", ic.is_backrotate180);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_convex=%d", ic.is_convex);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_duplex=%d", ic.is_duplex);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_switchfrontback=%d", ic.is_switchfrontback);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.is_dogeardetection=%d", ic.is_dogeardetection);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.multi_output_red=%d", ic.multi_output_red);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.noise=%d", 8);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_dst=%f", ic.resolution_dst);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.resolution_native=%f", ic.resolution_native);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.scannum=%d", ic.scannum);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.sharpen=%d", ic.sharpen);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.discardblank_percent=%d", ic.discardblank_percent);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.is_detachnoise=%d", ic.detachnoise.is_detachnoise);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.detachnoise=%d\r ", ic.detachnoise.detachnoise);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.detachnoise.refuseInflow=%d\r ", ic.refuseInflow);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.refuseInflow=%d\r ", ic.refuseInflow);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.removeMorr=%d\r ", ic.removeMorr);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.errorExtention=%d\r ", ic.errorExtention);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.textureRemove=%d\r\n ", ic.textureRemove);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fillhole.is_fillhole=%d\r\n ", ic.fillhole.is_fillhole);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.ic.fillhole.fillholeratio=%f\r\n ", ic.fillhole.fillholeratio);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.fadeback=%d\r\n ",ic.fadeback);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.enable=%d\r\n ",ic.cropRect.enable);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.height=%d\r\n ",ic.cropRect.height);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.width=%d\r\n ",ic.cropRect.width);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.x=%d\r\n ",ic.cropRect.x);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\n ic.cropRect.y=%d\r\n ",ic.cropRect.y);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void hg_scanner_300::printf_devconfig(HGSCANCONF_G400 *d)
|
|
|
|
|
{
|
|
|
|
|
io_->set_timeout(200);
|
|
|
|
|
if (!d)
|
|
|
|
|
d = &dsp_config;
|
|
|
|
|
|
2022-05-30 03:04:26 +00:00
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"\r\ndsp_config.params.doubleFeeded:%d\r\n",d->params.doubleFeeded);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dpi:%d\r\n",d->params.dpi);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.dstHeight:%d\r\n",d->params.dstHeight);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableLed:%d\r\n",d->params.enableLed);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.enableUV:%d\r\n",d->params.enableUV);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isColor:%d\r\n",d->params.isColor);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.isCorrect:%d\r\n",d->params.isCorrect);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.pageSize:%d\r\n",d->params.pageSize);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed1:%d\r\n",d->params.reversed1);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.reversed2:%d\r\n",d->params.reversed2);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.sizedetece:%d\r\n",d->params.sizedetece);
|
|
|
|
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"dsp_config.params.value:%d\r\n",d->value);
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string hg_scanner_300::get_firmware_version()
|
|
|
|
|
{
|
|
|
|
|
char buf[20] = { 0 };
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 10; //协议定义长度为10 100 200 =8
|
|
|
|
|
USBCB cmd = {GET_FW_VERSION,len,0,};
|
|
|
|
|
|
|
|
|
|
ret = writeusb(cmd);
|
|
|
|
|
ret = io_->read_bulk(buf, &len);
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string hg_scanner_300::get_serial_num()
|
|
|
|
|
{
|
|
|
|
|
string SerialNum = "";
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 14;
|
|
|
|
|
SerialNum.resize(len);
|
|
|
|
|
|
|
|
|
|
USBCB cmd = {GET_SERIAL,len,0,};
|
|
|
|
|
ret = writeusb(cmd);
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(io_lock_);
|
|
|
|
|
ret = io_->read_bulk(&SerialNum[0],&len);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
return "0000000000000000000";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SerialNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::set_leaflet_scan(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
test_1_paper_ = true;
|
|
|
|
|
|
|
|
|
|
ret = start();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_abuot_info(void)
|
|
|
|
|
{
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::restore_default_setting(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_final_image_format(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::get_compression_format(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_compression_format(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_auto_color_type(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::get_device_code(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_sleep_time(SANE_Power* getime)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
|
|
USBCB usbcb = {GET_SLEEP_TIME, 0, 0};
|
|
|
|
|
ret = writeusb(usbcb);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
len = sizeof(usbcb);
|
|
|
|
|
ret = io_->read_bulk(&usbcb,&len);
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (getime)
|
|
|
|
|
{
|
|
|
|
|
*getime = (SANE_Power)usbcb.u32_Data;
|
|
|
|
|
}
|
|
|
|
|
if (usbcb.u32_Data)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_SLEEPING;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_sleep_time(SANE_Power* setime)
|
|
|
|
|
{
|
|
|
|
|
if (!setime)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_NO_DATA;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
time = *setime;
|
|
|
|
|
USBCB usbcb = {SET_SLEEP_TIME,time, 0};
|
|
|
|
|
|
|
|
|
|
ret = writeusb(usbcb);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::get_dogear_distance(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_dogear_distance(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_scanner_paperon(SANE_Bool* paperon)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
|
|
USBCB usbcb = {GET_PAPER_STATUS, 0, 0};
|
|
|
|
|
len = sizeof(USBCB);
|
|
|
|
|
ret = writeusb(usbcb);
|
|
|
|
|
io_->set_timeout(500);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
ret = io_->read_bulk(&usbcb,&len);
|
|
|
|
|
}
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
if (usbcb.u32_Data == 0)
|
2022-05-17 07:04:55 +00:00
|
|
|
|
ret = SCANNER_ERR_DEVICE_NO_PAPER;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
else
|
2022-05-17 07:04:55 +00:00
|
|
|
|
ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
if (paperon)
|
|
|
|
|
{
|
|
|
|
|
*paperon = usbcb.u32_Data;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_scan_when_paper_on(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_scan_when_paper_on(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_scan_with_hole(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::set_scan_with_hole(void)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::get_scan_is_sleep()
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK,
|
2022-05-03 03:56:07 +00:00
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
|
|
USBCB usbcb = {0x100, 0, 0};
|
|
|
|
|
len = sizeof(USBCB);
|
|
|
|
|
ret = writeusb(usbcb);
|
|
|
|
|
|
|
|
|
|
io_->set_timeout(200);
|
|
|
|
|
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret == SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
ret = io_->read_bulk(&usbcb,&len);
|
|
|
|
|
}
|
2022-05-17 07:04:55 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
if (usbcb.u32_Data == 0x10)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
else if (usbcb.u32_Data == 0x100)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_SLEEPING;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///此款设备无此功能
|
|
|
|
|
int hg_scanner_300::on_staple_check_changed(bool& check)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::on_skew_check_changed(bool& check)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
int hg_scanner_300::on_skew_check_level_changed(int& check)
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hg_scanner_300::agreement()
|
|
|
|
|
{
|
2022-05-17 07:04:55 +00:00
|
|
|
|
int ret = SCANNER_ERR_OK;
|
2022-05-03 03:56:07 +00:00
|
|
|
|
|
|
|
|
|
if (image_prc_param_.bits.rid_color != RID_COLOR_NONE)
|
|
|
|
|
{
|
|
|
|
|
dsp_config.params.isColor = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = writedown_device_configuration(true);
|
|
|
|
|
io_->set_timeout(200);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|