code_device/sdk/imgprc/imgprc_mgr.h

87 lines
2.4 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 "img_processor.h"
#include <base/utils.h> // for refer
#include <base/packet.h>
#include <vector>
typedef std::shared_ptr<std::vector<char>> dcptr;
class device_option;
class imgproc_mgr : public sane_opt_provider
{
typedef struct _decode_data
{
PACKIMAGE info;
dcptr img;
}DECDAT;
std::string dump_path_ = "";
bool duplex_ = true;
bool xchg_fb_ = false;
std::vector<image_processor*> processors_;
device_option* opts_;
void(imgproc_mgr::* dumpf_)(const std::vector<PROCIMGINFO>& img, const char* after, int pos) = nullptr;
std::string(imgproc_mgr::* dumpusbf_)(uint8_t* data, size_t bytes, PACKIMAGE* info, const char* tail) = nullptr;
static bool sort_processor_by_pos(image_processor* l, image_processor* r);
void dump_real(const std::vector<PROCIMGINFO>& img, const char* after, int pos);
void dump_empty(const std::vector<PROCIMGINFO>& img, const char* after, int pos);
std::string dump_usb_img_real(uint8_t* data, size_t bytes, PACKIMAGE* info, const char* tail);
std::string dump_usb_img_empty(uint8_t* data, size_t bytes, PACKIMAGE* info, const char* tail);
int decode(PACKIMAGE* info, uint8_t* data, size_t bytes, std::vector<PROCIMGINFO>& result);
public:
imgproc_mgr(device_option* devopts, bool dumpimg, const char* dumpath);
static std::vector<DECDAT> decode_before_simple(uint8_t* data, size_t bytes, PACKIMAGE* info);
static std::vector<DECDAT> decode_before_g200dsp(uint8_t* data, size_t bytes, PACKIMAGE* info);
protected:
virtual ~imgproc_mgr();
public:
virtual int set_value(const char* name, void* val) override;
public:
int load_processor(const char* path); // outer-modules path
int clear(void);
int process(PACKIMAGE* info, uint8_t* data, size_t bytes, std::vector<PROCIMGINFO>& out);
};
//{
// "dumpimg": {
// "cat": "base",
// "group": "debug",
// "title": "输出算法中间图像",
// "desc": "每个算法执行后,输出中间的临时图像",
// "type": "bool",
// "pos": 10,
// "size": 4,
// "cur": false,
// "default": false
// },
// "dump-path": {
// "cat": "base",
// "group": "debug",
// "title": "中间图像输出路径",
// "desc": "每个算法执行后,输出中间临时图像的存放路径",
// "type": "string",
// "pos": 10,
// "size": 260,
// "cur": "",
// "default": "",
// "depend": "dumpimg==true"
// }
//}