74 lines
1.9 KiB
C++
74 lines
1.9 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 <sane_opt_json/base_opt.h>
|
||
#include "../../hgdriver/3rdparty/opencv/include/opencv2/opencv.hpp"
|
||
|
||
#pragma pack(push)
|
||
#pragma pack(1)
|
||
typedef struct _hg_img_info
|
||
{
|
||
uint32_t paper_ind : 16; // paper index in this turn/start, based ZERO. (image-collector set)
|
||
uint32_t new_img : 1; // 0 - partial data; 1 - new image data. (image-collector set)
|
||
uint32_t img_over : 1; // 0 - has data yet; 1 - END for the image. (image-collector set)
|
||
uint32_t paper_side : 4; // paper_side
|
||
uint32_t status : 10; // img_status
|
||
uint32_t split_ind : 4; // splitting order, from left to right and then top to bottom, based ZERO
|
||
uint32_t compress : 6; // compression type
|
||
uint32_t channels : 3;
|
||
uint32_t bits : 6;
|
||
uint32_t reserved : 13;
|
||
}HGIMGINFO;
|
||
|
||
typedef struct _proc_img_info_
|
||
{
|
||
HGIMGINFO info;
|
||
cv::Mat img;
|
||
}PROCIMGINFO, *LPPROCIMGINFO;
|
||
|
||
typedef struct _proc_img_info_modules // 跨模块参数
|
||
{
|
||
HGIMGINFO info;
|
||
uint32_t width; // in px
|
||
uint32_t height; // in px
|
||
uint32_t channels;
|
||
uint32_t bits; // bits per channel
|
||
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);
|
||
};
|
||
|