2024-01-16 09:51:34 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
// image processor
|
|
|
|
|
//
|
|
|
|
|
// created on 2023-11-07
|
|
|
|
|
//
|
|
|
|
|
// ver: 1.0
|
|
|
|
|
//
|
|
|
|
|
// NOTE: the interface is for all algorithms are in ONE module
|
|
|
|
|
|
|
|
|
|
#include <base/packet.h>
|
|
|
|
|
#include <sane_opt_json/base_opt.h>
|
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
|
|
typedef struct _proc_img_info_
|
|
|
|
|
{
|
|
|
|
|
PACKIMAGE info;
|
|
|
|
|
cv::Mat img;
|
|
|
|
|
std::string ext_info; // 图片扩展信息(图像处理过程中可以保存各算法间的共有信息;处理完后为向用户提供的扩展信息)
|
|
|
|
|
}PROCIMGINFO, *LPPROCIMGINFO;
|
|
|
|
|
|
|
|
|
|
typedef struct _proc_img_info_modules // 跨模块参数
|
|
|
|
|
{
|
|
|
|
|
PACKIMAGE info;
|
|
|
|
|
uint32_t bytes_per_line;
|
|
|
|
|
uint8_t* data; // size = bytes_per_line * height
|
|
|
|
|
}PROCIIM, *LPPROCIIM;
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
class image_processor : public sane_opt_provider
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
bool enabled_;
|
|
|
|
|
int ver_;
|
|
|
|
|
int pos_;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
image_processor(const char* alg_name);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~image_processor();
|
|
|
|
|
|
|
|
|
|
bool set_opt_json_text(char* txt);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool is_enable(void) { return enabled_; }
|
|
|
|
|
int get_version(void) { return ver_; }
|
|
|
|
|
int get_position(void) { return pos_; }
|
|
|
|
|
|
|
|
|
|
virtual int process(std::vector<PROCIMGINFO>& in, std::vector<PROCIMGINFO>& out) = 0;
|
|
|
|
|
|
|
|
|
|
// 跨模块图像处理接口。回调函数返回false,则停止处理;void*参数同 'param'。
|
|
|
|
|
virtual int process(LPPROCIIM* in, size_t cnt, bool(*result)(LPPROCIIM, void*), void* param);
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-23 09:34:20 +00:00
|
|
|
|
#define ADD_THIS_JSON() \
|
|
|
|
|
{ \
|
|
|
|
|
std::string t(""); \
|
|
|
|
|
for(auto& v: device_opt_json) \
|
|
|
|
|
t += v; \
|
|
|
|
|
set_opt_json_text(&t[0]); \
|
|
|
|
|
}
|