83 lines
2.2 KiB
C++
83 lines
2.2 KiB
C++
#pragma once
|
|
|
|
// image processor
|
|
//
|
|
// created on 2023-11-07
|
|
//
|
|
// ver: 1.0
|
|
//
|
|
// NOTE: the interface is for all algorithms are in ONE module
|
|
|
|
#include <imgprc/img_processor.h>
|
|
#include <base/utils.h> // for refer
|
|
#include <base/data.h>
|
|
#include <vector>
|
|
|
|
typedef std::shared_ptr<std::vector<char>> dcptr;
|
|
|
|
class device_option;
|
|
class rebuild;
|
|
class img_encoder;
|
|
|
|
class imgproc_mgr : public sane_opt_provider
|
|
{
|
|
typedef struct _raw_img
|
|
{
|
|
PACKIMAGE info;
|
|
dyn_mem_ptr data;
|
|
bool img;
|
|
}RAWIMG;
|
|
|
|
refer_guard<rebuild> first_;
|
|
refer_guard<img_encoder> last_;
|
|
image_processor* stretcher_ = nullptr;
|
|
bool do_rebuild_ = true;
|
|
volatile bool run_ = true;
|
|
volatile uint32_t sent_ind_ = 1;
|
|
bool dump_img_ = false;
|
|
uint32_t scan_id_ = 0;
|
|
uint32_t session_id_ = 0;
|
|
MUTEX working_cnt_lock_;
|
|
uint32_t working_cnt_ = 0;
|
|
std::vector<image_processor*> processors_;
|
|
device_option* opts_;
|
|
safe_thread workers_;
|
|
safe_fifo<RAWIMG> prc_que_;
|
|
|
|
CHK_RES_FUNC res_ = CHK_RES_FUNC();
|
|
std::function<void(data_source_ptr)> img_sender_;
|
|
|
|
static bool sort_processor_by_pos(image_processor* l, image_processor* r);
|
|
static bool sort_image_packet(image_packet_ptr l, image_packet_ptr r);
|
|
static data_source_ptr scan_finished_packet(uint32_t scanid, uint32_t err = 0);
|
|
|
|
uint32_t add_busy_worker(int inc = 1);
|
|
void thread_worker(void);
|
|
void process(RAWIMG* img);
|
|
void process(image_processor* prc, std::vector<PROCIMGINFO>* in, std::vector<PROCIMGINFO>* out);
|
|
void send_image(LPPACKIMAGE head, cv::Mat& mat, void* info = nullptr, size_t info_l = 0, bool last = true);
|
|
void send_image(std::vector<PROCIMGINFO>& imgs, bool last);
|
|
|
|
public:
|
|
imgproc_mgr(std::function<void(data_source_ptr)> sender, device_option* devopts, CHK_RES_FUNC res = CHK_RES_FUNC());
|
|
|
|
protected:
|
|
virtual ~imgproc_mgr();
|
|
|
|
public:
|
|
virtual int set_value(const char* name, void* val) override;
|
|
|
|
// process
|
|
public:
|
|
int load_processor(const char* path); // outer-modules path
|
|
int clear(void);
|
|
int process(LPPACKIMAGE info, dyn_mem_ptr data, bool img);
|
|
|
|
// life
|
|
public:
|
|
void stop(void);
|
|
bool is_busy(void);
|
|
void start_new_turn(uint32_t scanid, uint32_t sessionid);
|
|
};
|
|
|