85 lines
2.3 KiB
C++
85 lines
2.3 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"
|
|
|
|
enum paper_side
|
|
{
|
|
PAPER_SIDE_UNKNOWN = 0,
|
|
PAPER_SIDE_FRONT, // single side, this is front
|
|
PAPER_SIDE_BACK, // single side, this is back
|
|
PAPER_SIDE_TOP, // VERT-compound sides, and front side is at top
|
|
PAPER_SIDE_BOTTOM, // VERT-compound sides, and front side is at bottom
|
|
PAPER_SIDE_LEFT, // HORZ-compound sides, and front side is at left
|
|
PAPER_SIDE_RIGHT, // HORZ-compound sides, and front side is at right
|
|
|
|
PAPER_SIDE_DSP, // G100/200 DSP data
|
|
};
|
|
/*
|
|
enum img_status
|
|
{
|
|
IMG_STATUS_OK = 0, // normal
|
|
IMG_STATUS_DOUBLE = 1 << 0, // double-feeded paper
|
|
IMG_STATUS_JAM = 1 << 1, // jammed paper
|
|
IMG_STATUS_STAPLE = 1 << 2, // staples on the paper
|
|
IMG_STATUS_SIZE_ERR = 1 << 3, // size check failed
|
|
IMG_STATUS_DOGEAR = 1 << 4, // paper has dogear - common
|
|
IMG_STATUS_DOGEAR_PARTIAL = 1 << 5, // dogear - scanned partial
|
|
IMG_STATUS_BLANK = 1 << 6, // blank image
|
|
};
|
|
*/
|
|
|
|
#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;
|
|
#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(const std::vector<PROCIMGINFO>& in, std::vector<PROCIMGINFO>& out) = 0;
|
|
};
|
|
|