update sane-configurations

This commit is contained in:
gb 2023-05-06 15:41:18 +08:00
parent eddf026b05
commit 90b03e47fe
30 changed files with 1664 additions and 918 deletions

View File

@ -511,6 +511,27 @@ enum Scanner_Reg_Defs
SR_SCAN_CNT, SR_SCAN_CNT,
SR_SCAN_PAPER, SR_SCAN_PAPER,
SR_SCAN_PIXEL, SR_SCAN_PIXEL,
SR_CAPTURE_SET = 0x0ffffca00,
};
enum capturer_set_func
{
CSF_EXPO_MASK = 0x10,
CSF_EXPO_FB = 0,
CSF_EXPO_FG,
CSF_EXPO_FR,
CSF_EXPO_BB,
CSF_EXPO_BG,
CSF_EXPO_BR,
CSF_GAIN_MASK = 0x20,
CSF_GAIN_BACK = 0,
CSF_GAIN_FRONT,
CSF_OFFSET_MASK = 0x40,
CSF_OFFSET_BACK = 0,
CSF_OFFSET_FRONT,
}; };
typedef union Ctrol_Description{ typedef union Ctrol_Description{

View File

@ -6,6 +6,7 @@
#include "fsmstate.h" #include "fsmstate.h"
class IImageHandler; class IImageHandler;
class ICapturer;
class IScanner class IScanner
{ {
@ -42,4 +43,6 @@ public:
virtual void settrayposition(int value)=0; virtual void settrayposition(int value)=0;
virtual std::string getmbversion()=0; virtual std::string getmbversion()=0;
virtual void clean_paper_road() = 0; virtual void clean_paper_road() = 0;
virtual std::shared_ptr<ICapturer> get_capture(void) = 0;
}; };

View File

@ -52,6 +52,12 @@ public:
virtual void setfeedmode(int value) override; virtual void setfeedmode(int value) override;
virtual void settrayposition(int value) override; virtual void settrayposition(int value) override;
virtual void clean_paper_road() override; virtual void clean_paper_road() override;
virtual std::shared_ptr<ICapturer> get_capture(void) override
{
return capturer;
}
private: private:
void runMessageLoop(); void runMessageLoop();
void runScan(); void runScan();

View File

@ -97,6 +97,8 @@ ScannerRegAccess::~ScannerRegAccess()
{ {
} }
#include "../capimage/ICapturer.h"
bool ScannerRegAccess::write(unsigned int addr, const unsigned int val) bool ScannerRegAccess::write(unsigned int addr, const unsigned int val)
{ {
static uint64_t img_cb = 0, img_param = 0; static uint64_t img_cb = 0, img_param = 0;
@ -136,6 +138,24 @@ bool ScannerRegAccess::write(unsigned int addr, const unsigned int val)
return true; return true;
} }
else if((addr & (~0x0ff)) == SR_CAPTURE_SET)
{
std::shared_ptr<ICapturer> capturer = scanner->get_capture();
if(capturer.get())
{
int type = addr & (~SR_CAPTURE_SET),
ix = type & 0x0f;
if(type & CSF_EXPO_MASK)
capturer->set_expo(ix, val);
else if(type & CSF_GAIN_MASK)
capturer->set_gain(ix, val);
else if(type & CSF_OFFSET_MASK)
capturer->set_offset(ix, val);
}
return true;
}
switch (addr) switch (addr)
{ {
case SR_CMD: case SR_CMD:

View File

@ -26,13 +26,14 @@ class UsbDevice
void do_system_command(const char* cmd); void do_system_command(const char* cmd);
public: public:
int start_scan(void); int start_scan(int devcfg);
int stop_scan(void); int stop_scan(void);
int set_dpi(int *dpix, int* dpiy); int set_dpi(int *dpix, int* dpiy);
int set_scan_num(int num); int set_scan_num(int num);
int set_img_receiver(void* api, void* param); int set_img_receiver(void* api, void* param);
int set_paper_type(int type); int set_paper_type(int type);
int set_pixel_type(int *type); int set_pixel_type(int *type);
int set_capturer_parameter(int type, int ind, int val);
#endif #endif
public: public:

View File

@ -26,29 +26,55 @@
// exporting api: // exporting api:
#define CM_PER_INCH 2.54f #define CM_PER_INCH 2.54f
enum hrdw_paper
{
G200_A3 = 0,
G200_A4,
G200_A4R,
G200_A5,
G200_A5R,
G200_A6,
G200_A6R,
G200_B4,
G200_B5,
G200_B5R,
G200_B6,
G200_B6R,
G200_DOUBLELETTER,
G200_LEGAL,
G200_LETTER,
G200_LETTERR,
G200_LONGLETTER = 16,
G200_MAXSIZE = 16,
G200_AUTO = 12, // 16,
G200_MAXAUTO = 16,
};
static struct paper_size static struct paper_size
{ {
const char* name; const char* name;
TwSS type; TwSS type;
double w; double w;
double h; double h;
hrdw_paper hdpaper;
}g_paper_size[] = { }g_paper_size[] = {
{"A3", TwSS::A3, 29.7f, 42.0f}, {"A3", TwSS::A3, 29.7f, 42.0f, G200_A3},
{"A4", TwSS::A4, 21.0f, 29.7f}, {"A4", TwSS::A4, 21.0f, 29.7f, G200_A4},
{"A5", TwSS::A5, 14.8f, 21.0f}, {"A5", TwSS::A5, 14.8f, 21.0f, G200_A5},
{"A6", TwSS::A6, 10.5f, 14.8f}, {"A6", TwSS::A6, 10.5f, 14.8f, G200_A6},
{"B4", TwSS::B4, 25.7f, 36.4f}, {"B4", TwSS::B4, 25.7f, 36.4f, G200_B4},
{"B5", TwSS::B5, 17.6f, 25.0f}, // {PAPER_B5, {182, 257}}, {"B5", TwSS::B5, 17.6f, 25.0f, G200_B5}, // {PAPER_B5, {182, 257}},
{"B6", TwSS::B6, 12.5f, 17.6f}, {"B6", TwSS::B6, 12.5f, 17.6f, G200_B6},
{"8\xE5\xBC\x80", TwSS::K8, 29.7f, 42.0f}, {"8\xE5\xBC\x80", TwSS::K8, 29.7f, 42.0f, G200_A3},
{"16\xE5\xBC\x80", TwSS::K16, 21.0f, 28.5f}, {"16\xE5\xBC\x80", TwSS::K16, 21.0f, 28.5f, G200_A4},
{"Letter", TwSS::A4Letter, 21.6f, 27.9f}, {"Letter", TwSS::A4Letter, 21.6f, 27.9f, G200_LETTER},
{"Legal", TwSS::USLegal, 21.6f, 35.6f}, {"Legal", TwSS::USLegal, 21.6f, 35.6f, G200_LEGAL},
{"Double-Letter", TwSS::USLedger, 43.2f, 27.9f}, {"Double-Letter", TwSS::USLedger, 43.2f, 27.9f, G200_LONGLETTER},
{"\xE4\xB8\x89\xE8\x81\x94\xE8\xAF\x95\xE5\x8D\xB7", TwSS::Trigeminy, 29.7f, 42.0f}, // fixed me ... {"\xE4\xB8\x89\xE8\x81\x94\xE8\xAF\x95\xE5\x8D\xB7", TwSS::Trigeminy, 29.7f, 42.0f, G200_LONGLETTER}, // fixed me ...
{"\xE5\x8C\xB9\xE9\x85\x8D\xE5\x8E\x9F\xE5\xA7\x8B\xE5\xB0\xBA\xE5\xAF\xB8", TwSS::None, 29.7f, 42.0f}, //\xfixed\xme\x... {"\xE5\x8C\xB9\xE9\x85\x8D\xE5\x8E\x9F\xE5\xA7\x8B\xE5\xB0\xBA\xE5\xAF\xB8", TwSS::None, 29.7f, 42.0f, G200_AUTO}, // fixed me ...
{"\xE6\x9C\x80\xE5\xA4\xA7\xE6\x89\xAB\xE6\x8F\x8F\xE5\xB0\xBA\xE5\xAF\xB8\xE8\x87\xAA\xE5\x8A\xA8\xE8\xA3\x81\xE5\x88\x87", TwSS::USStatement, 29.7f, 42.0f}, //\xfixed\xme\x... {"\xE6\x9C\x80\xE5\xA4\xA7\xE6\x89\xAB\xE6\x8F\x8F\xE5\xB0\xBA\xE5\xAF\xB8\xE8\x87\xAA\xE5\x8A\xA8\xE8\xA3\x81\xE5\x88\x87"
{"\xE6\x9C\x80\xE5\xA4\xA7\xE6\x89\xAB\xE6\x8F\x8F\xE5\xB0\xBA\xE5\xAF\xB8", TwSS::MaxSize, 29.7f, 42.0f}, //\xfixed\xme\x... , TwSS::USStatement, 29.7f, 42.0f, G200_MAXAUTO}, // fixed me ...
{"\xE6\x9C\x80\xE5\xA4\xA7\xE6\x89\xAB\xE6\x8F\x8F\xE5\xB0\xBA\xE5\xAF\xB8", TwSS::MaxSize, 29.7f, 42.0f, G200_MAXSIZE}, // fixed me ...
}; };
namespace paper namespace paper
@ -87,7 +113,7 @@ namespace paper
// h - to receive height in cm // h - to receive height in cm
// //
// Return: true if 'name' was supported, or else false // Return: true if 'name' was supported, or else false
bool paper_size(const char* name, double* w, double* h, int* type) bool paper_size(const char* name, double* w, double* h, int* type, int* hrd_type)
{ {
bool fit = false; bool fit = false;
@ -101,6 +127,8 @@ namespace paper
*h = v.h; *h = v.h;
if(type) if(type)
*type = v.type; *type = v.type;
if(hrd_type)
*hrd_type = v.hdpaper;
fit = true; fit = true;
break; break;
} }
@ -114,7 +142,9 @@ namespace paper
if(h) if(h)
*h = g_paper_size[0].h; *h = g_paper_size[0].h;
if(type) if(type)
*type = g_paper_size[0].type; *type = g_paper_size[0].type;
if(hrd_type)
*hrd_type = g_paper_size[0].hdpaper;
} }
return fit; return fit;

View File

@ -26,7 +26,9 @@ namespace paper
// //
// type - to receive paper type of TwSS // type - to receive paper type of TwSS
// //
// hrd_type - to receive paper type of hardware enumeration
//
// Return: true if 'name' was supported, or else false // Return: true if 'name' was supported, or else false
bool paper_size(const char* name, double* w, double* h, int* type = nullptr); bool paper_size(const char* name, double* w, double* h, int* type = nullptr, int* hrd_type = nullptr);
}; };

View File

@ -306,6 +306,9 @@ void sane_cfg_provider::update_option_enable_status(gb_json* opt, std::function<
if(depends) if(depends)
{ {
bool en = true;
opt->get_value("enabled", en);
item = depends->first_child(); item = depends->first_child();
while(item) while(item)
{ {
@ -322,7 +325,8 @@ void sane_cfg_provider::update_option_enable_status(gb_json* opt, std::function<
} }
depends->release(); depends->release();
opt->set_value("enabled", able); opt->set_value("enabled", able);
log_cls::log(LOG_LEVEL_DEBUG, "%s enabled: %s. (%s = %s)\n", opt->key().c_str(), able ? "true" : "false", name.c_str(), val.c_str()); if(en ^ able)
log_cls::log(LOG_LEVEL_DEBUG, "%s enabled: %s. (%s = %s)\n", opt->key().c_str(), able ? "true" : "false", name.c_str(), sane_cfg_provider::to_readable_string(&val[0], (data_type)type).c_str());
} }
} }
data_type sane_cfg_provider::type_from_string(const char* type_desc) data_type sane_cfg_provider::type_from_string(const char* type_desc)
@ -724,7 +728,7 @@ void sane_cfg_mgr::on_sane_provider_changed(sane_cfg_provider* prvd, bool add)
refresh_api(v, &lost); refresh_api(v, &lost);
} }
} }
update_enable_status(); update_enable_status("option-changed");
} }
std::string sane_cfg_mgr::get_all_configurations(void) std::string sane_cfg_mgr::get_all_configurations(void)
{ {
@ -761,7 +765,7 @@ std::string sane_cfg_mgr::get_all_configurations(void)
return std::move(text); return std::move(text);
} }
void sane_cfg_mgr::update_enable_status(void) void sane_cfg_mgr::update_enable_status(const char* name)
{ {
auto get_opt = [&](const char* cfg_name, const char* key, std::string& val, uint32_t* type) -> int32_t auto get_opt = [&](const char* cfg_name, const char* key, std::string& val, uint32_t* type) -> int32_t
{ {
@ -776,11 +780,17 @@ void sane_cfg_mgr::update_enable_status(void)
return ret; return ret;
}; };
bool changed = false;
uint32_t cnt = 0;
for(auto& v: sane_waiters_) do
{ {
v->update_enabled(get_opt); changed = false;
} for(auto& v: sane_waiters_)
{
changed |= v->update_enabled(name, get_opt);
}
}while(changed && cnt++ < 3);
} }
int sane_cfg_mgr::reg_sane_provider(sane_cfg_provider* prvd) int sane_cfg_mgr::reg_sane_provider(sane_cfg_provider* prvd)
@ -842,18 +852,25 @@ int32_t sane_cfg_mgr::get_config(std::string& text, const char* cfg_name, std::s
return 0; return 0;
} }
} }
int32_t sane_cfg_mgr::set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) int32_t sane_cfg_mgr::set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo, data_type type)
{ {
if (cfg_name) if (cfg_name)
{ {
if (cfg_api_.count(cfg_name)) if (cfg_api_.count(cfg_name))
{ {
std::string v0(sane_cfg_provider::to_readable_string(data, type)), v1("");
uint32_t affect = 0; uint32_t affect = 0;
int32_t ret = cfg_api_[cfg_name].prvd->set_config(cfg_name, data, len, &affect); int32_t ret = cfg_api_[cfg_name].prvd->set_config(cfg_name, data, len, &affect);
v1 = sane_cfg_provider::to_readable_string(data, type);
if(v0 == v1)
log_cls::log(LOG_LEVEL_DEBUG, "Set '%s' to '%s'\n", cfg_name, v0.c_str());
else
log_cls::log(LOG_LEVEL_DEBUG, "Set '%s' to '%s', but applied '%s'\n", cfg_name, v0.c_str(), v1.c_str());
if(affect & OPT_AFFECT_OTHERS) if(affect & OPT_AFFECT_OTHERS)
{ {
update_enable_status(); update_enable_status(cfg_name);
} }
if(afterdo) if(afterdo)

View File

@ -47,7 +47,7 @@ public:
static std::string sane_option_value_get(gb_json* jsn, const char* key = "cur"/*cur, default*/, std::string* strval = nullptr/*convert value into string*/); static std::string sane_option_value_get(gb_json* jsn, const char* key = "cur"/*cur, default*/, std::string* strval = nullptr/*convert value into string*/);
static bool sane_option_value_set(gb_json* jsn, void* data, const char* key = "cur"/*cur, default*/); static bool sane_option_value_set(gb_json* jsn, void* data, const char* key = "cur"/*cur, default*/);
static bool sane_refine_range(gb_json* jsn, void* data, size_t* len); // if 'data' is accept then return true, or else return false and new data set in 'data' and 'len' static bool sane_refine_range(gb_json* jsn, void* data, size_t* len); // if 'data' is accept then return true, or else return false and new data set in 'data' and 'len'
static void update_option_enable_status(gb_json* opt, std::function<GET_SANE_OPT_PROTO> get_opt); static void update_option_enable_status(gb_json* opt, std::function<GET_SANE_OPT_PROTO> get_opt); // NOTE: this function only changed 'enabled' status according field 'range', record status before if some options can affect others.
static data_type type_from_string(const char* type_desc); static data_type type_from_string(const char* type_desc);
static bool raw_value_in_json(gb_json* root, const char* key, std::string& val, uint32_t* type = nullptr/*data_type*/); static bool raw_value_in_json(gb_json* root, const char* key, std::string& val, uint32_t* type = nullptr/*data_type*/);
@ -91,10 +91,12 @@ public:
// Function: update field 'enabled' if a option changed and affect other options ... // Function: update field 'enabled' if a option changed and affect other options ...
// //
// Parameters: get_opt - function to get option value, return value is the same as get_config // Parameters: name - name of the changed option
// //
// Return: none // get_opt - function to get option value, return value is the same as get_config
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) = 0; //
// Return: whether any options (can affect other options) has been changed in this routine
virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) = 0;
// Function: get value of given key // Function: get value of given key
// //
@ -127,7 +129,7 @@ class sane_cfg_mgr : public refer
void refresh_api(sane_cfg_provider* prvd, std::vector<std::string>* given = nullptr); void refresh_api(sane_cfg_provider* prvd, std::vector<std::string>* given = nullptr);
void on_sane_provider_changed(sane_cfg_provider* prvd, bool add); void on_sane_provider_changed(sane_cfg_provider* prvd, bool add);
std::string get_all_configurations(void); std::string get_all_configurations(void);
void update_enable_status(void); void update_enable_status(const char* name);
public: public:
sane_cfg_mgr(); sane_cfg_mgr();
@ -143,7 +145,7 @@ public:
// following APIs' parameters are same as sane_cfg_provider ... // following APIs' parameters are same as sane_cfg_provider ...
int32_t get_config(std::string& text, const char* cfg_name = nullptr, std::string* strval = nullptr); int32_t get_config(std::string& text, const char* cfg_name = nullptr, std::string* strval = nullptr);
int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo); int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo, data_type type = DATA_TYPE_CUSTOM);
}; };

File diff suppressed because one or more lines are too long

View File

@ -12,189 +12,134 @@
class gb_json; class gb_json;
#define CIS_API std::function<int(int*)> // return error code, set real value to parameter if in-value was not exact
#define CAPTURED_IMG_RECEIVER_PROTO void(int data_type/*img_cb_type*/, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status, bool img_new, bool img_over) #define CAPTURED_IMG_RECEIVER_PROTO void(int data_type/*img_cb_type*/, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status, bool img_new, bool img_over)
typedef struct _cis_api
{
CIS_API set_color_mode;
CIS_API set_dpi;
CIS_API set_sample;
CIS_API set_frame_height;
CIS_API set_gain_front;
CIS_API set_gain_back;
CIS_API set_offset_front;
CIS_API set_offset_back;
CIS_API set_exposure_front_red;
CIS_API set_exposure_front_green;
CIS_API set_exposure_front_blue;
CIS_API set_exposure_back_red;
CIS_API set_exposure_back_green;
CIS_API set_exposure_back_blue;
}CISAPI, *LPCISAPI;
// { // {
// "cis-mode": { // "cis-mode": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 2,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "CIS工作模式",
// "field": "cis", // "desc": "设置CIS彩色或者黑白的工作模式",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "CIS\u5de5\u4f5c\u6a21\u5f0f",
// "desc": "\u8bbe\u7f6eCIS\u5f69\u8272\u6216\u8005\u7070\u5ea6\u7684\u5de5\u4f5c\u6a21\u5f0f",
// "type": "string", // "type": "string",
// "cur": "\u5f69\u8272", // "unit": "none",
// "default": "\u5f69\u8272", // "affect": 2,
// "size": 12, // "readonly": false,
// "range": ["\u5f69\u8272", "\u7070\u5ea6"] // "visible": false,
// "enabled": true,
// "size": 30,
// "cur": "彩色",
// "default": "彩色",
// "range": ["彩色", "黑白"]
// }, // },
// "cis-dpi": { // "cis-dpi": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 2,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "CIS分辨率",
// "field": "cis", // "desc": "设置CIS采集的分辨率",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "CIS\u5206\u8fa8\u7387",
// "desc": "\u8bbe\u7f6eCIS\u91c7\u96c6\u7684\u5206\u8fa8\u7387",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 2,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 200, // "cur": 200,
// "default": 200, // "default": 200,
// "size": 4, // "range": [200, 300, 600]
// "range": [200, 300]
// },
// "cis-sample": {
// "category": "base",
// "readonly": false,
// "affect": 0,
// "group": "CIS",
// "visible": false,
// "field": "cis",
// "pos": 0,
// "ver": 1,
// "unit": "None",
// "title": "CIS\u91c7\u6837\u9891\u7387",
// "desc": "\u8bbe\u7f6eCIS\u955c\u5934\u91c7\u6837\u7684\u5de5\u4f5c\u9891\u7387",
// "type": "int",
// "cur": 256,
// "default": 256,
// "size": 4,
// "range": [128, 256, 512]
// },
// "frame-h": {
// "category": "base",
// "readonly": false,
// "affect": 0,
// "group": "CIS",
// "visible": false,
// "field": "cis",
// "pos": 0,
// "ver": 1,
// "unit": "None",
// "title": "CIS\u5e27\u9ad8\u5ea6",
// "desc": "\u8bbe\u7f6eCIS\u6bcf\u4e00\u5e27\u7684\u9ad8\u5ea6",
// "type": "int",
// "cur": 12,
// "default": 12,
// "size": 4,
// "range": [4, 8, 12, 16]
// }, // },
// "gain-front": { // "gain-front": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "正面增益",
// "field": "cis", // "desc": "设置CIS正面镜头的增益",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u6b63\u9762\u589e\u76ca",
// "desc": "\u8bbe\u7f6eCIS\u6b63\u9762\u955c\u5934\u7684\u589e\u76ca",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 200, // "cur": 200,
// "default": 200, // "default": 200,
// "size": 4,
// "range": [100, 200, 300, 600] // "range": [100, 200, 300, 600]
// }, // },
// "gain-back": { // "gain-back": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "背面增益",
// "field": "cis", // "desc": "设置CIS背面镜头的增益",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u80cc\u9762\u589e\u76ca",
// "desc": "\u8bbe\u7f6eCIS\u80cc\u9762\u955c\u5934\u7684\u589e\u76ca",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 200, // "cur": 200,
// "default": 200, // "default": 200,
// "size": 4,
// "range": [100, 200, 300, 600] // "range": [100, 200, 300, 600]
// }, // },
// "offset-front": { // "offset-front": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "正面偏移",
// "field": "cis", // "desc": "设置CIS正面的偏移距离",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u6b63\u9762\u504f\u79fb",
// "desc": "\u8bbe\u7f6eCIS\u6b63\u9762\u7684\u504f\u79fb\u8ddd\u79bb",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 150, // "cur": 150,
// "default": 150, // "default": 150,
// "size": 4,
// "range": [0, 50, 100, 150, 200] // "range": [0, 50, 100, 150, 200]
// }, // },
// "offset-back": { // "offset-back": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "背面偏移",
// "field": "cis", // "desc": "设置CIS背面的偏移距离",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u80cc\u9762\u504f\u79fb",
// "desc": "\u8bbe\u7f6eCIS\u80cc\u9762\u7684\u504f\u79fb\u8ddd\u79bb",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 150, // "cur": 150,
// "default": 150, // "default": 150,
// "size": 4,
// "range": [0, 50, 100, 150, 200] // "range": [0, 50, 100, 150, 200]
// }, // },
// "exposure-f-r": { // "exposure-f-r": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "正面红色分量曝光度",
// "field": "cis", // "desc": "设置正面红色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u6b63\u9762\u7ea2\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u6b63\u9762\u7ea2\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -202,21 +147,21 @@ typedef struct _cis_api
// } // }
// }, // },
// "exposure-f-g": { // "exposure-f-g": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "正面绿色分量曝光度",
// "field": "cis", // "desc": "设置正面绿色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u6b63\u9762\u7eff\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u6b63\u9762\u7eff\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -224,21 +169,21 @@ typedef struct _cis_api
// } // }
// }, // },
// "exposure-f-b": { // "exposure-f-b": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "正面蓝色分量曝光度",
// "field": "cis", // "desc": "设置正面蓝色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u6b63\u9762\u84dd\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u6b63\u9762\u84dd\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -246,21 +191,21 @@ typedef struct _cis_api
// } // }
// }, // },
// "exposure-b-r": { // "exposure-b-r": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "背面红色分量曝光度",
// "field": "cis", // "desc": "设置正背面红色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u80cc\u9762\u7ea2\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u6b63\u80cc\u9762\u7ea2\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -268,21 +213,21 @@ typedef struct _cis_api
// } // }
// }, // },
// "exposure-b-g": { // "exposure-b-g": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "背面绿色分量曝光度",
// "field": "cis", // "desc": "设置背面绿色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u80cc\u9762\u7eff\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u80cc\u9762\u7eff\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -290,21 +235,21 @@ typedef struct _cis_api
// } // }
// }, // },
// "exposure-b-b": { // "exposure-b-b": {
// "category": "base", // "cat": "cis",
// "readonly": false,
// "affect": 0,
// "group": "CIS", // "group": "CIS",
// "visible": false, // "title": "背面蓝色分量曝光度",
// "field": "cis", // "desc": "设置背面蓝色分量的曝光强度",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u80cc\u9762\u84dd\u8272\u5206\u91cf\u66dd\u5149\u5ea6",
// "desc": "\u8bbe\u7f6e\u80cc\u9762\u84dd\u8272\u5206\u91cf\u7684\u66dd\u5149\u5f3a\u5ea6",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 0, // "cur": 0,
// "default": 0, // "default": 0,
// "size": 4,
// "range": { // "range": {
// "min": -1000, // "min": -1000,
// "max": 1000, // "max": 1000,
@ -312,104 +257,460 @@ typedef struct _cis_api
// } // }
// }, // },
// "paper": { // "paper": {
// "category": "base", // "cat": "common",
// "group": "base",
// "title": "纸张尺寸",
// "desc": "设置出图大小",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 6,
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "common", // "enabled": true,
// "group": "base", // "size": 96,
// "pos": 0, // "cur": "匹配原始尺寸",
// "affect": 6, // "default": "匹配原始尺寸",
// "unit": "none", // "range": ["A3", "8开", "A4", "16开", "A5", "A6", "B4", "B5", "B6", "Letter", "Double Letter", "LEGAL", "匹配原始尺寸", "最大扫描尺寸自动裁切", "最大扫描尺寸", "三联试卷"]
// "ver": 1,
// "title": "\u7eb8\u5f20\u5c3a\u5bf8",
// "desc": "\u8bbe\u7f6e\u51fa\u56fe\u5927\u5c0f",
// "type": "string",
// "cur": "\u5339\u914d\u539f\u59cb\u5c3a\u5bf8",
// "default": "\u5339\u914d\u539f\u59cb\u5c3a\u5bf8",
// "size": 48,
// "range": ["A3", "8\u5f00", "A4", "16\u5f00", "A5", "A6", "B4", "B5", "B6", "Letter", "Double Letter", "LEGAL", "\u5339\u914d\u539f\u59cb\u5c3a\u5bf8", "\u6700\u5927\u626b\u63cf\u5c3a\u5bf8\u81ea\u52a8\u88c1\u5207", "\u6700\u5927\u626b\u63cf\u5c3a\u5bf8", "\u4e09\u8054\u8bd5\u5377"]
// }, // },
// "lateral": { // "lateral": {
// "category": "base", // "cat": "common",
// "group": "base",
// "title": "横向",
// "desc": "横向放纸",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 6,
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "common", // "enabled": true,
// "group": "base", // "size": 4,
// "pos": 0,
// "affect": 4,
// "unit": "none",
// "ver": 1,
// "title": "\u6a2a\u5411",
// "desc": "\u6a2a\u5411\u653e\u7eb8",
// "type": "bool",
// "cur": false, // "cur": false,
// "default": false, // "default": false,
// "size": 4,
// "depend_or": ["paper==A4", "==A5", "==A6", "==B5", "==B6", "==Letter"] // "depend_or": ["paper==A4", "==A5", "==A6", "==B5", "==B6", "==Letter"]
// }, // },
// "paper-w": { // "paper-w": {
// "category": "base", // "cat": "common",
// "group": "base",
// "title": "纸张宽度(像素)",
// "desc": "选择的固定大小纸张的宽度",
// "ver": 1,
// "pos": 0,
// "type": "int",
// "unit": "pixel",
// "affect": 0,
// "readonly": true, // "readonly": true,
// "visible": false, // "visible": false,
// "field": "common", // "enabled": true,
// "group": "base", // "size": 4,
// "pos": 0,
// "unit": "pixel",
// "ver": 1,
// "title": "\u7eb8\u5f20\u5bbd\u5ea6",
// "desc": "\u9009\u62e9\u7684\u56fa\u5b9a\u5927\u5c0f\u7eb8\u5f20\u7684\u5bbd\u5ea6",
// "type": "int",
// "cur": 1654, // "cur": 1654,
// "default": 1654, // "default": 1654
// "size": 4
// }, // },
// "paper-h": { // "paper-h": {
// "category": "base", // "cat": "common",
// "group": "base",
// "title": "纸张高度(像素)",
// "desc": "选择的固定大小纸张的宽度",
// "ver": 1,
// "pos": 0,
// "type": "int",
// "unit": "pixel",
// "affect": 0,
// "readonly": true, // "readonly": true,
// "visible": false, // "visible": false,
// "field": "common", // "enabled": true,
// "size": 4,
// "cur": 2339,
// "default": 2339
// },
// "is-custom-area": {
// "cat": "imgp",
// "group": "base", // "group": "base",
// "pos": 0, // "title": "自定义扫描区域",
// "unit": "pixel", // "desc": "自定义扫描区域",
// "ver": 1, // "ver": 1,
// "title": "\u7eb8\u5f20\u5bbd\u5ea6", // "pos": 302,
// "desc": "\u9009\u62e9\u7684\u56fa\u5b9a\u5927\u5c0f\u7eb8\u5f20\u7684\u5bbd\u5ea6", // "type": "bool",
// "unit": "none",
// "affect": 2,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false,
// "depend_and": ["paper!=匹配原始尺寸", "!=最大扫描尺寸", "!=最大扫描尺寸自动裁切"]
// },
// "tl-x": {
// "cat": "imgp",
// "group": "base",
// "title": "扫描区域左侧(像素)",
// "desc": "自定义扫描区域左上角x坐标",
// "ver": 1,
// "pos": 303,
// "type": "int", // "type": "int",
// "unit": "pixel",
// "affect": 4,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": 0,
// "max": 1654,
// "step": 1
// },
// "depend_and": ["is-custom-area==true"]
// },
// "br-x": {
// "cat": "imgp",
// "group": "base",
// "title": "扫描区域右侧(像素)",
// "desc": "自定义扫描区域右下角x坐标",
// "ver": 1,
// "pos": 304,
// "type": "int",
// "unit": "pixel",
// "affect": 4,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 1654,
// "default": 1654,
// "range": {
// "min": 0,
// "max": 1654,
// "step": 1
// },
// "depend_and": ["is-custom-area==true"]
// },
// "tl-y": {
// "cat": "imgp",
// "group": "base",
// "title": "扫描区域上侧(像素)",
// "desc": "自定义扫描区域左上角y坐标",
// "ver": 1,
// "pos": 305,
// "type": "int",
// "unit": "pixel",
// "affect": 4,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": 0,
// "max": 2339,
// "step": 1
// },
// "depend_and": ["is-custom-area==true"]
// },
// "br-y": {
// "cat": "imgp",
// "group": "base",
// "title": "扫描区域下侧(像素)",
// "desc": "自定义扫描区域右下角y坐标",
// "ver": 1,
// "pos": 306,
// "type": "int",
// "unit": "pixel",
// "affect": 4,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 2339, // "cur": 2339,
// "default": 2339, // "default": 2339,
// "size": 4 // "range": {
// "min": 0,
// "max": 2339,
// "step": 1
// },
// "depend_and": ["is-custom-area==true"]
// }, // },
// "scan-count": { // "scan-count": {
// "category": "base", // "cat": "cis",
// "readonly": false, // "group": "base",
// "affect": 0, // "title": "扫描张数",
// "group": "CIS", // "desc": "设置扫描的纸张数量,“-1”为连续扫描",
// "visible": true,
// "field": "cis",
// "pos": 0,
// "ver": 1, // "ver": 1,
// "unit": "None", // "pos": 0,
// "title": "\u626b\u63cf\u5f20\u6570",
// "desc": "\u8bbe\u7f6e\u626b\u63cf\u7684\u7eb8\u5f20\u6570\u91cf\uFF0C\u201C-1\u201D\u4e3a\u8fde\u7eed\u626b\u63cf",
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": -1, // "cur": -1,
// "default": -1, // "default": -1,
// "size": 4,
// "range": [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // "range": [-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// },
// "double-feed-check": {
// "cat": "cis",
// "group": "feeder",
// "title": "双张检测",
// "desc": "设置双张检测模式",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 36,
// "cur": "超声波",
// "default": "超声波",
// "range": ["无", "超声波"]
// },
// "is-staple": {
// "cat": "cis",
// "group": "feeder",
// "title": "装订检测",
// "desc": "检测是否出现粘连送入",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "is-check-askew": {
// "cat": "cis",
// "group": "feeder",
// "title": "歪斜检测",
// "desc": "检测是否出现歪斜送入",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true
// },
// "askew-range": {
// "cat": "cis",
// "group": "feeder",
// "title": "歪斜容忍度",
// "desc": "值越小,能容忍得送入文稿歪斜角度越小",
// "ver": 1,
// "pos": 0,
// "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 3,
// "default": 3,
// "range": {
// "min": 1,
// "max": 5,
// "step": 1
// },
// "depend_or": ["is-check-askew==true"]
// },
// "chip-pos-correct": {
// "cat": "cis",
// "group": "CIS",
// "title": "校正模式(位置)",
// "desc": "启用芯片上的位置校正功能",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "auto-scan": {
// "cat": "cis",
// "group": "advance",
// "title": "待纸扫描",
// "desc": "当纸张放上扫描仪时,自动开启扫描",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "photo-mode": {
// "cat": "cis",
// "group": "advance",
// "title": "照片模式",
// "desc": "照片模式可以保留图片更多细节",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "chip-color-correct": {
// "cat": "cis",
// "group": "CIS",
// "title": "图像校正(颜色)",
// "desc": "启用芯片上的颜色校正功能",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "is-size-check": {
// "cat": "cis",
// "group": "base",
// "title": "尺寸检测",
// "desc": "固定幅面下检测纸张尺寸是否匹配",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 2,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "chip-cache": {
// "cat": "cis",
// "group": "CIS",
// "title": "片上缓存",
// "desc": "是否在片上缓存图片",
// "ver": 1,
// "pos": 0,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false
// },
// "chip-size-err": {
// "cat": "cis",
// "group": "CIS",
// "title": "幅面检测误差",
// "desc": "设置尺寸检测时的误差大小",
// "ver": 1,
// "pos": 0,
// "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 0,
// "default": 0,
// "range": {
// "min": 0,
// "max": 512,
// "step": 1
// },
// "depend_or": ["is-size-check==true"]
// } // }
// } // }
class image_capture : public sane_cfg_provider class image_capture : public sane_cfg_provider
{ {
enum cis_dpi
{
CIS_DPI_200 = 1,
CIS_DPI_300,
CIS_DPI_600,
};
typedef union _cis_reg
{
unsigned int unvalue;
struct
{
unsigned int paper : 5; // 纸张类型 (每个型号有不同的映射表)
unsigned int color : 1; // 是否彩色 0 - 黑白, 1 - 彩色
unsigned int dpi : 2; // DPI 映射表1 - 200; 2 - 300; 3 - 600
unsigned int ultrasonic_enable : 1; // 是否进行超声波检测(双/多张进纸检测)
unsigned int staple_enbale : 1; // 是否进行钉书钉检测
unsigned int screw_detect_enable : 1; // 是否歪斜检测
unsigned int screw_detect_level : 3; // 歪斜检测水平
unsigned int iscorrect_mod : 1; // 是否自动校正 - 位置
unsigned int is_autopaper : 1; // 是否自动进纸
unsigned int is_photomode : 1; // 1 - 照片模式0 - 文本模式。默认值为 0
unsigned int is_fixedpaper : 1; // is_fixedpaper 为false en_autosize为true自适应幅面开启
unsigned int en_anlogic_key : 1; //
unsigned int en_autosize : 1; //
unsigned int pc_correct : 1; // 是否在PC端校正 1:不校正 cis原图0:校正 - 颜色
unsigned int enable_sizecheck : 1; // 是否进行尺寸检测
unsigned int enabledsp_cache : 1; // 是否在片上缓存
unsigned int sizeerror_errorratio : 9; // 幅面检测
};
}CISREG;
gb_json* cfg_; gb_json* cfg_;
CISAPI api_;
double dpi_x_; double dpi_x_;
double dpi_y_; double dpi_y_;
CISREG cis_reg_;
std::function<CAPTURED_IMG_RECEIVER_PROTO> img_keeper_; std::function<CAPTURED_IMG_RECEIVER_PROTO> img_keeper_;
void set_paper(const char* name);
void set_color_mode(const char* color);
void set_dpi_val(int dpi);
void set_ultrasonic(const char* method);
void init_cis_value(void);
int32_t set(const char* name, void* data, size_t* len); int32_t set(const char* name, void* data, size_t* len);
void refresh_paper_size(bool from_paper_type = false); enum
{
CHG_PAPER_SIZE_FROM_PAPER = 0,
CHG_PAPER_SIZE_FROM_LATERAL,
CHG_PAPER_SIZE_FROM_DPI,
};
void refresh_paper_size(int from);
void change_custom_area_range(double mm_w, double mm_h);
public: public:
image_capture(std::function<CAPTURED_IMG_RECEIVER_PROTO> receiver); image_capture(std::function<CAPTURED_IMG_RECEIVER_PROTO> receiver);
@ -421,30 +722,11 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public:
void set_api(LPCISAPI api);
public: public:
int32_t start(void); int32_t start(void);
int32_t stop(void); int32_t stop(void);
// Function: set resolution of hardware/CIS
//
// Parameters: dpi_x - [in]resolution of x axis to be set; [out]applied value, not set if it was nullptr
//
// dpi_y - [in]resolution of y axis to be set; [out]applied value, not set if it was nullptr
//
// Return: always 0. if input value is not accessible, the exact value is stored into the var
int set_dpi(int* dpi_x, int* dpi_y);
// Function: set resolution of hardware/CIS
//
// Parameters: mode - [in]color to be set; [out]applied value
//
// Return: always 0. if input value is not accessible, the exact value is stored into the var
int set_color_mode(color_mode* mode);
}; };

View File

@ -11,13 +11,12 @@
static std::string auto_crop_jsn = static std::string auto_crop_jsn =
""; "{\"is-crop\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u56fe\\u7247\\u88c1\\u5207\",\"desc\":\"\\u5c06\\u56fe\\u7247\\u88c1\\u5207\\u5230\\u9002\\u5408\\u7eb8\\u5f20\\u7684\\u5927\\u5c0f\\uff0c\\u6216\\u8005\\u7528\\u6237\\u81ea\\u5b9a\\u4e49\\u5927\\u5c0f\",\"ver\":1,\"pos\":300,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"is-auto-crop\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u81ea\\u52a8\\u88c1\\u5207\",\"desc\":\"\\u5c06\\u56fe\\u7247\\u88c1\\u5207\\u5230\\u9002\\u5408\\u5df2\\u77e5\\u7eb8\\u5f20\\uff08\\u5982A4\\uff09\\u7684\\u5927\\u5c0f\",\"ver\":1,\"pos\":301,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true,\"depend_or\":[\"is-crop==true\"]},\"is-erase-black-frame\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"ver\":1,\"pos\":320,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"bkg-fill-mode\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"ver\":1,\"pos\":321,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend_or\":[\"is-erase-black-frame==true\"]},\"is-fill-color\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"ver\":1,\"pos\":330,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend_and\":[\"is-erase-black-frame==true\"]},\"bg-fill-color\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u989c\\u8272\",\"desc\":\"\\u8bbe\\u7f6e\\u7528\\u4e8e\\u80cc\\u666f\\u586b\\u5145\\u7684\\u989c\\u8272\\uff0c-1\\u4e3a\\u81ea\\u52a8\\u989c\\u8272\\u586b\\u5145\",\"ver\":1,\"pos\":331,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":0,\"default\":0,\"depend_and\":[\"is-fill-color==true\"]}}";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// class img_algs // class img_algs
auto_crop::auto_crop() : root_(new gb_json()) auto_crop::auto_crop() : root_(new gb_json())
, name_("is-discard-blank"), pos_(0), ver_(0), enable_(false) , name_("is-crop"), pos_(300), ver_(1), enable_(true)
, threshold_(40), indent_(30), stroke_(50), bg_clr_(200), noise_(11), universal_(true)
{ {
root_->attach_text(&auto_crop_jsn[0]); root_->attach_text(&auto_crop_jsn[0]);
init_value_from_json(); init_value_from_json();
@ -30,51 +29,6 @@ auto_crop::~auto_crop()
void auto_crop::init_value_from_json(void) void auto_crop::init_value_from_json(void)
{ {
gb_json* child = nullptr; gb_json* child = nullptr;
if(root_->get_value(name_.c_str(), child) && child)
{
int val = 0;
child->get_value("cur", enable_);
child->get_value("ver", val);
ver_ = val;
child->get_value("pos", val);
pos_ = val;
child->release();
}
if(root_->get_value("discard-blank", child) && child)
{
std::string val("");
child->get_value("cur", val);
universal_ = val != "\xE5\x8F\x91\xE7\xA5\xA8\xE7\xBA\xB8";
child->release();
}
if(root_->get_value("blank-sensitivity", child) && child)
{
child->get_value("cur", stroke_);
child->release();
}
if(root_->get_value("blank-threshold", child) && child)
{
child->get_value("cur", threshold_);
child->release();
}
if(root_->get_value("blank-indent", child) && child)
{
child->get_value("cur", indent_);
child->release();
}
if(root_->get_value("blank-bg-clr", child) && child)
{
child->get_value("cur", bg_clr_);
child->release();
}
if(root_->get_value("blank-noise", child) && child)
{
child->get_value("cur", noise_);
child->release();
}
} }
int32_t auto_crop::get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval) int32_t auto_crop::get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval)
@ -113,10 +67,6 @@ int32_t auto_crop::set_config(const char* cfg_name, void* data, size_t* len, uin
ret = sane_cfg_provider::sane_refine_range(child, data, len) ? 0 : EUCLEAN; ret = sane_cfg_provider::sane_refine_range(child, data, len) ? 0 : EUCLEAN;
sane_cfg_provider::sane_option_value_set(child, data); sane_cfg_provider::sane_option_value_set(child, data);
init_value_from_json(); init_value_from_json();
if(strcmp(cfg_name, "discard-blank") == 0)
{
noise_ = universal_ ? 200 : 150;
}
if(afterdo) if(afterdo)
{ {
@ -130,7 +80,7 @@ int32_t auto_crop::set_config(const char* cfg_name, void* data, size_t* len, uin
return ret; return ret;
} }
void auto_crop::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool auto_crop::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
gb_json* child = root_->first_child(); gb_json* child = root_->first_child();
while(child) while(child)
@ -139,6 +89,8 @@ void auto_crop::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt)
child->release(); child->release();
child = root_->next_child(); child = root_->next_child();
} }
return false;
} }
int32_t auto_crop::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t auto_crop::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
@ -158,7 +110,10 @@ img_one_paper* auto_crop::execute(img_one_paper* img)
{ {
for(auto& v : img->images_queue()) for(auto& v : img->images_queue())
{ {
// CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(v.img, threshold_, indent_, stroke_, bg_clr_, noise_); cv::Mat src(std::move(v.img));
CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(src, v.img, auto_crop_, des_askew_, fill_blank_, 0, 0, convex_, auto_fill_color_, threshold_, noise_, indent_, new_crop_, ratio_x_, ratio_y_);
v.head.width = v.img.cols;
v.head.height = v.img.rows;
} }
img->add_ref(); img->add_ref();

View File

@ -10,6 +10,115 @@
// {
// "is-crop": {
// "cat": "imgp",
// "group": "imgp",
// "title": "图片裁切",
// "desc": "将图片裁切到适合纸张的大小,或者用户自定义大小",
// "ver": 1,
// "pos": 300,
// "type": "bool",
// "unit": "none",
// "affect": 2,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true
// },
// "is-auto-crop": {
// "cat": "imgp",
// "group": "imgp",
// "title": "自动裁切",
// "desc": "将图片裁切到适合已知纸张如A4的大小",
// "ver": 1,
// "pos": 301,
// "type": "bool",
// "unit": "none",
// "affect": 2,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true,
// "depend_or": ["is-crop==true"]
// },
// "is-erase-black-frame": {
// "cat": "imgp",
// "group": "imgp",
// "title": "消除黑框",
// "desc": "消除文稿范围外的黑色背景",
// "ver": 1,
// "pos": 320,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true
// },
// "bkg-fill-mode": {
// "cat": "imgp",
// "group": "imgp",
// "title": "背景填充方式",
// "desc": "选择背景填充方式",
// "ver": 1,
// "pos": 321,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 42,
// "cur": "凸多边形",
// "default": "凸多边形",
// "range": ["凸多边形", "凹多边形"],
// "depend_or": ["is-erase-black-frame==true"]
// },
// "is-fill-color": {
// "cat": "imgp",
// "group": "imgp",
// "title": "色彩填充",
// "desc": "启用后黑框部分将填充为文稿底色",
// "ver": 1,
// "pos": 330,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": false,
// "default": false,
// "depend_and": ["is-erase-black-frame==true"]
// },
// "bg-fill-color": {
// "cat": "imgp",
// "group": "imgp",
// "title": "背景填充颜色",
// "desc": "设置用于背景填充的颜色,-1为自动颜色填充",
// "ver": 1,
// "pos": 331,
// "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 0,
// "default": 0,
// "depend_and": ["is-fill-color==true"]
// }
// }
class gb_json; class gb_json;
@ -23,12 +132,17 @@ class auto_crop : public img_alg
uint32_t ver_; uint32_t ver_;
bool enable_; bool enable_;
int threshold_; bool auto_crop_ = true;
int indent_; bool des_askew_ = true;
int stroke_; // sensitivity bool fill_blank_ = true;
int bg_clr_; bool convex_ = true;
int noise_; bool auto_fill_color_ = true;
bool universal_; int threshold_ = 40;
int noise_ = 8;
int indent_ = 5;
bool new_crop_ = false;
double ratio_x_ = 1.0f;
double ratio_y_ = 1.0f;
void init_value_from_json(void); void init_value_from_json(void);
@ -40,7 +154,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -11,7 +11,7 @@
static std::string discard_blank_jsn = static std::string discard_blank_jsn =
"{\"is-discard-blank\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"affect\":2,\"pos\":200,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\",\"desc\":\"\\u5982\\u679c\\u68c0\\u6d4b\\u5230\\u56fe\\u50cf\\u4e3a\\u7a7a\\u767d\\uFF0C\\u5219\\u4e22\\u5f03\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"discard-blank\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":201,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7c7b\\u578b\",\"desc\":\"\\u901a\\u7528\\u548c\\u53d1\\u7968\\uFF0C\\u5176\\u4e2d\\u4e4b\\u4e00\",\"type\":\"string\",\"cur\":\"\\u901a\\u7528\",\"default\":\"\\u901a\\u7528\",\"size\":40,\"range\":[\"\\u901a\\u7528\",\"\\u53d1\\u7968\\u7eb8\"],\"depend_or\":[\"is-discard-blank==true\"]},\"blank-sensitivity\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":202,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\uFF0C\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-threshold\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":210,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u8f6e\\u5ed3\\u9608\\u503c\",\"desc\":\"\\u8f6e\\u5ed3\\u9608\\u503c\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-indent\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":211,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7a\\u767d\\u9875\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u7a7a\\u767d\\u9875\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"type\":\"int\",\"cur\":30,\"default\":30,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-bg-clr\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":212,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u80cc\\u666f\\u8272\\u9608\\u503c\",\"desc\":\"\\u4f4e\\u4e8e\\u8be5\\u503c\\uFF0C\\u88ab\\u89c6\\u4f5c\\u80cc\\u666f\\u989c\\u8272\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":1,\"max\":255,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-noise\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":213,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7eb8\\u5f20\\u6742\\u70b9\",\"desc\":\"\\u5ffd\\u7565\\u7eb8\\u5f20\\u6742\\u70b9\\u3002\\u22641\\u65f6\\u4e0d\\u751f\\u6548\\uFF0C\\u503c\\u8d8a\\u5927\\u8d8a\\u5bb9\\u6613\\u5ffd\\u7565\\u6742\\u70b9\",\"type\":\"int\",\"cur\":11,\"default\":11,\"size\":4,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]}}"; "{\"is-discard-blank\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\",\"desc\":\"\\u5982\\u679c\\u68c0\\u6d4b\\u5230\\u56fe\\u50cf\\u4e3a\\u7a7a\\u767d\\uff0c\\u5219\\u4e22\\u5f03\",\"ver\":1,\"pos\":200,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"discard-blank\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7c7b\\u578b\",\"desc\":\"\\u901a\\u7528\\u548c\\u53d1\\u7968\\uff0c\\u5176\\u4e2d\\u4e4b\\u4e00\",\"ver\":1,\"pos\":201,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":36,\"cur\":\"\\u901a\\u7528\",\"default\":\"\\u901a\\u7528\",\"range\":[\"\\u901a\\u7528\",\"\\u53d1\\u7968\\u7eb8\"],\"depend_or\":[\"is-discard-blank==true\"]},\"blank-sensitivity\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\uff0c\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"ver\":1,\"pos\":202,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":50,\"default\":50,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-threshold\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u8f6e\\u5ed3\\u9608\\u503c\",\"desc\":\"\\u8f6e\\u5ed3\\u9608\\u503c\",\"ver\":1,\"pos\":210,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":40,\"default\":40,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-indent\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7a\\u767d\\u9875\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u7a7a\\u767d\\u9875\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"ver\":1,\"pos\":211,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":30,\"default\":30,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-bg-clr\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u8272\\u9608\\u503c\",\"desc\":\"\\u4f4e\\u4e8e\\u8be5\\u503c\\uff0c\\u88ab\\u89c6\\u4f5c\\u80cc\\u666f\\u989c\\u8272\",\"ver\":1,\"pos\":212,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":200,\"default\":200,\"range\":{\"min\":1,\"max\":255,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]},\"blank-noise\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7eb8\\u5f20\\u6742\\u70b9\",\"desc\":\"\\u5ffd\\u7565\\u7eb8\\u5f20\\u6742\\u70b9\\u3002\\u22641\\u65f6\\u4e0d\\u751f\\u6548\\uff0c\\u503c\\u8d8a\\u5927\\u8d8a\\u5bb9\\u6613\\u5ffd\\u7565\\u6742\\u70b9\",\"ver\":1,\"pos\":213,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":11,\"default\":11,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend_or\":[\"is-discard-blank==true\"]}}";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// class img_algs // class img_algs
@ -130,7 +130,7 @@ int32_t discard_blank::set_config(const char* cfg_name, void* data, size_t* len,
return ret; return ret;
} }
void discard_blank::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool discard_blank::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
gb_json* child = root_->first_child(); gb_json* child = root_->first_child();
while(child) while(child)
@ -139,6 +139,8 @@ void discard_blank::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt)
child->release(); child->release();
child = root_->next_child(); child = root_->next_child();
} }
return false;
} }
int32_t discard_blank::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t discard_blank::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {

View File

@ -11,55 +11,57 @@
// { // {
// "is-discard-blank": { // "is-discard-blank": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "field": "imgproc",
// "group": "imgproc",
// "affect": 2,
// "pos": 200,
// "unit": "none",
// "ver": 1,
// "title": "跳过空白页", // "title": "跳过空白页",
// "desc": "如果检测到图像为空白,则丢弃", // "desc": "如果检测到图像为空白,则丢弃",
// "ver": 1,
// "pos": 200,
// "type": "bool", // "type": "bool",
// "cur": false, // "unit": "none",
// "default": false, // "affect": 2,
// "size": 4
// },
// "discard-blank": {
// "category": "base",
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "imgproc", // "enabled": true,
// "group": "imgproc", // "size": 4,
// "pos": 201, // "cur": false,
// "unit": "none", // "default": false
// "ver": 1, // },
// "discard-blank": {
// "cat": "imgp",
// "group": "imgp",
// "title": "跳过空白页类型", // "title": "跳过空白页类型",
// "desc": "通用和发票,其中之一", // "desc": "通用和发票,其中之一",
// "ver": 1,
// "pos": 201,
// "type": "string", // "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 36,
// "cur": "通用", // "cur": "通用",
// "default": "通用", // "default": "通用",
// "size": 40,
// "range": ["通用", "发票纸"], // "range": ["通用", "发票纸"],
// "depend_or": ["is-discard-blank==true"] // "depend_or": ["is-discard-blank==true"]
// }, // },
// "blank-sensitivity": { // "blank-sensitivity": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 202,
// "unit": "none",
// "ver": 1,
// "title": "跳过空白页灵敏度", // "title": "跳过空白页灵敏度",
// "desc": "数值越大,则越容易跳过", // "desc": "数值越大,则越容易跳过",
// "ver": 1,
// "pos": 202,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 4,
// "cur": 50, // "cur": 50,
// "default": 50, // "default": 50,
// "size": 4,
// "range": { // "range": {
// "min": 1, // "min": 1,
// "max": 100, // "max": 100,
@ -68,20 +70,21 @@
// "depend_or": ["is-discard-blank==true"] // "depend_or": ["is-discard-blank==true"]
// }, // },
// "blank-threshold": { // "blank-threshold": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 210,
// "unit": "none",
// "ver": 1,
// "title": "轮廓阈值", // "title": "轮廓阈值",
// "desc": "轮廓阈值", // "desc": "轮廓阈值",
// "ver": 1,
// "pos": 210,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 40, // "cur": 40,
// "default": 40, // "default": 40,
// "size": 4,
// "range": { // "range": {
// "min": 1, // "min": 1,
// "max": 100, // "max": 100,
@ -90,20 +93,21 @@
// "depend_or": ["is-discard-blank==true"] // "depend_or": ["is-discard-blank==true"]
// }, // },
// "blank-indent": { // "blank-indent": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 211,
// "unit": "none",
// "ver": 1,
// "title": "空白页边缘缩进", // "title": "空白页边缘缩进",
// "desc": "空白页边缘缩进", // "desc": "空白页边缘缩进",
// "ver": 1,
// "pos": 211,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 30, // "cur": 30,
// "default": 30, // "default": 30,
// "size": 4,
// "range": { // "range": {
// "min": 1, // "min": 1,
// "max": 100, // "max": 100,
@ -112,20 +116,21 @@
// "depend_or": ["is-discard-blank==true"] // "depend_or": ["is-discard-blank==true"]
// }, // },
// "blank-bg-clr": { // "blank-bg-clr": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 212,
// "unit": "none",
// "ver": 1,
// "title": "背景色阈值", // "title": "背景色阈值",
// "desc": "低于该值,被视作背景颜色", // "desc": "低于该值,被视作背景颜色",
// "ver": 1,
// "pos": 212,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 200, // "cur": 200,
// "default": 200, // "default": 200,
// "size": 4,
// "range": { // "range": {
// "min": 1, // "min": 1,
// "max": 255, // "max": 255,
@ -134,20 +139,21 @@
// "depend_or": ["is-discard-blank==true"] // "depend_or": ["is-discard-blank==true"]
// }, // },
// "blank-noise": { // "blank-noise": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 213,
// "unit": "none",
// "ver": 1,
// "title": "纸张杂点", // "title": "纸张杂点",
// "desc": "忽略纸张杂点。≤1时不生效值越大越容易忽略杂点", // "desc": "忽略纸张杂点。≤1时不生效值越大越容易忽略杂点",
// "ver": 1,
// "pos": 213,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 11, // "cur": 11,
// "default": 11, // "default": 11,
// "size": 4,
// "range": { // "range": {
// "min": 1, // "min": 1,
// "max": 100, // "max": 100,
@ -186,7 +192,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -10,7 +10,7 @@
static std::string dogear_jsn("{\"is-check-dog-ear\":{\"category\":\"base\",\"readonly\":false,\"affect\":2,\"group\":\"feeder\",\"visible\":true,\"field\":\"imgproc\",\"pos\":10,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"dog-ear-size\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":true,\"field\":\"imgproc\",\"pos\":11,\"ver\":1,\"unit\":\"None\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":70,\"default\":70,\"size\":4,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-size-outer\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":false,\"field\":\"imgproc\",\"pos\":12,\"ver\":1,\"unit\":\"None\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\\u5728\\u56fe\\u7247\\u5916\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"type\":\"int\",\"cur\":70,\"default\":70,\"size\":4,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-zoom-x\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":false,\"field\":\"imgproc\",\"pos\":13,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u539f\\u56feX\\u8f74\\u7f29\\u653e\\u6bd4\\u4f8b\",\"desc\":\"\\u5BF9\\u4E8E\\u5927\\u5C3A\\u5BF8\\u56FE\\u50CF\\u800C\\u8A00\\u901A\\u8FC7zoom\\u7F29\\u5C0F\\u56FE\\u50CF\\u53EF\\u51CF\\u5C11\\u8BA1\\u7B97\\u91CF\\u3002\\u9ED8\\u8BA4\\u503C1.0\",\"type\":\"float\",\"cur\":1.0,\"default\":1.0,\"size\":8,\"range\":{\"min\":0.1,\"max\":4.0,\"step\":0.5},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-zoom-y\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":false,\"field\":\"imgproc\",\"pos\":14,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u539f\\u56fey\\u8f74\\u7f29\\u653e\\u6bd4\\u4f8b\",\"desc\":\"\\u5BF9\\u4E8E\\u5927\\u5C3A\\u5BF8\\u56FE\\u50CF\\u800C\\u8A00\\u901A\\u8FC7zoom\\u7F29\\u5C0F\\u56FE\\u50CF\\u53EF\\u51CF\\u5C11\\u8BA1\\u7B97\\u91CF\\u3002\\u9ED8\\u8BA4\\u503C1.0\",\"type\":\"float\",\"cur\":1.0,\"default\":1.0,\"size\":8,\"range\":{\"min\":0.1,\"max\":4.0,\"step\":0.5},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-threashold\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"feeder\",\"visible\":false,\"field\":\"imgproc\",\"pos\":15,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u4e8c\\u503c\\u5316\\u9608\\u503c\",\"desc\":\"\\u6298\\u89d2\\u68c0\\u6d4b\\u4e8c\\u503c\\u5316\\u53c2\\u6570\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":10,\"max\":100,\"step\":5},\"depend_or\":[\"is-check-dog-ear==true\"]}}"); static std::string dogear_jsn("{\"is-check-dog-ear\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"ver\":1,\"pos\":10,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"dog-ear-size\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"ver\":1,\"pos\":11,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":70,\"default\":70,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-size-outer\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\\uff08\\u5728\\u56fe\\u7247\\u5916\\uff09\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"ver\":1,\"pos\":12,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":70,\"default\":70,\"range\":{\"min\":0,\"max\":100,\"step\":1},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-zoom-x\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\"\\u539f\\u56feX\\u8f74\\u7f29\\u653e\\u6bd4\\u4f8b\",\"desc\":\"\\u5bf9\\u4e8e\\u5927\\u5c3a\\u5bf8\\u56fe\\u50cf\\u800c\\u8a00\\u901a\\u8fc7zoom\\u7f29\\u5c0f\\u56fe\\u50cf\\u53ef\\u51cf\\u5c11\\u8ba1\\u7b97\\u91cf\\u3002\\u9ed8\\u8ba4\\u503c1.0\",\"ver\":1,\"pos\":13,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":8,\"cur\":1.000000,\"default\":1.000000,\"range\":{\"min\":0.100000,\"max\":4.000000,\"step\":0.500000},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-zoom-y\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\"\\u539f\\u56fey\\u8f74\\u7f29\\u653e\\u6bd4\\u4f8b\",\"desc\":\"\\u5bf9\\u4e8e\\u5927\\u5c3a\\u5bf8\\u56fe\\u50cf\\u800c\\u8a00\\u901a\\u8fc7zoom\\u7f29\\u5c0f\\u56fe\\u50cf\\u53ef\\u51cf\\u5c11\\u8ba1\\u7b97\\u91cf\\u3002\\u9ed8\\u8ba4\\u503c1.0\",\"ver\":1,\"pos\":14,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":8,\"cur\":1.000000,\"default\":1.000000,\"range\":{\"min\":0.100000,\"max\":4.000000,\"step\":0.500000},\"depend_or\":[\"is-check-dog-ear==true\"]},\"dog-ear-threashold\":{\"cat\":\"imgp\",\"group\":\"feeder\",\"title\":\"\\u4e8c\\u503c\\u5316\\u9608\\u503c\",\"desc\":\"\\u6298\\u89d2\\u68c0\\u6d4b\\u4e8c\\u503c\\u5316\\u53c2\\u6570\",\"ver\":1,\"pos\":15,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":40,\"default\":40,\"range\":{\"min\":10,\"max\":100,\"step\":5},\"depend_or\":[\"is-check-dog-ear==true\"]}}");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// class img_algs // class img_algs
@ -140,7 +140,7 @@ int32_t dogear::set_config(const char* cfg_name, void* data, size_t* len, uint32
return ret; return ret;
} }
void dogear::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool dogear::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
gb_json* child = root_->first_child(); gb_json* child = root_->first_child();
while(child) while(child)
@ -149,6 +149,8 @@ void dogear::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt)
child->release(); child->release();
child = root_->next_child(); child = root_->next_child();
} }
return false;
} }
int32_t dogear::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t dogear::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {

View File

@ -9,140 +9,140 @@
//{ // {
// "is-check-dog-ear": { // "is-check-dog-ear": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": "折角检测",
// "group": "feeder", // "desc": "检测文稿是否存在折角",
// "visible": true, // "ver": 1,
// "field": "imgproc", // "pos": 10,
// "pos": 10, // "type": "bool",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 2,
// "title": "折角检测", // "readonly": false,
// "desc": "检测文稿是否存在折角", // "visible": true,
// "type": "bool", // "enabled": true,
// "cur": false, // "size": 4,
// "default": false, // "cur": false,
// "size": 4 // "default": false
// }, // },
// "dog-ear-size": { // "dog-ear-size": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": " 折角大小",
// "group": "feeder", // "desc": "值越小能检测到的折角越小",
// "visible": true, // "ver": 1,
// "field": "imgproc", // "pos": 11,
// "pos": 11, // "type": "int",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 0,
// "title": " 折角大小", // "readonly": false,
// "desc": "值越小,能检测到的折角越小", // "visible": true,
// "type": "int", // "enabled": true,
// "cur": 70, // "size": 4,
// "default": 70, // "cur": 70,
// "size": 4, // "default": 70,
// "range": { // "range": {
// "min": 0, // "min": 0,
// "max": 100, // "max": 100,
// "step": 1 // "step": 1
// }, // },
// "depend_or": ["is-check-dog-ear==true"] // "depend_or": ["is-check-dog-ear==true"]
// }, // },
// "dog-ear-size-outer": { // "dog-ear-size-outer": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": " 折角大小(在图片外)",
// "group": "feeder", // "desc": "值越小能检测到的折角越小",
// "visible": false, // "ver": 1,
// "field": "imgproc", // "pos": 12,
// "pos": 12, // "type": "int",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 0,
// "title": " 折角大小(超出图片)", // "readonly": false,
// "desc": "值越小,能检测到的折角越小", // "visible": false,
// "type": "int", // "enabled": true,
// "cur": 70, // "size": 4,
// "default": 70, // "cur": 70,
// "size": 4, // "default": 70,
// "range": { // "range": {
// "min": 0, // "min": 0,
// "max": 100, // "max": 100,
// "step": 1 // "step": 1
// }, // },
// "depend_or": ["is-check-dog-ear==true"] // "depend_or": ["is-check-dog-ear==true"]
// }, // },
// "dog-ear-zoom-x": { // "dog-ear-zoom-x": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": "原图X轴缩放比例",
// "group": "feeder", // "desc": "对于大尺寸图像而言通过zoom缩小图像可减少计算量。默认值1.0",
// "visible": false, // "ver": 1,
// "field": "imgproc", // "pos": 13,
// "pos": 13, // "type": "float",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 0,
// "title": "原图X轴缩放比例", // "readonly": false,
// "desc": "对于大尺寸图像而言通过zoom缩小图像可减少计算量。默认值1.0", // "visible": false,
// "type": "float", // "enabled": true,
// "cur": 1.0, // "size": 8,
// "default": 1.0, // "cur": 1.000000,
// "size": 4, // "default": 1.000000,
// "range": [ // "range": {
// "min": 0.1, // "min": 0.100000,
// "max": 4.0, // "max": 4.000000,
// "step": 0.5 // "step": 0.500000
// ], // },
// "depend_or": ["is-check-dog-ear==true"] // "depend_or": ["is-check-dog-ear==true"]
// }, // },
// "dog-ear-zoom-y": { // "dog-ear-zoom-y": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": "原图y轴缩放比例",
// "group": "feeder", // "desc": "对于大尺寸图像而言通过zoom缩小图像可减少计算量。默认值1.0",
// "visible": false, // "ver": 1,
// "field": "imgproc", // "pos": 14,
// "pos": 14, // "type": "float",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 0,
// "title": "原图y轴缩放比例", // "readonly": false,
// "desc": "对于大尺寸图像而言通过zoom缩小图像可减少计算量。默认值1.0", // "visible": false,
// "type": "float", // "enabled": true,
// "cur": 1.0, // "size": 8,
// "default": 1.0, // "cur": 1.000000,
// "size": 4, // "default": 1.000000,
// "range": [ // "range": {
// "min": 0.1, // "min": 0.100000,
// "max": 4.0, // "max": 4.000000,
// "step": 0.5 // "step": 0.500000
// ], // },
// "depend_or": ["is-check-dog-ear==true"] // "depend_or": ["is-check-dog-ear==true"]
// }, // },
// "dog-ear-threashold": { // "dog-ear-threashold": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "feeder",
// "affect": 0, // "title": "二值化阈值",
// "group": "feeder", // "desc": "折角检测二值化参数",
// "visible": false, // "ver": 1,
// "field": "imgproc", // "pos": 15,
// "pos": 15, // "type": "int",
// "ver": 1, // "unit": "none",
// "unit": "None", // "affect": 0,
// "title": "二值化阈值", // "readonly": false,
// "desc": "折角检测二值化参数", // "visible": false,
// "type": "int", // "enabled": true,
// "cur": 40, // "size": 4,
// "default": 40, // "cur": 40,
// "size": 4, // "default": 40,
// "range": [ // "range": {
// "min": 10, // "min": 10,
// "max": 100, // "max": 100,
// "step": 5 // "step": 5
// ], // },
// "depend_or": ["is-check-dog-ear==true"] // "depend_or": ["is-check-dog-ear==true"]
// }, // }
//} // }
class CImageApplyDogEarDetection; class CImageApplyDogEarDetection;
class gb_json; class gb_json;
@ -176,7 +176,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -105,8 +105,8 @@ img_alg* img_alg::create_image_algorithm(img_alg_type type)
return dynamic_cast<img_alg*>(new discard_blank()); return dynamic_cast<img_alg*>(new discard_blank());
if(type == IMG_ALG_COLOR_TRANSFER) if(type == IMG_ALG_COLOR_TRANSFER)
return dynamic_cast<img_alg*>(new img_color_transfer()); return dynamic_cast<img_alg*>(new img_color_transfer());
// if(type == IMG_ALG_AUTO_CROP) if(type == IMG_ALG_AUTO_CROP)
// return dynamic_cast<img_alg*>(new auto_crop()); return dynamic_cast<img_alg*>(new auto_crop());
return nullptr; return nullptr;
@ -133,25 +133,26 @@ const char* img_alg::option_name(void)
// class color_correct // class color_correct
// { // {
// "color-correct": { // "color-correct": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 400,
// "unit": "none",
// "ver": 1,
// "title": "颜色校正", // "title": "颜色校正",
// "desc": "校正由于硬件特性产生的色偏,使图片颜色更接近真实", // "desc": "校正由于硬件特性产生的色偏,使图片颜色更接近真实",
// "ver": 1,
// "pos": 400,
// "type": "string", // "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 42,
// "cur": "普通模式", // "cur": "普通模式",
// "default": "普通模式", // "default": "普通模式",
// "size": 20,
// "range": ["不校正", "普通模式", "增强模式"] // "range": ["不校正", "普通模式", "增强模式"]
// } // }
// } // }
static std::string color_correct_json = static std::string color_correct_json =
"{\"color-correct\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":400,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u989c\\u8272\\u6821\\u6b63\",\"desc\":\"\\u6821\\u6b63\\u7531\\u4e8e\\u786c\\u4ef6\\u7279\\u6027\\u4ea7\\u751f\\u7684\\u8272\\u504f\\uFF0C\\u4f7f\\u56fe\\u7247\\u989c\\u8272\\u66f4\\u63a5\\u8fd1\\u771f\\u5b9e\",\"type\":\"string\",\"cur\":\"\\u666e\\u901a\\u6a21\\u5f0f\",\"default\":\"\\u666e\\u901a\\u6a21\\u5f0f\",\"size\":20,\"range\":[\"\\u4e0d\\u6821\\u6b63\",\"\\u666e\\u901a\\u6a21\\u5f0f\",\"\\u589e\\u5f3a\\u6a21\\u5f0f\"]}}"; "{\"color-correct\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u989c\\u8272\\u6821\\u6b63\",\"desc\":\"\\u6821\\u6b63\\u7531\\u4e8e\\u786c\\u4ef6\\u7279\\u6027\\u4ea7\\u751f\\u7684\\u8272\\u504f\\uff0c\\u4f7f\\u56fe\\u7247\\u989c\\u8272\\u66f4\\u63a5\\u8fd1\\u771f\\u5b9e\",\"ver\":1,\"pos\":400,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u666e\\u901a\\u6a21\\u5f0f\",\"default\":\"\\u666e\\u901a\\u6a21\\u5f0f\",\"range\":[\"\\u4e0d\\u6821\\u6b63\",\"\\u666e\\u901a\\u6a21\\u5f0f\",\"\\u589e\\u5f3a\\u6a21\\u5f0f\"]}}";
color_correct::color_correct() : enable_(true), enhance_(false) color_correct::color_correct() : enable_(true), enhance_(false)
{ {
@ -220,8 +221,10 @@ int32_t color_correct::set_config(const char* cfg_name, void* data, size_t* len,
return ret; return ret;
} }
void color_correct::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool color_correct::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{} {
return false;
}
int32_t color_correct::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t color_correct::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
gb_json *child = nullptr; gb_json *child = nullptr;
@ -262,19 +265,21 @@ bool color_correct::is_enabled(std::function<int32_t(const char*, void*, size_t*
// class img_resizer // class img_resizer
// { // {
// "resolution": { // "resolution": {
// "category": "base", // "cat": "imgp",
// "group": "base",
// "title": "\u5206\u8fa8\u7387",
// "desc": "\u8bbe\u7f6e\u626b\u63cf\u56fe\u50cf\u7684\u5206\u8fa8\u7387",
// "ver": 1,
// "pos": 200,
// "type": "int",
// "unit": "dpi",
// "affect": 6,
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "Common", // "enabled": true,
// "pos": 0, // "size": 4,
// "unit": "DPI",
// "ver": 1,
// "title": "分辨率",
// "desc": "设置扫描图像的分辨率",
// "type": "int",
// "cur": 200, // "cur": 200,
// "default": 200, // "default": 200,
// "size": 4,
// "range": { // "range": {
// "min": 100, // "min": 100,
// "max": 600, // "max": 600,
@ -283,7 +288,7 @@ bool color_correct::is_enabled(std::function<int32_t(const char*, void*, size_t*
// } // }
// } // }
static std::string resize_json = static std::string resize_json =
"{\"resolution\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"base\",\"pos\":200,\"unit\":\"DPI\",\"ver\":1,\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"type\":\"int\",\"cur\":200,\"default\":200,\"size\":4,\"range\":{\"min\":100,\"max\":600,\"step\":50}}}"; "{\"resolution\":{\"cat\":\"imgp\",\"group\":\"base\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"ver\":1,\"pos\":200,\"type\":\"int\",\"unit\":\"dpi\",\"affect\":6,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":200,\"default\":200,\"range\":{\"min\":100,\"max\":600,\"step\":50}}}";
img_resizer::img_resizer() : dpi_(200), enable_(false) img_resizer::img_resizer() : dpi_(200), enable_(false)
{ {
@ -337,23 +342,37 @@ int32_t img_resizer::set_config(const char* cfg_name, void* data, size_t* len, u
if(cfg_->get_value(cfg_name, child) && child) if(cfg_->get_value(cfg_name, child) && child)
{ {
sane_cfg_provider::sane_refine_range(child, data, len); sane_cfg_provider::sane_refine_range(child, data, len);
if(name_ == cfg_name) // if(name_ == cfg_name)
{ {
dpi_ = *(int*)data; dpi_ = *(int*)data;
child->set_value("cur", dpi_); child->set_value("cur", dpi_);
if(afterdo)
int x = *(int*)data, {
y = x; int x = 0;
set_dpi(&x, &y); child->get_value("affect", x);
enable_ = x != dpi_ || y != dpi_; *afterdo = x;
}
} }
child->release(); child->release();
} }
return ret; return ret;
} }
void img_resizer::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool img_resizer::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{} {
uint32_t dtype = 0;
std::string val("");
if(get_opt("cis-dpi", "cur", val, &dtype) == 0)
{
if(dtype == DATA_TYPE_INT4)
enable_ = dpi_ != *(int*)val.c_str();
else if(dtype == DATA_TYPE_FLOAT)
enable_ = dpi_ != (int)*(double*)val.c_str();
}
return false;
}
int32_t img_resizer::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t img_resizer::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
gb_json *child = nullptr; gb_json *child = nullptr;
@ -371,8 +390,7 @@ int32_t img_resizer::get_raw_value(const char* name, const char* key, std::strin
img_one_paper* img_resizer::execute(img_one_paper* img) img_one_paper* img_resizer::execute(img_one_paper* img)
{ {
if(enable_) if(enable_)
{ {
for(auto& v: img->images_queue()) for(auto& v: img->images_queue())
{ {
double ratio_x = dpi_ * 1.0f / v.head.resolution_x, double ratio_x = dpi_ * 1.0f / v.head.resolution_x,
@ -396,26 +414,26 @@ bool img_resizer::is_enabled(std::function<int32_t(const char*, void*, size_t*)>
// class img_color_transfer // class img_color_transfer
// { // {
// "mode": { // "mode": {
// "category": "base", // "cat": "imgp",
// "readonly": false,
// "visible": true,
// "field": "imgproc",
// "group": "base", // "group": "base",
// "pos": 500,
// "unit": "none",
// "affect": 6,
// "ver": 1,
// "title": "颜色模式", // "title": "颜色模式",
// "desc": "选择色彩模式", // "desc": "选择色彩模式",
// "ver": 1,
// "pos": 500,
// "type": "string", // "type": "string",
// "unit": "none",
// "affect": 6,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 54,
// "cur": "24位彩色", // "cur": "24位彩色",
// "default": "24位彩色", // "default": "24位彩色",
// "size": 32,
// "range": ["24位彩色", "256级灰度", "黑白", "颜色自动识别"] // "range": ["24位彩色", "256级灰度", "黑白", "颜色自动识别"]
// } // }
// } // }
static std::string color_mode_json = static std::string color_mode_json =
"{\"mode\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"base\",\"pos\":500,\"unit\":\"none\",\"affect\":6,\"ver\":1,\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]}}"; "{\"mode\":{\"cat\":\"imgp\",\"group\":\"base\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"ver\":1,\"pos\":500,\"type\":\"string\",\"unit\":\"none\",\"affect\":6,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":54,\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]}}";
img_color_transfer::img_color_transfer() : enable_(false) img_color_transfer::img_color_transfer() : enable_(false)
{ {
@ -491,8 +509,10 @@ int32_t img_color_transfer::set_config(const char* cfg_name, void* data, size_t*
return ret; return ret;
} }
void img_color_transfer::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool img_color_transfer::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{} {
return false;
}
int32_t img_color_transfer::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t img_color_transfer::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
gb_json *child = nullptr; gb_json *child = nullptr;
@ -531,26 +551,26 @@ bool img_color_transfer::is_enabled(std::function<int32_t(const char*, void*, si
// class img_encoder // class img_encoder
// { // {
// "img-format": { // "img-format": {
// "category": "base", // "cat": "Common",
// "readonly": false,
// "affect": 0,
// "group": "output", // "group": "output",
// "visible": true,
// "field": "Common",
// "pos": 0,
// "unit": "None",
// "title": "图片格式", // "title": "图片格式",
// "desc": "设备输出的图片文件格式", // "desc": "设备输出的图片文件格式",
// "ver": 1,
// "pos": 0,
// "type": "string", // "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 42,
// "cur": "JPEG", // "cur": "JPEG",
// "default": "JPEG", // "default": "JPEG",
// "size": 20,
// "ver": 1,
// "range": ["JPEG", "PNG", "TIFF"] // "range": ["JPEG", "PNG", "TIFF"]
// } // }
// } // }
static std::string fmt_json = static std::string fmt_json =
"{\"img-format\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"output\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u56fe\\u7247\\u683c\\u5f0f\",\"desc\":\"\\u8bbe\\u5907\\u8f93\\u51fa\\u7684\\u56fe\\u7247\\u6587\\u4ef6\\u683c\\u5f0f\",\"type\":\"string\",\"cur\":\"JPEG\",\"default\":\"JPEG\",\"size\":20,\"ver\":1,\"range\":[\"JPEG\",\"PNG\",\"TIFF\"]}}"; "{\"img-format\":{\"cat\":\"Common\",\"group\":\"output\",\"title\":\"\\u56fe\\u7247\\u683c\\u5f0f\",\"desc\":\"\\u8bbe\\u5907\\u8f93\\u51fa\\u7684\\u56fe\\u7247\\u6587\\u4ef6\\u683c\\u5f0f\",\"ver\":1,\"pos\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"JPEG\",\"default\":\"JPEG\",\"range\":[\"JPEG\",\"PNG\",\"TIFF\"]}}";
img_encoder::img_encoder() : fmt_("JPEG") img_encoder::img_encoder() : fmt_("JPEG")
{ {
@ -619,8 +639,10 @@ int32_t img_encoder::set_config(const char* cfg_name, void* data, size_t* len, u
return ret; return ret;
} }
void img_encoder::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool img_encoder::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{} {
return false;
}
int32_t img_encoder::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t img_encoder::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
gb_json* child = nullptr; gb_json* child = nullptr;

View File

@ -127,7 +127,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:
@ -150,7 +150,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:
@ -174,7 +174,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:
@ -196,7 +196,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -11,7 +11,7 @@
static std::string remove_hole_jsn = static std::string remove_hole_jsn =
"{\"is-rid-hole-l\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"affect\":2,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":100,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-l\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":101,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u5de6\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-l==true\"]},\"is-rid-hole-r\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"affect\":2,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":110,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-r\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":111,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u53f3\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-r==true\"]},\"is-rid-hole-t\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"affect\":2,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":120,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-t\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":121,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u4e0a\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-t==true\"]},\"is-rid-hole-b\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"affect\":2,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":130,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"search-hole-range-b\":{\"category\":\"base\",\"readonly\":false,\"visible\":true,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":131,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u4e0b\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"type\":\"float\",\"cur\":0.100000,\"default\":0.100000,\"size\":4,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-b==true\"]},\"hole-side-len\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":140,\"unit\":\"pixel\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u8fb9\\u957f\\u9608\\u503c\",\"desc\":\"\\u7a7f\\u5b54\\u8fb9\\u957f\\u8d85\\u51fa\\u8be5\\u9608\\u503c\\u65f6\\uFF0C\\u5c06\\u88ab\\u79fb\\u9664\",\"type\":\"float\",\"cur\":25.0,\"default\":25.0,\"size\":4,\"range\":{\"min\":10.0,\"max\":50.0,\"step\":5}},\"hole-bin-threshold\":{\"category\":\"base\",\"readonly\":false,\"visible\":false,\"field\":\"imgproc\",\"group\":\"imgproc\",\"pos\":141,\"unit\":\"none\",\"ver\":1,\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u4e2d\\uFF0C\\u4e8c\\u503c\\u5316\\u56fe\\u50cf\\u7684\\u9608\\u503c\",\"desc\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u7b97\\u6cd5\\u4e2d\\uFF0C\\u4e8c\\u503c\\u5316\\u56fe\\u50cf\\u65f6\\uFF0C\\u91c7\\u7528\\u7684\\u9608\\u503c\",\"type\":\"int\",\"cur\":50,\"default\":50,\"size\":4,\"range\":{\"min\":0,\"max\":255,\"step\":1}}}"; "{\"is-rid-hole-l\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"ver\":1,\"pos\":100,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-l\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u5de6\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":1,\"pos\":101,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-l==true\"]},\"is-rid-hole-r\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"ver\":1,\"pos\":110,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-r\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u53f3\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":1,\"pos\":111,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-r==true\"]},\"is-rid-hole-t\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"ver\":1,\"pos\":120,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-t\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u4e0a\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":1,\"pos\":121,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-t==true\"]},\"is-rid-hole-b\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"ver\":1,\"pos\":130,\"type\":\"bool\",\"unit\":\"none\",\"affect\":2,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-b\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u4e0b\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":1,\"pos\":131,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend_and\":[\"is-rid-hole-b==true\"]},\"hole-side-len\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u8fb9\\u957f\\u9608\\u503c\",\"desc\":\"\\u7a7f\\u5b54\\u8fb9\\u957f\\u8d85\\u51fa\\u8be5\\u9608\\u503c\\u65f6\\uff0c\\u5c06\\u88ab\\u79fb\\u9664\",\"ver\":1,\"pos\":140,\"type\":\"float\",\"unit\":\"pixel\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":8,\"cur\":25.000000,\"default\":25.000000,\"range\":{\"min\":10.000000,\"max\":50.000000,\"step\":0.000000}},\"hole-bin-threshold\":{\"cat\":\"imgp\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u4e2d\\uff0c\\u4e8c\\u503c\\u5316\\u56fe\\u50cf\\u7684\\u9608\\u503c\",\"desc\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u7b97\\u6cd5\\u4e2d\\uff0c\\u4e8c\\u503c\\u5316\\u56fe\\u50cf\\u65f6\\uff0c\\u91c7\\u7528\\u7684\\u9608\\u503c\",\"ver\":1,\"pos\":141,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":50,\"default\":50,\"range\":{\"min\":0,\"max\":255,\"step\":1}}}";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// class img_algs // class img_algs
@ -134,7 +134,7 @@ int32_t rm_hole::set_config(const char* cfg_name, void* data, size_t* len, uint3
return ret; return ret;
} }
void rm_hole::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool rm_hole::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
gb_json* child = root_->first_child(); gb_json* child = root_->first_child();
while(child) while(child)
@ -143,6 +143,8 @@ void rm_hole::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt)
child->release(); child->release();
child = root_->next_child(); child = root_->next_child();
} }
return false;
} }
int32_t rm_hole::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t rm_hole::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {

View File

@ -11,37 +11,38 @@
// { // {
// "is-rid-hole-l": { // "is-rid-hole-l": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "affect": 2,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 100,
// "unit": "none",
// "ver": 1,
// "title": "穿孔移除—左侧", // "title": "穿孔移除—左侧",
// "desc": "穿孔在纸张上的左侧", // "desc": "穿孔在纸张上的左侧",
// "ver": 1,
// "pos": 100,
// "type": "bool", // "type": "bool",
// "cur": false, // "unit": "none",
// "default": false, // "affect": 2,
// "size": 4
// },
// "search-hole-range-l": {
// "category": "base",
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "imgproc", // "enabled": true,
// "group": "imgproc", // "size": 4,
// "pos": 101, // "cur": false,
// "unit": "none", // "default": false
// "ver": 1, // },
// "search-hole-range-l": {
// "cat": "imgp",
// "group": "imgp",
// "title": "左侧穿孔搜索范围占幅面比例", // "title": "左侧穿孔搜索范围占幅面比例",
// "desc": "穿孔搜索范围占幅面比例", // "desc": "穿孔搜索范围占幅面比例",
// "ver": 1,
// "pos": 101,
// "type": "float", // "type": "float",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 8,
// "cur": 0.100000, // "cur": 0.100000,
// "default": 0.100000, // "default": 0.100000,
// "size": 4,
// "range": { // "range": {
// "min": 0.000000, // "min": 0.000000,
// "max": 0.500000, // "max": 0.500000,
@ -50,37 +51,38 @@
// "depend_and": ["is-rid-hole-l==true"] // "depend_and": ["is-rid-hole-l==true"]
// }, // },
// "is-rid-hole-r": { // "is-rid-hole-r": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "affect": 2,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 110,
// "unit": "none",
// "ver": 1,
// "title": "穿孔移除—右侧", // "title": "穿孔移除—右侧",
// "desc": "穿孔在纸张上的右侧", // "desc": "穿孔在纸张上的右侧",
// "ver": 1,
// "pos": 110,
// "type": "bool", // "type": "bool",
// "cur": false, // "unit": "none",
// "default": false, // "affect": 2,
// "size": 4
// },
// "search-hole-range-r": {
// "category": "base",
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "imgproc", // "enabled": true,
// "group": "imgproc", // "size": 4,
// "pos": 111, // "cur": false,
// "unit": "none", // "default": false
// "ver": 1, // },
// "search-hole-range-r": {
// "cat": "imgp",
// "group": "imgp",
// "title": "右侧穿孔搜索范围占幅面比例", // "title": "右侧穿孔搜索范围占幅面比例",
// "desc": "穿孔搜索范围占幅面比例", // "desc": "穿孔搜索范围占幅面比例",
// "ver": 1,
// "pos": 111,
// "type": "float", // "type": "float",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 8,
// "cur": 0.100000, // "cur": 0.100000,
// "default": 0.100000, // "default": 0.100000,
// "size": 4,
// "range": { // "range": {
// "min": 0.000000, // "min": 0.000000,
// "max": 0.500000, // "max": 0.500000,
@ -89,37 +91,38 @@
// "depend_and": ["is-rid-hole-r==true"] // "depend_and": ["is-rid-hole-r==true"]
// }, // },
// "is-rid-hole-t": { // "is-rid-hole-t": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "affect": 2,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 120,
// "unit": "none",
// "ver": 1,
// "title": "穿孔移除—上侧", // "title": "穿孔移除—上侧",
// "desc": "穿孔在纸张的上部", // "desc": "穿孔在纸张的上部",
// "ver": 1,
// "pos": 120,
// "type": "bool", // "type": "bool",
// "cur": false, // "unit": "none",
// "default": false, // "affect": 2,
// "size": 4
// },
// "search-hole-range-t": {
// "category": "base",
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "imgproc", // "enabled": true,
// "group": "imgproc", // "size": 4,
// "pos": 121, // "cur": false,
// "unit": "none", // "default": false
// "ver": 1, // },
// "search-hole-range-t": {
// "cat": "imgp",
// "group": "imgp",
// "title": "上侧穿孔搜索范围占幅面比例", // "title": "上侧穿孔搜索范围占幅面比例",
// "desc": "穿孔搜索范围占幅面比例", // "desc": "穿孔搜索范围占幅面比例",
// "ver": 1,
// "pos": 121,
// "type": "float", // "type": "float",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 8,
// "cur": 0.100000, // "cur": 0.100000,
// "default": 0.100000, // "default": 0.100000,
// "size": 4,
// "range": { // "range": {
// "min": 0.000000, // "min": 0.000000,
// "max": 0.500000, // "max": 0.500000,
@ -128,37 +131,38 @@
// "depend_and": ["is-rid-hole-t==true"] // "depend_and": ["is-rid-hole-t==true"]
// }, // },
// "is-rid-hole-b": { // "is-rid-hole-b": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": true,
// "affect": 2,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 130,
// "unit": "none",
// "ver": 1,
// "title": "穿孔移除—下侧", // "title": "穿孔移除—下侧",
// "desc": "穿孔在纸张的下部", // "desc": "穿孔在纸张的下部",
// "ver": 1,
// "pos": 130,
// "type": "bool", // "type": "bool",
// "cur": false, // "unit": "none",
// "default": false, // "affect": 2,
// "size": 4
// },
// "search-hole-range-b": {
// "category": "base",
// "readonly": false, // "readonly": false,
// "visible": true, // "visible": true,
// "field": "imgproc", // "enabled": true,
// "group": "imgproc", // "size": 4,
// "pos": 131, // "cur": false,
// "unit": "none", // "default": false
// "ver": 1, // },
// "search-hole-range-b": {
// "cat": "imgp",
// "group": "imgp",
// "title": "下侧穿孔搜索范围占幅面比例", // "title": "下侧穿孔搜索范围占幅面比例",
// "desc": "穿孔搜索范围占幅面比例", // "desc": "穿孔搜索范围占幅面比例",
// "ver": 1,
// "pos": 131,
// "type": "float", // "type": "float",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": true,
// "enabled": true,
// "size": 8,
// "cur": 0.100000, // "cur": 0.100000,
// "default": 0.100000, // "default": 0.100000,
// "size": 4,
// "range": { // "range": {
// "min": 0.000000, // "min": 0.000000,
// "max": 0.500000, // "max": 0.500000,
@ -167,41 +171,43 @@
// "depend_and": ["is-rid-hole-b==true"] // "depend_and": ["is-rid-hole-b==true"]
// }, // },
// "hole-side-len": { // "hole-side-len": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 140,
// "unit": "pixel",
// "ver": 1,
// "title": "穿孔边长阈值", // "title": "穿孔边长阈值",
// "desc": "穿孔边长超出该阈值时,将被移除", // "desc": "穿孔边长超出该阈值时,将被移除",
// "ver": 1,
// "pos": 140,
// "type": "float", // "type": "float",
// "cur": 25.0, // "unit": "pixel",
// "default": 25.0, // "affect": 0,
// "size": 4, // "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 8,
// "cur": 25.000000,
// "default": 25.000000,
// "range": { // "range": {
// "min": 10.0, // "min": 10.000000,
// "max": 50.0, // "max": 50.000000,
// "step": 5 // "step": 0.000000
// } // }
// }, // },
// "hole-bin-threshold": { // "hole-bin-threshold": {
// "category": "base", // "cat": "imgp",
// "readonly": false, // "group": "imgp",
// "visible": false,
// "field": "imgproc",
// "group": "imgproc",
// "pos": 141,
// "unit": "none",
// "ver": 1,
// "title": "穿孔移除中,二值化图像的阈值", // "title": "穿孔移除中,二值化图像的阈值",
// "desc": "穿孔移除算法中,二值化图像时,采用的阈值", // "desc": "穿孔移除算法中,二值化图像时,采用的阈值",
// "ver": 1,
// "pos": 141,
// "type": "int", // "type": "int",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": 50, // "cur": 50,
// "default": 50, // "default": 50,
// "size": 4,
// "range": { // "range": {
// "min": 0, // "min": 0,
// "max": 255, // "max": 255,
@ -240,7 +246,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -6,45 +6,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// configuration text // configuration text
// //
//{
// "montage": {
// "category": "base",
// "readonly" : false,
// "affect" : 3,
// "group" : "base",
// "visible" : false,
// "field" : "cis",
// "val": 1,
// "pos" : 10,
// "unit" : "None",
// "title" : "ͼ<><CDBC>ƴ<EFBFBD><C6B4>",
// "desc" : "<22><>CIS<49>ɼ<EFBFBD><C9BC><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD>ݻָ<DDBB>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>",
// "type" : "bool",
// "cur" : true,
// "default" : true,
// "size" : 4
// },
// "fb-split": {
// "category": "base",
// "readonly" : false,
// "affect" : 2,
// "group" : "base",
// "visible" : false,
// "field" : "cis",
// "val": 1,
// "pos" : 20,
// "unit" : "None",
// "title" : "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
// "desc" : "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϳɵ<CFB3>һ<EFBFBD><D2BB>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>ͼƬ",
// "type" : "bool",
// "cur" : true,
// "default" : true,
// "size" : 4,
// "depend_and": ["montage==true"]
// }
//}
static std::string g_cis_cfg("{\"montage\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"CIS\",\"visible\":false,\"field\":\"cis\",\"pos\":10,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u56fe\\u50cf\\u62fc\\u63a5\",\"desc\":\"\\u5c06CIS\\u91c7\\u96c6\\u7684\\u539f\\u59cb\\u6570\\u636e\\u6062\\u590d\\u4e3a\\u6b63\\u5e38\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"fb-split\":{\"category\":\"base\",\"readonly\":false,\"affect\":0,\"group\":\"CIS\",\"visible\":false,\"field\":\"cis\",\"pos\":20,\"ver\":1,\"unit\":\"None\",\"title\":\"\\u62c6\\u5206\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u5c06\\u6b63\\u53cd\\u9762\\u5408\\u6210\\u7684\\u4e00\\u5f20\\u56fe\\u7247\\u62c6\\u5206\\u6210\\u6b63\\u9762\\u548c\\u53cd\\u9762\\u56fe\\u7247\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4}}"); static std::string g_cis_cfg("{\"montage\":{\"cat\":\"cis\",\"group\":\"CIS\",\"title\":\"\\u56fe\\u50cf\\u62fc\\u63a5\",\"desc\":\"\\u5c06CIS\\u91c7\\u96c6\\u7684\\u539f\\u59cb\\u6570\\u636e\\u6062\\u590d\\u4e3a\\u6b63\\u5e38\\u7684\\u56fe\\u50cf\",\"ver\":1,\"pos\":10,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"fb-split\":{\"cat\":\"cis\",\"group\":\"CIS\",\"title\":\"\\u62c6\\u5206\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u5c06\\u6b63\\u53cd\\u9762\\u5408\\u6210\\u7684\\u4e00\\u5f20\\u56fe\\u7247\\u62c6\\u5206\\u6210\\u6b63\\u9762\\u548c\\u53cd\\u9762\\u56fe\\u7247\",\"ver\":1,\"pos\":20,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":false,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true}}");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -195,7 +158,7 @@ int32_t cis_pre_do::set_config(const char* cfg_name, void* data, size_t* len, ui
return ret; return ret;
} }
void cis_pre_do::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool cis_pre_do::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
gb_json* root = new gb_json(); gb_json* root = new gb_json();
@ -206,6 +169,8 @@ void cis_pre_do::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt)
} }
root->release(); root->release();
return false;
} }
int32_t cis_pre_do::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t cis_pre_do::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {

View File

@ -10,6 +10,43 @@
class gb_json; class gb_json;
// {
// "montage": {
// "cat": "cis",
// "group": "CIS",
// "title": "图像拼接",
// "desc": "将CIS采集的原始数据恢复为正常的图像",
// "ver": 1,
// "pos": 10,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true
// },
// "fb-split": {
// "cat": "cis",
// "group": "CIS",
// "title": "拆分正反面",
// "desc": "将正反面合成的一张图片拆分成正面和反面图片",
// "ver": 1,
// "pos": 20,
// "type": "bool",
// "unit": "none",
// "affect": 0,
// "readonly": false,
// "visible": false,
// "enabled": true,
// "size": 4,
// "cur": true,
// "default": true
// }
// }
class cis_pre_do : public sane_cfg_provider class cis_pre_do : public sane_cfg_provider
{ {
std::string cfg_; std::string cfg_;
@ -32,7 +69,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -166,6 +166,8 @@ void img_processor::reload_cur_processors(void)
} }
std::sort(cur_proc_.begin(), cur_proc_.end(), img_processor::compare_img_processors_position); std::sort(cur_proc_.begin(), cur_proc_.end(), img_processor::compare_img_processors_position);
for(auto& v: all_proc_)
printf("image process %02d: %s\n", v->position(), v->option_name());
} }
uint32_t img_processor::add_busy_count(int adden) uint32_t img_processor::add_busy_count(int adden)
@ -315,16 +317,18 @@ int32_t img_processor::set_config(const char* cfg_name, void* data, size_t* len,
return ret; return ret;
} }
void img_processor::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool img_processor::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{ {
// sane_cfg_provider::update_option_enable_status(cfg_, get_opt); // sane_cfg_provider::update_option_enable_status(cfg_, get_opt);
cis_pre_->update_enabled(get_opt); bool changed = cis_pre_->update_enabled(name, get_opt);
for(auto& v: all_proc_) for(auto& v: all_proc_)
{ {
v->update_enabled(get_opt); changed |= v->update_enabled(name, get_opt);
} }
reload_cur_processors(); reload_cur_processors();
encoder_->update_enabled(get_opt); changed |= encoder_->update_enabled(name, get_opt);
return changed;
} }
int32_t img_processor::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t img_processor::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {

View File

@ -62,7 +62,7 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name = nullptr, std::string* strval = nullptr) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
public: public:

View File

@ -235,6 +235,13 @@ void async_scanner::init(void)
cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(r)); cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(r));
r->release(); r->release();
auto on_image_captured = [&](int data_type, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over) -> void
{
push_image(data_type, data, w, h, dpi_x, dpi_y, paper_ind, side, clr, status, img_new, img_over);
};
capture_ = new image_capture(on_image_captured);
cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(capture_));
auto send_img = [&](LPPACKIMAGE head, MemoryPtr img, const void* info, size_t info_size) -> void auto send_img = [&](LPPACKIMAGE head, MemoryPtr img, const void* info, size_t info_size) -> void
{ {
image_packet* imgp = nullptr; image_packet* imgp = nullptr;
@ -287,13 +294,6 @@ void async_scanner::init(void)
}; };
img_prc_ = new img_processor(send_img, get_opt); img_prc_ = new img_processor(send_img, get_opt);
cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(img_prc_)); cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(img_prc_));
auto on_image_captured = [&](int data_type, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over) -> void
{
push_image(data_type, data, w, h, dpi_x, dpi_y, paper_ind, side, clr, status, img_new, img_over);
};
capture_ = new image_capture(on_image_captured);
cfg_mgr_->reg_sane_provider(dynamic_cast<sane_cfg_provider*>(capture_));
} }
dyn_mem_ptr async_scanner::handle_simple_roger(LPPACK_BASE pack, uint32_t* used, packet_data_base_ptr* required) dyn_mem_ptr async_scanner::handle_simple_roger(LPPACK_BASE pack, uint32_t* used, packet_data_base_ptr* required)
@ -373,7 +373,7 @@ dyn_mem_ptr async_scanner::handle_set_opt(LPPACK_BASE pack, uint32_t* used, pack
{ {
LPCFGVAL cfg = (LPCFGVAL)pack->payload, LPCFGVAL cfg = (LPCFGVAL)pack->payload,
cfg_ret = nullptr; cfg_ret = nullptr;
std::string name(cfg->data + cfg->name_off), val0(sane_cfg_provider::to_readable_string(cfg->data + cfg->val_off, (data_type)cfg->type)), val1(""); std::string name(cfg->data + cfg->name_off);
size_t l = base_head_size + sizeof(CFGVAL) + name.length() + 1 + cfg->max_size + 1, val_size = cfg->val_size; size_t l = base_head_size + sizeof(CFGVAL) + name.length() + 1 + cfg->max_size + 1, val_size = cfg->val_size;
int32_t err = 0; int32_t err = 0;
uint32_t after = 0; uint32_t after = 0;
@ -388,17 +388,12 @@ dyn_mem_ptr async_scanner::handle_set_opt(LPPACK_BASE pack, uint32_t* used, pack
cfg_ret->val_size = cfg->val_size; cfg_ret->val_size = cfg->val_size;
cfg_ret->max_size = cfg->max_size; cfg_ret->max_size = cfg->max_size;
cfg_ret->type = cfg->type; cfg_ret->type = cfg->type;
err = cfg_mgr_->set_config(cfg->data + cfg->name_off, cfg_ret->data + cfg_ret->val_off, &val_size, &after); err = cfg_mgr_->set_config(cfg->data + cfg->name_off, cfg_ret->data + cfg_ret->val_off, &val_size, &after, (data_type)cfg->type);
cfg_ret->after_do = after; cfg_ret->after_do = after;
cfg_ret->val_size = val_size; cfg_ret->val_size = val_size;
BASE_PACKET_REPLY(*pk, pack->cmd + 1, pack->pack_id, err); BASE_PACKET_REPLY(*pk, pack->cmd + 1, pack->pack_id, err);
pk->payload_len = sizeof(CFGVAL) + name.length() + 1 + cfg->max_size + 1; pk->payload_len = sizeof(CFGVAL) + name.length() + 1 + cfg->max_size + 1;
reply->set_len(l); reply->set_len(l);
val1 = sane_cfg_provider::to_readable_string(cfg_ret->data + cfg_ret->val_off, (data_type)cfg->type);
if(val0 == val1)
log_cls::log(LOG_LEVEL_DEBUG, "Set '%s' value to '%s'\n", name.c_str(), val0.c_str());
else
log_cls::log(LOG_LEVEL_DEBUG, "Set '%s' value to '%s', but applied '%s'\n", name.c_str(), val0.c_str(), val1.c_str());
} }
return reply; return reply;
@ -502,21 +497,6 @@ dyn_mem_ptr async_scanner::handle_scan_start(LPPACK_BASE pack, uint32_t* used, p
scan_err_ = 0; scan_err_ = 0;
reply_start_ = false; reply_start_ = false;
// {
// reg_image_callback();
// ctrl_handler(-1, (usb_ctrlrequest*)SR_IM_CLEAR, (unsigned char*)0);
// log_cls::log(LOG_LEVEL_ALL, "Memory usage before starting to scan: %s\n", sys_util::format_readable_bytes(sys_util::get_memory_usage("scan")).c_str());
// bool ret = ctrl_handler(-1, (usb_ctrlrequest*)15, (unsigned char*)0x160); // hardware configuration
//
// ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_CNT, (unsigned char*)scan_cnt_);
// ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_DPI, (unsigned char*)dpi_);
// ctrl_handler(-1, (usb_ctrlrequest*)SR_CONFIF_IMGPROCPARAM, (unsigned char*)0);
// log_cls::log(LOG_LEVEL_ALL, "Start scanning %d papers and %d DPI ...\n", scan_cnt_, dpi_);
// ret = ctrl_handler(-1, nullptr, nullptr);
// log_cls::log(LOG_LEVEL_ALL, "Start scanning %s\n", ret ? "OK" : "Failed");
// log_cls::log(LOG_LEVEL_ALL, "Memory usage after scanning started: %s\n", sys_util::format_readable_bytes(sys_util::get_memory_usage("scan")).c_str());
// }
*used = base_head_size; *used = base_head_size;
reply->set_len(base_head_size); reply->set_len(base_head_size);
log_cls::log_memory_usage("before starting to scan"); log_cls::log_memory_usage("before starting to scan");

View File

@ -6,7 +6,7 @@
#include <string> #include <string>
static std::string readonly_json = static std::string readonly_json =
"{\"dev-sn\":{\"category\":\"base\",\"readonly\":true,\"affect\":0,\"group\":\"\\u8BBE\\u5907\\u5C5E\\u6027\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8bbe\\u5907\\u5e8f\\u5217\\u53f7\",\"desc\":\"\\u8bbe\\u5907\\u552f\\u4e00\\u7f16\\u7801\",\"type\":\"string\",\"cur\":\"G100S20230001\",\"size\":20,\"ver\":1},\"fmw-ver\":{\"category\":\"base\",\"readonly\":true,\"affect\":0,\"group\":\"\\u8BBE\\u5907\\u5C5E\\u6027\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u56fa\\u4ef6\\u7248\\u672c\\u53f7\",\"desc\":\"\\u8bbe\\u5907\\u9a71\\u52a8\\u7248\\u672c\\u53f7\",\"type\":\"string\",\"cur\":\"FMWV1001\",\"size\":10,\"ver\":1},\"ip-addr\":{\"category\":\"base\",\"readonly\":true,\"affect\":0,\"group\":\"\\u8BBE\\u5907\\u5C5E\\u6027\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8bbe\\u5907IP\\u5730\\u5740\",\"desc\":\"\\u5f53\\u8bbe\\u5907\\u8fde\\u63a5\\u7f51\\u7edc\\u65f6\\u5206\\u914d\\u7684IP\\u5730\\u5740\",\"type\":\"string\",\"cur\":\"0.0.0.0\",\"size\":60,\"ver\":1},\"mac-addr\":{\"category\":\"base\",\"readonly\":true,\"affect\":0,\"group\":\"\\u8BBE\\u5907\\u5C5E\\u6027\",\"visible\":true,\"field\":\"Common\",\"pos\":0,\"unit\":\"None\",\"title\":\"\\u8bbe\\u5907MAC\\u5730\\u5740\",\"desc\":\"\\u8bbe\\u5907MAC\\u5730\\u5740\",\"type\":\"string\",\"cur\":\"00:11:22:33:44:55\",\"size\":30,\"ver\":1}}"; "{\"dev-sn\":{\"cat\":\"Common\",\"group\":\"\\u8bbe\\u5907\\u5c5e\\u6027\",\"title\":\"\\u8bbe\\u5907\\u5e8f\\u5217\\u53f7\",\"desc\":\"\\u8bbe\\u5907\\u552f\\u4e00\\u7f16\\u7801\",\"ver\":1,\"pos\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":true,\"visible\":true,\"enabled\":true,\"size\":96,\"cur\":\"G100S20230001\",\"default\":\"G100S20230001\"},\"fmw-ver\":{\"cat\":\"Common\",\"group\":\"\\u8bbe\\u5907\\u5c5e\\u6027\",\"title\":\"\\u56fa\\u4ef6\\u7248\\u672c\\u53f7\",\"desc\":\"\\u8bbe\\u5907\\u9a71\\u52a8\\u7248\\u672c\\u53f7\",\"ver\":1,\"pos\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":true,\"visible\":true,\"enabled\":true,\"size\":66,\"cur\":\"FMWV1001\",\"default\":\"FMWV1001\"},\"ip-addr\":{\"cat\":\"Common\",\"group\":\"\\u8bbe\\u5907\\u5c5e\\u6027\",\"title\":\"\\u8bbe\\u5907IP\\u5730\\u5740\",\"desc\":\"\\u5f53\\u8bbe\\u5907\\u8fde\\u63a5\\u7f51\\u7edc\\u65f6\\u5206\\u914d\\u7684IP\\u5730\\u5740\",\"ver\":1,\"pos\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":true,\"visible\":true,\"enabled\":true,\"size\":60,\"cur\":\"0.0.0.0\",\"default\":\"0.0.0.0\"},\"mac-addr\":{\"cat\":\"Common\",\"group\":\"\\u8bbe\\u5907\\u5c5e\\u6027\",\"title\":\"\\u8bbe\\u5907MAC\\u5730\\u5740\",\"desc\":\"\\u8bbe\\u5907MAC\\u5730\\u5740\",\"ver\":1,\"pos\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":true,\"visible\":true,\"enabled\":true,\"size\":120,\"cur\":\"00:11:22:33:44:55\",\"default\":\"00:11:22:33:44:55\"}}";
// C2-B0-AF-79-75-D6 // C2-B0-AF-79-75-D6
// //
@ -96,8 +96,10 @@ int32_t readonly_cfg::set_config(const char* cfg_name, void* data, size_t* len,
// read-only attributes not support this operation !!! // read-only attributes not support this operation !!!
return EINVAL; return EINVAL;
} }
void readonly_cfg::update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) bool readonly_cfg::update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt)
{} {
return false;
}
int32_t readonly_cfg::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type) int32_t readonly_cfg::get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type)
{ {
int32_t ret = ENOENT; int32_t ret = ENOENT;

View File

@ -9,6 +9,76 @@
class gb_json; class gb_json;
// C2-B0-AF-79-75-D6 // C2-B0-AF-79-75-D6
// {
// "dev-sn": {
// "cat": "Common",
// "group": "设备属性",
// "title": "设备序列号",
// "desc": "设备唯一编码",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": true,
// "visible": true,
// "enabled": true,
// "size": 96,
// "cur": "G100S20230001",
// "default": "G100S20230001"
// },
// "fmw-ver": {
// "cat": "Common",
// "group": "设备属性",
// "title": "固件版本号",
// "desc": "设备驱动版本号",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": true,
// "visible": true,
// "enabled": true,
// "size": 66,
// "cur": "FMWV1001",
// "default": "FMWV1001"
// },
// "ip-addr": {
// "cat": "Common",
// "group": "设备属性",
// "title": "设备IP地址",
// "desc": "当设备连接网络时分配的IP地址",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": true,
// "visible": true,
// "enabled": true,
// "size": 60,
// "cur": "0.0.0.0",
// "default": "0.0.0.0"
// },
// "mac-addr": {
// "cat": "Common",
// "group": "设备属性",
// "title": "设备MAC地址",
// "desc": "设备MAC地址",
// "ver": 1,
// "pos": 0,
// "type": "string",
// "unit": "none",
// "affect": 0,
// "readonly": true,
// "visible": true,
// "enabled": true,
// "size": 120,
// "cur": "00:11:22:33:44:55",
// "default": "00:11:22:33:44:55"
// }
// }
class readonly_cfg : public sane_cfg_provider class readonly_cfg : public sane_cfg_provider
{ {
@ -26,6 +96,6 @@ protected:
public: public:
virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval) override; virtual int32_t get_config(void* buf, size_t* len, const char* cfg_name, std::string* strval) override;
virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override; virtual int32_t set_config(const char* cfg_name, void* data, size_t* len, uint32_t* afterdo) override;
virtual void update_enabled(std::function<GET_SANE_OPT_PROTO> get_opt) override; virtual bool update_enabled(const char* name, std::function<GET_SANE_OPT_PROTO> get_opt) override;
virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override; virtual int32_t get_raw_value(const char* name, const char* key, std::string& val, uint32_t* type = nullptr) override;
}; };

View File

@ -18,12 +18,13 @@
#include "scanner/async_scanner.h" #include "scanner/async_scanner.h"
#ifdef TEMPORARY_API #ifdef TEMPORARY_API
int32_t (*scan_start)(void) = nullptr; int32_t (*scan_start)(int) = nullptr;
int32_t (*scan_stop)(void) = nullptr; int32_t (*scan_stop)(void) = nullptr;
int32_t (*set_dpi)(int*, int*) = nullptr; int32_t (*set_dpi)(int*, int*) = nullptr;
int32_t (*set_scan_num)(int) = nullptr; int32_t (*set_scan_num)(int) = nullptr;
int32_t (*set_paper_type)(int) = nullptr; int32_t (*set_paper_type)(int) = nullptr;
int32_t (*set_pixel_type)(int*) = nullptr; int32_t (*set_pixel_type)(int*) = nullptr;
int32_t (*set_capturer_param)(int, int, int) = nullptr;
int32_t (*set_image_receiver)(void(*rcv)(int data_type, void* data, size_t w, size_t h, int, int, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over, void* param), void* param) = nullptr; int32_t (*set_image_receiver)(void(*rcv)(int data_type, void* data, size_t w, size_t h, int, int, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over, void* param), void* param) = nullptr;
#endif #endif
@ -77,9 +78,9 @@ static std::shared_ptr<std::thread> int_sent_;
const int UsbDevice::cacheSize = 64*1024; const int UsbDevice::cacheSize = 64*1024;
#ifdef TEMPORARY_API #ifdef TEMPORARY_API
static UsbDevice* inst = nullptr; static UsbDevice* inst = nullptr;
int32_t call_start_scan(void) int32_t call_start_scan(int devcfg)
{ {
return inst->start_scan(); return inst->start_scan(devcfg);
} }
int32_t call_stop_scan(void) int32_t call_stop_scan(void)
{ {
@ -101,6 +102,10 @@ int32_t call_set_pixel_type(int *type)
{ {
return inst->set_pixel_type(type); return inst->set_pixel_type(type);
} }
int32_t call_set_capturer_param(int type, int ind, int val)
{
return inst->set_capturer_parameter(type, ind, val);
}
int32_t call_set_image_receiver(void(*rcv)(int data_type, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over, void* param), void* param) int32_t call_set_image_receiver(void(*rcv)(int data_type, void* data, size_t w, size_t h, int dpi_x, int dpi_y, size_t paper_ind, paper_side side, clr_channel clr, img_status status, bool img_new, bool img_over, void* param), void* param)
{ {
return inst->set_img_receiver((void*)rcv, param); return inst->set_img_receiver((void*)rcv, param);
@ -376,6 +381,7 @@ UsbDevice::UsbDevice(std::function<bool(int, struct usb_ctrlrequest *, unsigned
::set_image_receiver = call_set_image_receiver; ::set_image_receiver = call_set_image_receiver;
::set_paper_type = call_set_paper_type; ::set_paper_type = call_set_paper_type;
::set_pixel_type = call_set_pixel_type; ::set_pixel_type = call_set_pixel_type;
::set_capturer_param = call_set_capturer_param;
thread_pool<UsbDevice> *t = new thread_pool<UsbDevice>(this); thread_pool<UsbDevice> *t = new thread_pool<UsbDevice>(this);
t->thread_new(&UsbDevice::do_system_command, R"(echo linaro | sudo -S sh -c "echo fe900000.dwc3 > /opt/cfg/usb_gadget/g1/UDC")"); t->thread_new(&UsbDevice::do_system_command, R"(echo linaro | sudo -S sh -c "echo fe900000.dwc3 > /opt/cfg/usb_gadget/g1/UDC")");
@ -1402,9 +1408,10 @@ void UsbDevice::do_system_command(const char* cmd)
} }
#include "commondef.h" #include "commondef.h"
int UsbDevice::start_scan(void) int UsbDevice::start_scan(int devcfg)
{ {
ctrl_handler(-1, (usb_ctrlrequest*)SR_IM_CLEAR, (unsigned char*)0); ctrl_handler(-1, (usb_ctrlrequest*)SR_IM_CLEAR, (unsigned char*)0);
ctrl_handler(-1, (usb_ctrlrequest*)SR_CONFIG_SCAN_PARAM, (unsigned char*)devcfg);
ctrl_handler(-1, (usb_ctrlrequest*)SR_CONFIF_IMGPROCPARAM, (unsigned char*)0); ctrl_handler(-1, (usb_ctrlrequest*)SR_CONFIF_IMGPROCPARAM, (unsigned char*)0);
return ctrl_handler(-1, nullptr, nullptr) ? 0 : EBADF; return ctrl_handler(-1, nullptr, nullptr) ? 0 : EBADF;
@ -1441,7 +1448,7 @@ int UsbDevice::set_dpi(int *dpix, int* dpiy)
} }
if(dpi == 0) if(dpi == 0)
dpi = 200; dpi = 200;
return ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_DPI, (unsigned char*)dpi) ? 0 : EBADF; return ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_DPI, (unsigned char*)dpi) ? 0 : EBADF;
} }
int UsbDevice::set_scan_num(int num) int UsbDevice::set_scan_num(int num)
@ -1462,4 +1469,12 @@ int UsbDevice::set_pixel_type(int *type)
{ {
return ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_PIXEL, (unsigned char*)*type) ? 0 : EBADF; return ctrl_handler(-1, (usb_ctrlrequest*)SR_SCAN_PIXEL, (unsigned char*)*type) ? 0 : EBADF;
} }
int UsbDevice::set_capturer_parameter(int type, int ind, int val)
{
ind &= 0x0ff;
ind |= type & 0x0f0;
ind |= SR_CAPTURE_SET;
return ctrl_handler(-1, (usb_ctrlrequest*)ind, (unsigned char*)val) ? 0 : EBADF;
}
#endif #endif

View File

@ -90,7 +90,7 @@ UsbService::UsbService(std::shared_ptr<IRegsAccess> fgparegs, std::shared_ptr<IR
} }
else else
{ {
printf("setup = %p\n", setup); printf("devregs = %p, setup = %p, buffer = %p\n", devregs, setup, buffer);
devregs->write(/*SR_CMD*/(unsigned int)(uint64_t)setup, /*SC_START*/(unsigned int)(uint64_t)buffer); devregs->write(/*SR_CMD*/(unsigned int)(uint64_t)setup, /*SC_START*/(unsigned int)(uint64_t)buffer);
} }
return true; return true;