#pragma once // image processor // // created on 2023-11-07 // // ver: 1.0 // // NOTE: the interface is for all algorithms are in ONE module #include #include // for refer #include #include typedef std::shared_ptr> dcptr; class device_option; class rebuild; class imgproc_mgr : public sane_opt_provider { typedef struct _raw_img { PACKIMAGE info; dyn_mem_ptr data; bool img; }RAWIMG; refer_guard rebuild_; volatile bool run_ = true; bool dump_img_ = false; uint32_t scan_id_ = 0; uint32_t sent_ind_ = 0; uint32_t session_id_ = 0; MUTEX working_cnt_lock_; uint32_t working_cnt_ = 0; std::vector processors_; device_option* opts_; safe_thread workers_; safe_fifo prc_que_; std::function 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); static image_packet_ptr image_sent_packet(LPPACKIMAGE head, dyn_mem_ptr img, uint32_t scanid, void* info = nullptr, size_t info_l = 0); uint32_t add_busy_worker(int inc = 1); void thread_worker(void); void process(RAWIMG* img); void send_image(LPPACKIMAGE head, uint8_t* data, size_t size, void* info = nullptr, size_t info_l = 0); void send_image(std::vector& imgs, bool clear_after_send); public: imgproc_mgr(std::function sender, device_option* devopts); 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); };