新增配置开启cpu高级指令集 新增配置设置内存检测
This commit is contained in:
parent
ca7cc065cf
commit
2575551b37
|
@ -19,6 +19,7 @@ add_definitions(-Dx86_64="x86_64")
|
|||
|
||||
message("cpu is x86_64")
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
add_definitions(-Dxaarch64="aarch64")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libittnotify.a
|
||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libtegra_hal.a #uos 不需要 kylin需要
|
||||
|
@ -28,12 +29,14 @@ elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
|||
)
|
||||
message("cpu is arm64")
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64")
|
||||
add_definitions(-Dmips64="mips64")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
#message("静态库预留03")
|
||||
#message("静态库预留04")
|
||||
)
|
||||
message("cpu is mips64")
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
#message("静态库预留03")
|
||||
#message("静态库预留04")
|
||||
|
|
|
@ -99,10 +99,13 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
|||
, async_io_(false), is_white_0_(true), isremove_left_hole(false), isremove_right_hole(false), isremove_top_hole(false), isremove_low_hole(false)
|
||||
, isremove_left_hole_threshold(0), isremove_right_hole_threshold(0), isremove_top_hole_threshold(0), isremove_low_hole_threshold(0)
|
||||
, dump_usb_path_(""),is_kernelsnap_211209_(false), pid_(0), dump_img_(&hg_scanner::dump_image_empty), is_kernelsnap_220830_(false),is_kernelsnap3288_221106_(false)
|
||||
, is_kernelsnap_221027_(false)
|
||||
, is_kernelsnap_221027_(false), memory_size_(1024), isx86_closeAdvan_(true)
|
||||
{
|
||||
#if !defined(_WIN32) && !defined(_WIN64) &&defined(X86)
|
||||
isx86_closeAdvan_ = fasle;
|
||||
#endif
|
||||
init_setting_func_map();
|
||||
final_path_ = hg_log::ini_get("paths", "final_img");
|
||||
final_path_ = hg_log::ini_get("path", "final_img");
|
||||
if(final_path_.empty())
|
||||
final_path_ = hg_log::local_data_path() + PATH_SEPARATOR + "imgs";
|
||||
if (hg_log::ini_get("dump", "dumpusb") == "1")
|
||||
|
@ -113,6 +116,18 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
|||
if (!dump_usb_path_.empty())
|
||||
dump_img_ = &hg_scanner::dump_image_real;
|
||||
}
|
||||
|
||||
std::string mem = dump_usb_path_ = hg_log::ini_get("mem", "max_img");
|
||||
if (!mem.empty())
|
||||
{
|
||||
memory_size_ = std::stoi(mem);
|
||||
}
|
||||
std::string adv = dump_usb_path_ = hg_log::ini_get("cpu", "advanced");
|
||||
if (!adv.empty())
|
||||
{
|
||||
isx86_closeAdvan_ = adv == "0" ? false : true;
|
||||
}
|
||||
|
||||
if (hg_log::create_folder(final_path_.c_str()))
|
||||
{
|
||||
VLOG_MINI_1(LOG_LEVEL_WARNING, "temporary image folder: %s\n", final_path_.c_str());
|
||||
|
@ -148,7 +163,7 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
|||
wait_usb_result_.set_debug_info("start");
|
||||
thread_usb_read_.reset(new std::thread(&hg_scanner::thread_handle_usb, this));
|
||||
thread_img_handle_.reset(new std::thread(&hg_scanner::thread_image_handle, this));
|
||||
ImagePrc_pHandle_ = hg_imgproc::init(pid_);;
|
||||
ImagePrc_pHandle_ = hg_imgproc::init(pid_, isx86_closeAdvan_);;
|
||||
}
|
||||
hg_scanner::~hg_scanner()
|
||||
{
|
||||
|
@ -2081,8 +2096,8 @@ hg_imgproc::IMGPRCPARAM hg_scanner::get_image_process_object(int model)
|
|||
//image_prc_param_.bits.color_mode == COLOR_MODE_256_GRAY || image_prc_param_.bits.color_mode == COLOR_MODE_BLACK_WHITE
|
||||
|
||||
param.black_white = image_prc_param_.bits.color_mode == COLOR_MODE_BLACK_WHITE;
|
||||
param.channels = image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS ? 3 : 1;
|
||||
param.color_mode = image_prc_param_.bits.color_mode;
|
||||
param.channels = (image_prc_param_.bits.color_mode == COLOR_MODE_24_BITS || image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH) ? 3 : 1;
|
||||
param.color_mode = image_prc_param_.bits.color_mode == COLOR_MODE_AUTO_MATCH ? 2 : image_prc_param_.bits.color_mode;
|
||||
param.double_side = img_conf_.is_duplex;
|
||||
param.dpi = img_conf_.resolution_dst;
|
||||
|
||||
|
@ -2336,6 +2351,7 @@ void hg_scanner::copy_to_sane_image_header(SANE_Parameters* header, int w, int h
|
|||
int hg_scanner::save_usb_data(std::shared_ptr<tiny_buffer> data)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
float Memoryusae = hg_log::GetAppMemoryUsage();;
|
||||
unsigned int bytes = data->size();
|
||||
|
||||
usb_img_index_++;
|
||||
|
@ -2368,6 +2384,11 @@ int hg_scanner::save_usb_data(std::shared_ptr<tiny_buffer> data)
|
|||
}
|
||||
else
|
||||
{
|
||||
while (Memoryusae > memory_size_)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
Memoryusae = hg_log::GetAppMemoryUsage();
|
||||
}
|
||||
imgs_.Put(data);
|
||||
if (wait_img_.is_waiting())
|
||||
wait_img_.notify();
|
||||
|
|
|
@ -291,6 +291,8 @@ protected:
|
|||
unsigned int usb_img_index_;
|
||||
unsigned int final_img_index_;
|
||||
std::string final_path_;
|
||||
unsigned int memory_size_;
|
||||
bool isx86_closeAdvan_;
|
||||
BlockingQueue<std::shared_ptr<tiny_buffer>> imgs_;
|
||||
|
||||
void init_settings(const char* json_setting_text);
|
||||
|
|
|
@ -232,20 +232,18 @@ std::string hg_scanner_239::get_fpga(void)
|
|||
return fpga;
|
||||
}
|
||||
|
||||
int hg_scanner_239::get_scan_mode(void)
|
||||
int hg_scanner_239::get_scan_mode(int &v)
|
||||
{
|
||||
int val = 0,
|
||||
ret = read_register(setting3399::SR_OS, &val);
|
||||
v = val;
|
||||
|
||||
if (ret)
|
||||
if (val == 1)
|
||||
{
|
||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get scan mode error: %s\n", hg_scanner_err_name(ret));
|
||||
status_ = ret;
|
||||
|
||||
return -1;
|
||||
return SCANNER_ERR_DEVICE_COUNT_MODE;
|
||||
}
|
||||
else
|
||||
return val;
|
||||
return ret;
|
||||
}
|
||||
int hg_scanner_239::get_status(void)
|
||||
{
|
||||
|
@ -262,7 +260,6 @@ int hg_scanner_239::get_status(void)
|
|||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
bool hg_scanner_239::is_dev_image_process_done(void)
|
||||
{
|
||||
int val = 0,
|
||||
|
@ -294,7 +291,6 @@ bool hg_scanner_239::is_dev_image_keep_last_paper(void)
|
|||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
int hg_scanner_239::get_image_count(void)
|
||||
{
|
||||
int val = 0,
|
||||
|
@ -342,7 +338,6 @@ void hg_scanner_239::init_version(void)
|
|||
else
|
||||
is_kernelsnap_221027_ = false;
|
||||
}
|
||||
|
||||
int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware::HGSCANCONF_3399* dev_conf)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
|
@ -378,7 +373,6 @@ int hg_scanner_239::writedown_device_configuration(bool type, setting_hardware::
|
|||
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "Writedown scanner configuration(0x%x) = %s\n", dev_conf->value, hg_scanner_err_name(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hg_scanner_239::writedown_image_configuration(void)
|
||||
{
|
||||
int ret = write_register(setting3399::SR_CONFIF_IMGPROCPARAM, sizeof(SCANCONF));
|
||||
|
@ -706,7 +700,6 @@ int hg_scanner_239::writedown_image_configuration(void)
|
|||
img_conf_ = ic;*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hg_scanner_239::pop_first_image(void)
|
||||
{
|
||||
int ret = write_register(setting3399::SR_IM_POP, 1);
|
||||
|
@ -715,7 +708,6 @@ int hg_scanner_239::pop_first_image(void)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hg_scanner_239::read_one_image_from_usb(SANE_Image_Statu statu)
|
||||
{
|
||||
int r = 0,
|
||||
|
@ -843,7 +835,6 @@ void hg_scanner_239::discard_all_images(void)
|
|||
if (pre_int)
|
||||
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img);
|
||||
}
|
||||
|
||||
//color_mode =-1 除色选项
|
||||
int hg_scanner_239::on_color_mode_changed(int& color_mode)
|
||||
{
|
||||
|
@ -921,7 +912,6 @@ int hg_scanner_239::on_resolution_changed(int& dpi)
|
|||
int ret = writedown_device_configuration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hg_scanner_239::on_ultrasonic_check_changed(bool& check)
|
||||
{
|
||||
int ret = SCANNER_ERR_OK;
|
||||
|
@ -1007,7 +997,6 @@ int hg_scanner_239::on_skew_check_level_changed(int& check)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hg_scanner_239::on_get_feedmode(int &feedmode)//获取分纸强度
|
||||
{
|
||||
int ret = SCANNER_ERR_OK,
|
||||
|
@ -1093,7 +1082,6 @@ int hg_scanner_239::on_scanner_closing(bool force)
|
|||
{
|
||||
return SCANNER_ERR_OK;
|
||||
}
|
||||
|
||||
void hg_scanner_239::thread_handle_usb_read(void)
|
||||
{
|
||||
char buf[64];
|
||||
|
@ -1323,9 +1311,10 @@ int hg_scanner_239::start(void)
|
|||
notify_ui_working_status(STATU_DESC_PREPARE_START);
|
||||
|
||||
reset();
|
||||
ret = get_roller_num(val);
|
||||
ret = get_scan_is_sleep(val);//211220固件版本不支持返回
|
||||
if (ret == SCANNER_ERR_DEVICE_SLEEPING)
|
||||
//ret = get_roller_num(val);
|
||||
|
||||
//211220固件版本不支持返回
|
||||
if ((ret = get_scan_is_sleep(val)) == SCANNER_ERR_DEVICE_SLEEPING)
|
||||
{
|
||||
status_ = ret;;
|
||||
VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING);
|
||||
|
@ -1334,18 +1323,15 @@ int hg_scanner_239::start(void)
|
|||
notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NOTIFY_SLEEP, SANE_EVENT_ERROR, status_);
|
||||
return status_;
|
||||
}
|
||||
|
||||
ret = get_scan_mode();
|
||||
if (status_ == SCANNER_ERR_DEVICE_NOT_FOUND)
|
||||
return status_;
|
||||
|
||||
if (ret == -1)
|
||||
return status_;
|
||||
if (ret & 1)
|
||||
else if ((ret = get_scan_mode(val)) == SCANNER_ERR_DEVICE_COUNT_MODE)
|
||||
{
|
||||
status_ = SCANNER_ERR_DEVICE_COUNT_MODE;
|
||||
|
||||
return status_;
|
||||
status_ = ret;
|
||||
return ret;
|
||||
}
|
||||
else if ((ret = get_scan_islock(val)) == SCANNER_ERR_DEVICE_ISLOCK)
|
||||
{
|
||||
status_ = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
notify_ui_working_status(STATU_DESC_REWRITE_CONFIGURATION);
|
||||
|
@ -1353,7 +1339,6 @@ int hg_scanner_239::start(void)
|
|||
{
|
||||
ret = writedown_device_configuration(true);
|
||||
}
|
||||
|
||||
if(ret == SCANNER_ERR_OK)
|
||||
{
|
||||
ret = writedown_image_configuration();
|
||||
|
@ -1459,9 +1444,6 @@ int hg_scanner_239::clear_roller_num(void)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int hg_scanner_239::set_leaflet_scan(void)
|
||||
|
|
|
@ -30,7 +30,7 @@ class hg_scanner_239 : public hg_scanner
|
|||
|
||||
std::string control_fetch(int addr, int val, int size);
|
||||
std::string get_fpga(void);
|
||||
int get_scan_mode(void);
|
||||
int get_scan_mode(int &v);
|
||||
int get_status(void);
|
||||
int get_image_count(void);
|
||||
int get_front_data_size(void);
|
||||
|
|
|
@ -229,6 +229,7 @@ namespace hg_imgproc
|
|||
typedef unsigned int (__stdcall *SDKHGBase_FreeImage_)(void* image);
|
||||
class imgproc
|
||||
{
|
||||
bool isx86_closeAdvan_ = true;
|
||||
std::string my_path_;
|
||||
IMGPRCPARAM param_;
|
||||
SCANCONF img_conf_;
|
||||
|
@ -275,15 +276,16 @@ namespace hg_imgproc
|
|||
}
|
||||
// construction
|
||||
public:
|
||||
imgproc(int pid) : pid_(pid),papersize_(pid_)
|
||||
imgproc(int pid, bool isx86_Advan_) : pid_(pid),papersize_(pid_)
|
||||
, img_statu_(SANE_Image_Statu_OK)
|
||||
, my_path_(hg_log::pe_path())
|
||||
,ocrinit_(NULL),ocrgetdirectimage_(NULL)
|
||||
,ocrexit_(NULL),HGBase_CreatImg(NULL)
|
||||
,HGBase_FreeImg(NULL),Auto_Txt_pHanld(NULL)
|
||||
,Dynamicopen_HGBase_pHandle_(NULL)
|
||||
,Dynamicopen_HGImageprc_pHandle_(NULL)
|
||||
,Dynamicopen_HGImageprc_pHandle_(NULL),isx86_closeAdvan_(isx86_Advan_)
|
||||
{
|
||||
cv::setUseOptimized(isx86_closeAdvan_); //开关cpu高级指令集
|
||||
}
|
||||
~imgproc()
|
||||
{
|
||||
|
@ -1556,9 +1558,9 @@ namespace hg_imgproc
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// api ...
|
||||
HIMGPRC init(int pid)
|
||||
HIMGPRC init(int pid,bool isx86_Advan_)
|
||||
{
|
||||
imgproc* obj = new imgproc(pid);
|
||||
imgproc* obj = new imgproc(pid, isx86_Advan_);
|
||||
|
||||
return (HIMGPRC)obj;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace hg_imgproc
|
|||
}IMGHEAD, *LPIMGHEAD;
|
||||
|
||||
|
||||
HIMGPRC init(int pid);
|
||||
HIMGPRC init(int pid, bool isx86Advan_);
|
||||
int load_buffer(HIMGPRC himg,std::shared_ptr<tiny_buffer> buff);
|
||||
int load_file(HIMGPRC himg, const char* path_file);
|
||||
|
||||
|
|
|
@ -681,6 +681,48 @@ extern "C"
|
|||
{
|
||||
log_cls::instance()->log(info);
|
||||
}
|
||||
|
||||
float GetMemoryUsage(int pid)
|
||||
{
|
||||
#ifdef WIN32
|
||||
uint64_t mem = 0, vmem = 0;
|
||||
PROCESS_MEMORY_COUNTERS pmc;
|
||||
|
||||
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
||||
if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc)))
|
||||
{
|
||||
mem = pmc.WorkingSetSize;
|
||||
vmem = pmc.PagefileUsage;
|
||||
}
|
||||
CloseHandle(process);
|
||||
|
||||
return mem / 1024.0 / 1024.0;//KB TO MB
|
||||
|
||||
#else
|
||||
char file_name[64] = { 0 };
|
||||
FILE* fd;
|
||||
char line_buff[512] = { 0 };
|
||||
sprintf(file_name, "/proc/%d/status", pid);
|
||||
|
||||
fd = fopen(file_name, "r");
|
||||
if (nullptr == fd)
|
||||
return 0;
|
||||
|
||||
char name[64];
|
||||
int vmrss = 0;
|
||||
for (int i = 0; i < VMRSS_LINE - 1; i++)
|
||||
fgets(line_buff, sizeof(line_buff), fd);
|
||||
|
||||
fgets(line_buff, sizeof(line_buff), fd);
|
||||
sscanf(line_buff, "%s %d", name, &vmrss);
|
||||
fclose(fd);
|
||||
return vmrss / 1024.0;//KB TO MB
|
||||
#endif
|
||||
}
|
||||
float GetAppMemoryUsage()
|
||||
{
|
||||
return GetMemoryUsage(getpid());
|
||||
}
|
||||
}
|
||||
#ifdef EXPORT_AS_C
|
||||
}
|
||||
|
@ -692,3 +734,4 @@ void hg_debug_log(int level, const char* info)
|
|||
hg_log::log(level, info);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ extern "C"
|
|||
std::string local_data_path(void);
|
||||
std::string temporary_path(void);
|
||||
std::string log_file_path(void);
|
||||
float GetMemoryUsage(int pid);
|
||||
float GetAppMemoryUsage();
|
||||
unsigned int get_page_size(unsigned int* map_unit = nullptr);
|
||||
unsigned long long available_memory(void);
|
||||
void str_tolower(std::string& str);
|
||||
|
|
Loading…
Reference in New Issue