图像包头增加从采集指令到最后输出的总时间;优化中间文件存储名称;延长升降台等待时间及出纸时间等待;CIS缓冲区小于3的时候等待;图像线程增加到4个
This commit is contained in:
parent
bf939b8c96
commit
d4fa615534
|
@ -1,11 +1,25 @@
|
||||||
{
|
{
|
||||||
|
"crop": {
|
||||||
|
"cat": "imgp",
|
||||||
|
"group": "imgp",
|
||||||
|
"title": "裁切",
|
||||||
|
"desc": "按图片大小裁切",
|
||||||
|
"type": "bool",
|
||||||
|
"pos": 30,
|
||||||
|
"ui-pos": -1,
|
||||||
|
"auth": 0,
|
||||||
|
"size": 4,
|
||||||
|
"cur": true,
|
||||||
|
"default": true,
|
||||||
|
"depend": "page!=对折"
|
||||||
|
},
|
||||||
"is-anti-skew": {
|
"is-anti-skew": {
|
||||||
"cat": "imgp",
|
"cat": "imgp",
|
||||||
"group": "imgp",
|
"group": "imgp",
|
||||||
"title": "自动纠偏",
|
"title": "自动纠偏",
|
||||||
"desc": "自动纠正歪斜送入的文稿图像",
|
"desc": "自动纠正歪斜送入的文稿图像",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"pos": 30,
|
"pos": 33,
|
||||||
"fix-id": 34844,
|
"fix-id": 34844,
|
||||||
"ui-pos": -1,
|
"ui-pos": -1,
|
||||||
"auth": 0,
|
"auth": 0,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -94,8 +94,8 @@ class scanner_hw : public sane_opt_provider
|
||||||
std::map<std::string, std::function<void(void*)>> opt_handler_;
|
std::map<std::string, std::function<void(void*)>> opt_handler_;
|
||||||
|
|
||||||
|
|
||||||
int to_lifter_ = 5000; // timeout in ms of lifter arrived
|
int to_lifter_ = 10000; // timeout in ms of lifter arrived
|
||||||
int to_paper_out_ = 3000; // timeout in ms of paper passed
|
int to_paper_out_ = 5000; // timeout in ms of paper passed
|
||||||
int to_stream_ = 5000; // timeout in ms of frame data can be read
|
int to_stream_ = 5000; // timeout in ms of frame data can be read
|
||||||
|
|
||||||
void init(void);
|
void init(void);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
static std::string device_opt_json[] = {
|
static std::string device_opt_json[] = {
|
||||||
"{\"is-anti-skew\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"pos\":30,\"fix-id\":34844,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":true,\"default\":true,\"depend\":\"page!=\\u5bf9\\u6298\"},\"is-erase-black-frame\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"pos\":35,\"fix-id\":34849,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":true,\"default\":true},\"bkg-fill-mode\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"type\":\"string\",\"pos\":36,\"fix-id\":34854,\"ui-pos\":-1,\"auth\":0,\"size\":16,\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend\":\"is-erase-black-frame==true\"},\"threshold\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c\\uff0c\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"pos\":37,\"fix-id\":34851,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":40,\"default\":40,\"range\":{\"min\":30,\"max\":50,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"anti-noise-level\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"pos\":38,\"fix-id\":34852,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":8,\"default\":8,\"range\":{\"min\":2,\"max\":20,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"margin\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"pos\":40,\"fix-id\":34853,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":5,\"default\":5,\"range\":{\"min\":2,\"max\":30,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"paper\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"type\":\"string\",\"pos\":1000,\"fix-id\":34831,\"ui-pos\":-1,\"auth\":0,\"size\":44,\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"range\":[\"A3\",\"8\\u5f00\",\"A4\",\"16\\u5f00\",\"A5\",\"A6\",\"B4\",\"B5\",\"B6\",\"Letter\",\"Double Letter\",\"LEGAL\",\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",{\"resolution<500\":\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\"},{\"resolution<500\":\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\"},{\"resolution<500\":\"\\u4e09\\u8054\\u8bd5\\u5377\"}]},\"lateral\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u6a2a\\u5411\",\"desc\":\"\\u6a2a\\u5411\\u653e\\u7f6e\\u7eb8\\u5f20\",\"type\":\"bool\",\"pos\":1000,\"fix-id\":34924,\"ui-pos\":-1,\"auth\":0,\"affect\":6,\"visible\":0,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"paper==A4 || paper==16\\u5f00 || paper==A5 || paper==A6 || paper==B5 || paper==B6 || paper==Letter\"}}"
|
"{\"crop\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u88c1\\u5207\",\"desc\":\"\\u6309\\u56fe\\u7247\\u5927\\u5c0f\\u88c1\\u5207\",\"type\":\"bool\",\"pos\":30,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":true,\"default\":true,\"depend\":\"page!=\\u5bf9\\u6298\"},\"is-anti-skew\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"type\":\"bool\",\"pos\":33,\"fix-id\":34844,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":true,\"default\":true,\"depend\":\"page!=\\u5bf9\\u6298\"},\"is-erase-black-frame\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"pos\":35,\"fix-id\":34849,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":true,\"default\":true},\"bkg-fill-mode\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"type\":\"string\",\"pos\":36,\"fix-id\":34854,\"ui-pos\":-1,\"auth\":0,\"size\":16,\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend\":\"is-erase-black-frame==true\"},\"threshold\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c\\uff0c\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"pos\":37,\"fix-id\":34851,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":40,\"default\":40,\"range\":{\"min\":30,\"max\":50,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"anti-noise-level\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"pos\":38,\"fix-id\":34852,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":8,\"default\":8,\"range\":{\"min\":2,\"max\":20,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"margin\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"pos\":40,\"fix-id\":34853,\"ui-pos\":-1,\"auth\":0,\"size\":4,\"cur\":5,\"default\":5,\"range\":{\"min\":2,\"max\":30,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"paper\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"type\":\"string\",\"pos\":1000,\"fix-id\":34831,\"ui-pos\":-1,\"auth\":0,\"size\":44,\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"range\":[\"A3\",\"8\\u5f00\",\"A4\",\"16\\u5f00\",\"A5\",\"A6\",\"B4\",\"B5\",\"B6\",\"Letter\",\"Double Letter\",\"LEGAL\",\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",{\"resolution<500\":\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\"},{\"resolution<500\":\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\"},{\"resolution<500\":\"\\u4e09\\u8054\\u8bd5\\u5377\"}]},\"lateral\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u6a2a\\u5411\",\"desc\":\"\\u6a2a\\u5411\\u653e\\u7f6e\\u7eb8\\u5f20\",\"type\":\"bool\",\"pos\":1000,\"fix-id\":34924,\"ui-pos\":-1,\"auth\":0,\"affect\":6,\"visible\":0,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"paper==A4 || paper==16\\u5f00 || paper==A5 || paper==A6 || paper==B5 || paper==B6 || paper==Letter\"}}"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue)
|
static void myWarpAffine(cv::InputArray _src, cv::OutputArray _dst, cv::InputArray _M0, cv::Size dsize, int flags, int borderType, const cv::Scalar& borderValue)
|
||||||
|
@ -66,9 +66,13 @@ auto_crop::~auto_crop()
|
||||||
|
|
||||||
void auto_crop::init(void)
|
void auto_crop::init(void)
|
||||||
{
|
{
|
||||||
|
OPTION_FUNC(crop)
|
||||||
|
{
|
||||||
|
enabled_ = *(bool*)val;
|
||||||
|
};
|
||||||
OPTION_FUNC(deskew)
|
OPTION_FUNC(deskew)
|
||||||
{
|
{
|
||||||
enabled_ = deskew_ = *(bool*)val;
|
deskew_ = *(bool*)val;
|
||||||
};
|
};
|
||||||
OPTION_FUNC(bg)
|
OPTION_FUNC(bg)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +114,7 @@ void auto_crop::init(void)
|
||||||
lateral_ = *(bool*)val;
|
lateral_ = *(bool*)val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
opt_handler_[SANE_OPT_NAME(CROP)] = crop;
|
||||||
opt_handler_[SANE_OPT_NAME(ANTI_SKEW)] = deskew;
|
opt_handler_[SANE_OPT_NAME(ANTI_SKEW)] = deskew;
|
||||||
opt_handler_[SANE_OPT_NAME(ERASE_BLACK_FRAME)] = bg;
|
opt_handler_[SANE_OPT_NAME(ERASE_BLACK_FRAME)] = bg;
|
||||||
opt_handler_[SANE_OPT_NAME(FILL_BKG_MODE)] = bgm;
|
opt_handler_[SANE_OPT_NAME(FILL_BKG_MODE)] = bgm;
|
||||||
|
|
|
@ -15,15 +15,7 @@ static std::string device_opt_json[] = {
|
||||||
img_encoder::img_encoder() : image_processor("img_encoder")
|
img_encoder::img_encoder() : image_processor("img_encoder")
|
||||||
{
|
{
|
||||||
ADD_THIS_JSON();
|
ADD_THIS_JSON();
|
||||||
// if (!bwimg)
|
|
||||||
// {
|
|
||||||
// compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
|
|
||||||
// compression_params.push_back(100);
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// compression_params.push_back(CV_IMWRITE_PNG_STRATEGY);
|
|
||||||
// compression_params.push_back(cv::IMWRITE_PNG_STRATEGY_FIXED);
|
|
||||||
// }
|
|
||||||
param_.push_back(cv::IMWRITE_JPEG_QUALITY);
|
param_.push_back(cv::IMWRITE_JPEG_QUALITY);
|
||||||
param_.push_back(jpeg_quality_);
|
param_.push_back(jpeg_quality_);
|
||||||
}
|
}
|
||||||
|
@ -101,12 +93,11 @@ std::shared_ptr<std::vector<uchar>> img_encoder::encode(LPPACKIMAGE head, cv::Ma
|
||||||
{
|
{
|
||||||
cv::Mat out;
|
cv::Mat out;
|
||||||
|
|
||||||
cv::flip(mat, out, 0);
|
cv::flip(mat, out, 0); // 0 - flip around x-axis; >0 - flip around y-axis; <0 - flip both x and y
|
||||||
ptr.reset(new std::vector<uchar>());
|
ptr.reset(new std::vector<uchar>());
|
||||||
head->format = fmt_ == ".jpg" ? IMG_FMT_JPEG : IMG_FMT_PNG;
|
head->format = fmt_ == ".jpg" ? IMG_FMT_JPEG : IMG_FMT_PNG;
|
||||||
cv::imencode(fmt_.c_str(), out, *ptr, param_);
|
cv::imencode(fmt_.c_str(), out, *ptr, param_);
|
||||||
head->prc_time = watch.elapse_ms();
|
head->prc_time = watch.elapse_ms();
|
||||||
printf("encode to '%s' in %ums: %u\n", fmt_.c_str(), head->prc_time, ptr->size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
@ -77,7 +77,10 @@ imgproc_mgr::imgproc_mgr(std::function<void(data_source_ptr)> sender
|
||||||
workers_.start(thrd, SIZE_MB(0), "imgproc_mgr::thread_worker", (void*)&imgproc_mgr::thread_worker);
|
workers_.start(thrd, SIZE_MB(0), "imgproc_mgr::thread_worker", (void*)&imgproc_mgr::thread_worker);
|
||||||
};
|
};
|
||||||
workers_.set_exception_handler(restart);
|
workers_.set_exception_handler(restart);
|
||||||
workers_.start(thrd, SIZE_MB(0), "imgproc_mgr::thread_worker", (void*)&imgproc_mgr::thread_worker);
|
workers_.start(thrd, SIZE_MB(0), "thread_worker1", (void*)&imgproc_mgr::thread_worker);
|
||||||
|
workers_.start(thrd, SIZE_MB(0), "thread_worker2", (void*)&imgproc_mgr::thread_worker);
|
||||||
|
workers_.start(thrd, SIZE_MB(0), "thread_worker3", (void*)&imgproc_mgr::thread_worker);
|
||||||
|
workers_.start(thrd, SIZE_MB(0), "thread_worker4", (void*)&imgproc_mgr::thread_worker);
|
||||||
}
|
}
|
||||||
imgproc_mgr::~imgproc_mgr()
|
imgproc_mgr::~imgproc_mgr()
|
||||||
{
|
{
|
||||||
|
@ -144,11 +147,30 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
{
|
{
|
||||||
std::vector<PROCIMGINFO> in, out, *src = &in, *dst = &out, *swp = nullptr;
|
std::vector<PROCIMGINFO> in, out, *src = &in, *dst = &out, *swp = nullptr;
|
||||||
chronograph watch;
|
chronograph watch;
|
||||||
|
auto realdump = [this](std::vector<PROCIMGINFO>* arr, LPPACKIMAGE info, cv::Mat* mat, char* infoex, size_t infexl, bool last) -> void
|
||||||
|
{
|
||||||
|
if(arr)
|
||||||
|
send_image(*arr, last);
|
||||||
|
else
|
||||||
|
send_image(info, *mat, infoex, infexl, last);
|
||||||
|
};
|
||||||
|
auto emptydump = [this](std::vector<PROCIMGINFO>* arr, LPPACKIMAGE info, cv::Mat* mat, char* infoex, size_t infexl, bool last) -> void
|
||||||
|
{};
|
||||||
|
std::function<void(std::vector<PROCIMGINFO>* arr, LPPACKIMAGE info, cv::Mat* mat, char* infoex, size_t infexl, bool last)> dump = realdump;
|
||||||
|
|
||||||
|
if(dump_img_)
|
||||||
|
{
|
||||||
|
cv::Mat mat(img->info.width, img->info.height, CV_8UC1, img->data->ptr());
|
||||||
|
send_image(&img->info, mat, nullptr, 0, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dump = emptydump;
|
||||||
|
|
||||||
if(do_rebuild_)
|
if(do_rebuild_)
|
||||||
{
|
{
|
||||||
first_->do_rebuild(&img->info, img->data->ptr(), in);
|
first_->do_rebuild(&img->info, img->data->ptr(), in);
|
||||||
utils::to_log(LOG_LEVEL_ALL, "Rebuild paper %d spend %llu milliseconds.\n", img->info.pos.paper_ind, watch.elapse_ms());
|
utils::to_log(LOG_LEVEL_ALL, "Rebuild paper %d spend %llu milliseconds.\n", img->info.pos.paper_ind, watch.elapse_ms());
|
||||||
|
dump(&in, nullptr, nullptr, nullptr, 0, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -157,47 +179,21 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
i.img = cv::Mat(img->info.width, img->info.height, CV_8UC1, img->data->ptr());
|
i.img = cv::Mat(img->info.width, img->info.height, CV_8UC1, img->data->ptr());
|
||||||
in.push_back(i);
|
in.push_back(i);
|
||||||
}
|
}
|
||||||
|
img->data->release();
|
||||||
|
|
||||||
if(dump_img_)
|
for(auto& v: processors_)
|
||||||
{
|
{
|
||||||
|
if(v->is_enable())
|
||||||
{
|
{
|
||||||
cv::Mat mat(img->info.width, img->info.height, CV_8UC1, img->data->ptr());
|
process(v, src, dst);
|
||||||
send_image(&img->info, mat, nullptr, 0, false);
|
src->clear();
|
||||||
}
|
swp = src;
|
||||||
img->data->release();
|
src = dst;
|
||||||
|
dst = swp;
|
||||||
for(auto& v: processors_)
|
dump(src, nullptr, nullptr, nullptr, 0, false);
|
||||||
{
|
|
||||||
send_image(*src, false);
|
|
||||||
if(v->is_enable())
|
|
||||||
{
|
|
||||||
process(v, src, dst);
|
|
||||||
src->clear();
|
|
||||||
swp = src;
|
|
||||||
src = dst;
|
|
||||||
dst = swp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
img->data->release();
|
|
||||||
for(auto& v: processors_)
|
|
||||||
{
|
|
||||||
if(v->is_enable())
|
|
||||||
{
|
|
||||||
process(v, src, dst);
|
|
||||||
src->clear();
|
|
||||||
swp = src;
|
|
||||||
src = dst;
|
|
||||||
dst = swp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uint32_t t = watch.elapse_ms();
|
|
||||||
for(auto& v: in)
|
|
||||||
v.info.prc_time = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
send_image(*src, true);
|
send_image(*src, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -250,7 +246,11 @@ void imgproc_mgr::send_image(LPPACKIMAGE head, cv::Mat& mat, void* info, size_t
|
||||||
std::shared_ptr<std::vector<uchar>> compd(last_->encode(&h, mat));
|
std::shared_ptr<std::vector<uchar>> compd(last_->encode(&h, mat));
|
||||||
image_packet_ptr ptr = nullptr;
|
image_packet_ptr ptr = nullptr;
|
||||||
|
|
||||||
if(!last)
|
if(last)
|
||||||
|
{
|
||||||
|
h.life = chronograph::from_process_born() - h.life;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
h.prc_stage = head->prc_stage;
|
h.prc_stage = head->prc_stage;
|
||||||
h.prc_time = head->prc_time;
|
h.prc_time = head->prc_time;
|
||||||
|
|
|
@ -158,7 +158,7 @@ async_scanner::async_scanner() : usb_(nullptr), cfg_mgr_(nullptr), scan_id_(0)
|
||||||
{
|
{
|
||||||
cis_->close();
|
cis_->close();
|
||||||
res_mgr_->stop();
|
res_mgr_->stop();
|
||||||
utils::print_memory_usage("Memory usage when finished scanning", false);
|
utils::print_memory_usage("Memory usage when finished scanning", true);
|
||||||
system("sudo cpufreq-set -g ondemand");
|
system("sudo cpufreq-set -g ondemand");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ dyn_mem_ptr async_scanner::handle_scan_start(LPPACK_BASE pack, uint32_t* used, p
|
||||||
return res_mgr_->is_resource_enable((enum _task)task, wait, to_ms);
|
return res_mgr_->is_resource_enable((enum _task)task, wait, to_ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
utils::print_memory_usage("Memory usage before scanning", false);
|
utils::print_memory_usage("Memory usage before scanning", true);
|
||||||
*used = base_head_size;
|
*used = base_head_size;
|
||||||
img_prcr_->start_new_turn(scan_id_, session);
|
img_prcr_->start_new_turn(scan_id_, session);
|
||||||
scan_err_ = cis_->open(receiver, res, &config);
|
scan_err_ = cis_->open(receiver, res, &config);
|
||||||
|
|
|
@ -144,7 +144,7 @@ int image_holder::save_2_file(const char* root_dir, int alg_ind, const char* alg
|
||||||
bool bmp = false;
|
bool bmp = false;
|
||||||
|
|
||||||
file += PATH_SEPARATOR;
|
file += PATH_SEPARATOR;
|
||||||
sprintf(buf, "%04d_%04x", (uint32_t)head_.pos.paper_ind, alg_ind);
|
sprintf(buf, "%04d_%04d", (int32_t)head_.pos.paper_ind, alg_ind);
|
||||||
file += buf;
|
file += buf;
|
||||||
if (head_.pos.paper_side == PAPER_SIDE_FRONT)
|
if (head_.pos.paper_side == PAPER_SIDE_FRONT)
|
||||||
file += "_Front";
|
file += "_Front";
|
||||||
|
@ -156,6 +156,8 @@ int image_holder::save_2_file(const char* root_dir, int alg_ind, const char* alg
|
||||||
file += buf;
|
file += buf;
|
||||||
if (alg && *alg)
|
if (alg && *alg)
|
||||||
file += std::string("_") + alg;
|
file += std::string("_") + alg;
|
||||||
|
else
|
||||||
|
alg = "";
|
||||||
if (head_.format == IMG_FMT_PNG)
|
if (head_.format == IMG_FMT_PNG)
|
||||||
file += ".png";
|
file += ".png";
|
||||||
else if (head_.format == IMG_FMT_JPEG)
|
else if (head_.format == IMG_FMT_JPEG)
|
||||||
|
@ -194,7 +196,10 @@ int image_holder::save_2_file(const char* root_dir, int alg_ind, const char* alg
|
||||||
|
|
||||||
if (dst)
|
if (dst)
|
||||||
fclose(dst);
|
fclose(dst);
|
||||||
utils::to_log(LOG_LEVEL_ALL, "Image-Process of file '%s' is %ums.\n", file.c_str(), head_.prc_time);
|
if(strcmp(alg, "img-fmt") == 0)
|
||||||
|
utils::to_log(LOG_LEVEL_ALL, "Image-Process %s of file '%s' is %ums, total %ums.\n", alg, file.c_str(), head_.prc_time, (int)head_.life);
|
||||||
|
else
|
||||||
|
utils::to_log(LOG_LEVEL_ALL, "Image-Process %s of file '%s' is %ums.\n", alg, file.c_str(), head_.prc_time);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,7 @@ typedef struct _img_pos
|
||||||
typedef struct _pack_img
|
typedef struct _pack_img
|
||||||
{
|
{
|
||||||
IMGPOS pos; // image pos info ...
|
IMGPOS pos; // image pos info ...
|
||||||
|
uint64_t life; // milliseconds from capturer to final output
|
||||||
uint32_t width; // image width in pixel. (image-collector set)
|
uint32_t width; // image width in pixel. (image-collector set)
|
||||||
uint32_t height; // image height in pixel. (image-collector set)
|
uint32_t height; // image height in pixel. (image-collector set)
|
||||||
uint32_t resolution_x; // image horizontal reolution. (image-collector set)
|
uint32_t resolution_x; // image horizontal reolution. (image-collector set)
|
||||||
|
|
|
@ -1970,6 +1970,8 @@ int32_t refer::release(void)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// util
|
// util
|
||||||
|
chronograph chronograph::process_born_;
|
||||||
|
|
||||||
chronograph::chronograph()
|
chronograph::chronograph()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
@ -2022,6 +2024,10 @@ std::string chronograph::now(bool with_ms/*whether with milliseconds*/)
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
uint64_t chronograph::from_process_born(void)
|
||||||
|
{
|
||||||
|
return chronograph::process_born_.elapse_ms();
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t chronograph::elapse_s(void)
|
uint64_t chronograph::elapse_s(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,6 +308,7 @@ public:
|
||||||
class chronograph
|
class chronograph
|
||||||
{
|
{
|
||||||
TIMEV bgn_;
|
TIMEV bgn_;
|
||||||
|
static chronograph process_born_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
chronograph();
|
chronograph();
|
||||||
|
@ -316,7 +317,8 @@ public:
|
||||||
static bool now(TIMEV* tv);
|
static bool now(TIMEV* tv);
|
||||||
static bool now(uint64_t* seconds, uint64_t* u_seconds);
|
static bool now(uint64_t* seconds, uint64_t* u_seconds);
|
||||||
static std::string now(bool with_ms = true/*whether with milliseconds*/); // return '2022-11-30 10:38:42.123', no '.123' if with_ms was false
|
static std::string now(bool with_ms = true/*whether with milliseconds*/); // return '2022-11-30 10:38:42.123', no '.123' if with_ms was false
|
||||||
|
static uint64_t from_process_born(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint64_t elapse_s(void);
|
uint64_t elapse_s(void);
|
||||||
uint64_t elapse_ms(void);
|
uint64_t elapse_ms(void);
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
#define SANE_STD_OPT_NAME_PHASE_BACK "phase-b"
|
#define SANE_STD_OPT_NAME_PHASE_BACK "phase-b"
|
||||||
#define SANE_STD_OPT_NAME_OUT_FORMAT "img-fmt"
|
#define SANE_STD_OPT_NAME_OUT_FORMAT "img-fmt"
|
||||||
#define SANE_STD_OPT_NAME_JPEG_QUALITY "jpeg-quality"
|
#define SANE_STD_OPT_NAME_JPEG_QUALITY "jpeg-quality"
|
||||||
|
#define SANE_STD_OPT_NAME_CROP "crop"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue