From e1bf64b18933e1d8fc5ff2c3d4cfe7c66d8323ac Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Wed, 24 Jan 2024 17:40:41 +0800 Subject: [PATCH] nothing --- hardware/hardware.cpp | 2 -- imgproc/algs/auto_crop.cpp | 11 ++++++----- imgproc/algs/auto_crop.h | 2 +- imgproc/imgprc_mgr.cpp | 13 ++++++++++++- sdk/base/data.cpp | 17 ++++++++++++++++- xmake.lua | 2 +- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/hardware/hardware.cpp b/hardware/hardware.cpp index ad08b43..3ee0d56 100644 --- a/hardware/hardware.cpp +++ b/hardware/hardware.cpp @@ -381,12 +381,10 @@ void scanner_hw::thread_image_capture(void) break; } img.prc_time = watch.elapse_ms(); - printf("Fetch paper %d: %ums\n", img.pos.paper_ind + 1, img.prc_time); mem = new dyn_mem_shared(frame, size, put_v4l2_mem, (void*)ind); used_v4l2_mem++; img.pos.paper_ind++; img.pos.status = IMG_STATUS_OK; - printf("Image height: %d\n", img.height); img_handler_(mem, true, &img); mem->release(); diff --git a/imgproc/algs/auto_crop.cpp b/imgproc/algs/auto_crop.cpp index 8e3df1d..0adab64 100644 --- a/imgproc/algs/auto_crop.cpp +++ b/imgproc/algs/auto_crop.cpp @@ -92,8 +92,8 @@ void auto_crop::init(void) }; OPTION_FUNC(paper) { - crop_ = strcmp((char*)val, WORDS_PAPER_ORIGIN_SIZE) == 0 - || strcmp((char*)val, WORDS_PAPER_MAX_SIZE_CROP) == 0; + crop_ = //strcmp((char*)val, WORDS_PAPER_ORIGIN_SIZE) == 0 || + strcmp((char*)val, WORDS_PAPER_MAX_SIZE_CROP) == 0; if(crop_) memset(&fixed_paper_, 0, sizeof(fixed_paper_)); else @@ -122,8 +122,8 @@ void auto_crop::init(void) int auto_crop::work(PROCIMGINFO& in, PROCIMGINFO& out) { int ret = SCANNER_ERR_OK, - dWidth = fixed_paper_.cx, - dHeight = fixed_paper_.cy; + dWidth = fixed_paper_.cx * 1.0f / MM_PER_INCH * in.info.resolution_x + .5f, + dHeight = fixed_paper_.cy * 1.0f / MM_PER_INCH * in.info.resolution_x + .5f; cv::Mat thre; @@ -165,7 +165,7 @@ int auto_crop::work(PROCIMGINFO& in, PROCIMGINFO& out) cv::Scalar blankColor; if (fill_bg_) - if (/*isColorBlank*/1) + if (/*isColorBlank*/0) { cv::Rect boudingRect = cv::boundingRect(maxContour); boudingRect.x *= FX_FY; @@ -324,6 +324,7 @@ int auto_crop::process(std::vector& in, std::vector& o chronograph watch; ret = work(v, o); + o.info = v.info; o.info.prc_time = watch.elapse_ms(); o.info.prc_stage = get_position(); diff --git a/imgproc/algs/auto_crop.h b/imgproc/algs/auto_crop.h index 4d789d4..9272c93 100644 --- a/imgproc/algs/auto_crop.h +++ b/imgproc/algs/auto_crop.h @@ -14,7 +14,7 @@ class auto_crop : public image_processor bool fill_bg_ = true; bool convex_ = true; bool fill_clr_ = false; - int threshold_ = 10; + int threshold_ = 40; int indent_ = 5; int noise_ = 8; SIZE fixed_paper_ = {0, 0}; diff --git a/imgproc/imgprc_mgr.cpp b/imgproc/imgprc_mgr.cpp index 28d643c..271adfa 100644 --- a/imgproc/imgprc_mgr.cpp +++ b/imgproc/imgprc_mgr.cpp @@ -34,6 +34,18 @@ imgproc_mgr::imgproc_mgr(std::function sender { thread_worker(); }; + auto restart = [this](const char* thread_name) ->void + { + auto thrd = [this](void) -> void + { + thread_worker(); + }; + workers_.stop(thread_name); + add_busy_worker(-1); + printf("\nrestart imgproc_mgr::thread_worker\n\n"); + workers_.start(thrd, "imgproc_mgr::thread_worker", (void*)&imgproc_mgr::thread_worker); + }; + workers_.set_exception_handler(restart); workers_.start(thrd, "imgproc_mgr::thread_worker", (void*)&imgproc_mgr::thread_worker); } imgproc_mgr::~imgproc_mgr() @@ -158,7 +170,6 @@ void imgproc_mgr::send_image(LPPACKIMAGE head, uint8_t* data, size_t size, void* dyn_mem_ptr mem(dyn_mem::memory(size)); image_packet_ptr ptr = nullptr; - printf("send image %d(%d-0x%04x) with size %u:\n", head->pos.paper_ind, head->pos.paper_side, head->prc_stage, size); mem->put(data, size); ptr = imgproc_mgr::image_sent_packet(head, mem, scan_id_, info, info_l); mem->release(); diff --git a/sdk/base/data.cpp b/sdk/base/data.cpp index 371fdf4..e493818 100644 --- a/sdk/base/data.cpp +++ b/sdk/base/data.cpp @@ -163,12 +163,27 @@ int image_holder::save_2_file(const char* root_dir, const char* alg) { fwrite(bfh.c_str(), 1, bfh.length(), dst); fwrite(bih.c_str(), 1, bih.length(), dst); - fwrite(data() + head_.info_size, 1, head_.data_size, dst); + if(head_.data_size == ((LPBITMAPINFOHEADER)&bih[0])->biSizeImage) + fwrite(data() + head_.info_size, 1, head_.data_size, dst); + else + { + int l = BMP_LINE_BYTES(head_.width * head_.bpp * head_.channels), + dif = l - (head_.width * head_.bpp * head_.channels + 7) / 8; + char pad[4] = { 0 }; + uint8_t *ptr = data() + head_.info_size; + for (int i = 0; i < head_.height; ++i) + { + fwrite(ptr, 1, l - dif, dst); + fwrite(pad, 1, dif, dst); + ptr += l - dif; + } + } } } if (dst) fclose(dst); + utils::to_log(LOG_LEVEL_ALL, "Image-Process of file '%s' is %ums.\n", file.c_str(), head_.prc_time); return err; } diff --git a/xmake.lua b/xmake.lua index cb0547a..d39e97d 100644 --- a/xmake.lua +++ b/xmake.lua @@ -61,7 +61,7 @@ add_defines("BUILD_AS_DEVICE") add_defines("VER_MAIN=2") add_defines("VER_FAMILY=200") add_defines("VER_DATE=20240124") -add_defines("VER_BUILD=8") +add_defines("VER_BUILD=25") target("conf") set_kind("phony")