调整设备显示名称;应用新的灰度转黑白图像算法(位序还需要调整)
This commit is contained in:
parent
339474b6d1
commit
8ce837c8ca
|
@ -117,32 +117,42 @@
|
|||
|
||||
// 设备名称
|
||||
// #define SCANNER_NAME_HG_G100 "华高扫描仪—G100"
|
||||
#define SCANNER_NAME_HG_G100 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G100"
|
||||
// #define SCANNER_NAME_HG_G100 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G100"
|
||||
// #define SCANNER_NAME_HG_G200 "华高扫描仪—G200"
|
||||
#define SCANNER_NAME_HG_G200 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G200"
|
||||
// #define SCANNER_NAME_HG_G200 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G200"
|
||||
// #define SCANNER_NAME_HG_G300 "华高扫描仪—G300"
|
||||
#define SCANNER_NAME_HG_G300 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G300"
|
||||
// #define SCANNER_NAME_HG_G300 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G300"
|
||||
// #define SCANNER_NAME_HG_G400 "华高扫描仪—G400"
|
||||
#define SCANNER_NAME_HG_G400 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G400"
|
||||
// #define SCANNER_NAME_HG_G400 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G400"
|
||||
// #define SCANNER_NAME_HG_G139 "华高扫描仪—G139"
|
||||
#define SCANNER_NAME_HG_G139 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G139"
|
||||
// #define SCANNER_NAME_HG_G139 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G139"
|
||||
// #define SCANNER_NAME_HG_G239 "华高扫描仪—G239"
|
||||
#define SCANNER_NAME_HG_G239 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G239"
|
||||
// #define SCANNER_NAME_HG_G239 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G239"
|
||||
// #define SCANNER_NAME_HG_G339 "华高扫描仪—G339"
|
||||
#define SCANNER_NAME_HG_G339 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G339"
|
||||
// #define SCANNER_NAME_HG_G339 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G339"
|
||||
// #define SCANNER_NAME_HG_G439 "华高扫描仪—G439"
|
||||
#define SCANNER_NAME_HG_G439 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G439"
|
||||
// #define SCANNER_NAME_HG_G439 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G439"
|
||||
// #define SCANNER_NAME_HG_G402 "华高扫描仪—G402"
|
||||
#define SCANNER_NAME_HG_G402 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G402"
|
||||
// #define SCANNER_NAME_HG_G402 "\345\215\216\351\253\230\346\211\253\346\217\217\344\273\252\342\200\224G402"
|
||||
|
||||
#define SCANNER_NAME_HG_G100 "HUAGOSCAN G100"
|
||||
#define SCANNER_NAME_HG_G200 "HUAGOSCAN G200"
|
||||
#define SCANNER_NAME_HG_G300 "HUAGOSCAN G300"
|
||||
#define SCANNER_NAME_HG_G400 "HUAGOSCAN G400"
|
||||
|
||||
// #define SCANNER_NAME_LSC_G42S "立思辰扫描仪—G42S"
|
||||
#define SCANNER_NAME_LSC_G42S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G42S"
|
||||
// #define SCANNER_NAME_LSC_G42S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G42S"
|
||||
// #define SCANNER_NAME_LSC_G52S "立思辰扫描仪—G52S"
|
||||
#define SCANNER_NAME_LSC_G52S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G52S"
|
||||
// #define SCANNER_NAME_LSC_G52S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G52S"
|
||||
// #define SCANNER_NAME_LSC_G62S "立思辰扫描仪—G62S"
|
||||
#define SCANNER_NAME_LSC_G62S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G62S"
|
||||
// #define SCANNER_NAME_LSC_G62S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G62S"
|
||||
// #define SCANNER_NAME_LSC_G73S "立思辰扫描仪—G73S"
|
||||
#define SCANNER_NAME_LSC_G73S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G73S"
|
||||
// #define SCANNER_NAME_LSC_G73S "\347\253\213\346\200\235\350\276\260\346\211\253\346\217\217\344\273\252\342\200\224G73S"
|
||||
|
||||
#define SCANNER_NAME_LSC_G42S "LANXUMSCAN G42S"
|
||||
#define SCANNER_NAME_LSC_G52S "LANXUMSCAN G52S"
|
||||
#define SCANNER_NAME_LSC_G62S "LANXUMSCAN G62S"
|
||||
#define SCANNER_NAME_LSC_G73S "LANXUMSCAN G73S"
|
||||
|
||||
// #define SCANNER_NAME_HW_7000 "汉王扫描仪—HW7000"
|
||||
// #define SCANNER_NAME_HW_7000 "\346\261\211\347\216\213\346\211\253\346\217\217\344\273\252\342\200\224HW7000"
|
||||
|
|
|
@ -14,7 +14,7 @@ static int ui_default_callback(scanner_handle, int, void*, unsigned int*, void*)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
static std::string bmp_821(unsigned char* bits/*bits data*/, int w, int h, int* lbytes, bool line_align_4, int threashold, bool reverse)
|
||||
static std::string bmp_821(unsigned char* bits/*bits data*/, int w, int h, int* lbytes/*in/out 行字节*/, bool line_align_4/*是否行对齐4字节*/, int threashold/*黑白像素阈值*/, bool reverse/*是否反色输出*/)
|
||||
{
|
||||
static unsigned int g_bmp8_pallete[] = {
|
||||
0x00000000, 0x00800000, 0x00008000, 0x00808000, 0x00000080, 0x00800080, 0x00008080, 0x00c0c0c0, 0x00c0dcc0, 0x00a6caf0, 0x00402000, 0x00602000, 0x00802000, 0x00a02000, 0x00c02000, 0x00e02000
|
||||
|
@ -2317,7 +2317,11 @@ int hg_scanner::save_final_image(hg_imgproc::LPIMGHEAD head, void* buf)
|
|||
if (img_conf_.pixtype == 0 || (is_1bit && is_multiout))
|
||||
{
|
||||
int old = head->line_bytes;
|
||||
/*/
|
||||
bw = bmp_821((unsigned char*)buf, head->width, head->height, &head->line_bytes, async_io_, bw_threshold_, is_white_0_);
|
||||
/*/
|
||||
bw = hg_imgproc::bmp8_2_1bit((unsigned char*)buf, head->width, head->height, head->line_bytes, bw_threshold_, is_white_0_, async_io_);
|
||||
head->line_bytes = bw.length() / head->height;////////*//////////
|
||||
buf = &bw[0];
|
||||
head->channels = head->bits = 1;
|
||||
head->total_bytes = head->line_bytes * head->height;
|
||||
|
|
|
@ -60,6 +60,10 @@ extern "C"
|
|||
#include "hg_ipc.h"
|
||||
#include "../ImageProcess/G4Tiff.h"
|
||||
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#define CV_MAT_DEPTH_SET(flags, depth) (((flags) & ~(CV_MAT_DEPTH_MASK)) | (depth & CV_MAT_DEPTH_MASK))
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define GET_BYTE(a) ((a) & 0x0ff)
|
||||
#define MAKE_INT(a, b, c, d) (GET_BYTE(a) | (GET_BYTE(b) << 8) | (GET_BYTE(c) << 16) | (GET_BYTE(d) << 24))
|
||||
|
@ -458,6 +462,9 @@ namespace hg_imgproc
|
|||
mat = output.apply(mats[i]);
|
||||
for(size_t j = 0;j < mat.size();j++)
|
||||
{
|
||||
//if (out_type != MULTI_COLOR_AND_GRAY && i == mats.size() - 1)
|
||||
// mats_.push_back(convert_8bit_2_1bit(mat[j], 127, false, false));
|
||||
//else
|
||||
mats_.push_back(mat[j]);
|
||||
// std::string filename = "multi_out("+std::to_string(num++)+").jpg";
|
||||
// cv::imwrite(filename,mat[j]);
|
||||
|
@ -943,6 +950,40 @@ namespace hg_imgproc
|
|||
return SCANNER_ERR_OK;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8位图转1位图
|
||||
/// </summary>
|
||||
/// <param name="image">8bit图</param>
|
||||
/// <param name="threshold">阈值,建议默认127</param>
|
||||
/// <param name="reverse">true为反色,即黑0白1;反之亦然</param>
|
||||
/// <param name="align">true为四字节对齐</param>
|
||||
/// <returns>1位图</returns>
|
||||
static cv::Mat convert_8bit_2_1bit(const cv::Mat& image, uchar threshold, bool reverse, bool align)
|
||||
{
|
||||
if (image.channels() != 1)
|
||||
return cv::Mat();
|
||||
|
||||
int cols = align ? (((image.cols + 7) / 8 + 3) / 4 * 4) : ((image.cols + 7) / 8);
|
||||
int rows = image.rows;
|
||||
|
||||
uchar tableData[256];
|
||||
memset(tableData, reverse ? 0 : 1, 256);
|
||||
memset(tableData, reverse ? 1 : 0, threshold);
|
||||
|
||||
cv::Mat dst = cv::Mat::zeros(rows, cols, (int)CV_8UC1);
|
||||
uchar* ptr_src, * ptr_dst;
|
||||
for (size_t y = 0; y < rows; y++)
|
||||
{
|
||||
ptr_dst = dst.ptr<uchar>(y);
|
||||
ptr_src = const_cast<uchar*>(image.ptr<uchar>(y));
|
||||
for (size_t x = 0; x < image.cols; x++)
|
||||
ptr_dst[x / 8] += tableData[ptr_src[x]] << (x % 8);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
// final
|
||||
public:
|
||||
int final(void)
|
||||
|
@ -1195,8 +1236,6 @@ namespace hg_imgproc
|
|||
}
|
||||
|
||||
// seperate utilites ...
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#define CV_MAT_DEPTH_SET(flags, depth) (((flags) & ~(CV_MAT_DEPTH_MASK)) | (depth & CV_MAT_DEPTH_MASK))
|
||||
static cv::Mat from_bmp_file_bits(const BITMAPINFOHEADER& bih, unsigned char* data, bool line_reverse, bool bw_reverse)
|
||||
{
|
||||
cv::Mat m;
|
||||
|
@ -1470,6 +1509,43 @@ namespace hg_imgproc
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char reverse_bit(unsigned char v)
|
||||
{
|
||||
unsigned char r = 0;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
r <<= 1;
|
||||
r |= v & 1;
|
||||
v >>= 1;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
std::string bmp8_2_1bit(const unsigned char* data, int w, int h, int line_len, int threshold, bool reverse, bool align)
|
||||
{
|
||||
cv::Mat m;
|
||||
unsigned char* dst = NULL;
|
||||
|
||||
m.create(h, w, CV_8UC1);
|
||||
dst = m.ptr();// +w * (h - 1);
|
||||
for (int i = 0; i < h; ++i)
|
||||
{
|
||||
memcpy(dst, data, w);
|
||||
dst += w;
|
||||
data += line_len;
|
||||
}
|
||||
|
||||
cv::Mat bw = imgproc::convert_8bit_2_1bit(m, threshold, reverse, align);
|
||||
//std::string ret("");
|
||||
|
||||
dst = bw.ptr();
|
||||
for (int i = 0; i < bw.total(); ++i)
|
||||
dst[i] = reverse_bit(dst[i]);
|
||||
|
||||
return std::string((char*)bw.ptr(), bw.total());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -212,8 +212,9 @@ namespace hg_imgproc
|
|||
int get_final_data(HIMGPRC himg, LPIMGHEAD pimh, std::vector<unsigned char>* buf, int index);
|
||||
void release(HIMGPRC himg);
|
||||
|
||||
|
||||
// seperate utilites ...
|
||||
int convert_image_file(SANE_ImageFormatConvert* conv);
|
||||
int save_2_bmp_file(const char* bmp_file, LPIMGHEAD head, void* buf, int resolution);
|
||||
|
||||
std::string bmp8_2_1bit(const unsigned char* data, int w, int h, int line_len, int threshold, bool reverse, bool align);
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ g_supporting_devices[] = {
|
|||
#ifdef OEM_LISICHENG
|
||||
{0x31c9, 0x8200, SCANNER_NAME_LSC_G42S, "G42x0F", "", &hg_scanner_mgr::create_scanner_g300}
|
||||
, {0x31c9, 0x8420, SCANNER_NAME_LSC_G42S, "G426xF", "", &hg_scanner_mgr::create_scanner_g300}
|
||||
, {0x31c9, 0x8429, SCANNER_NAME_LSC_G42S, "G42x0F", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
, {0x31c9, 0x8520, SCANNER_NAME_LSC_G52S, "G52x0F", "", &hg_scanner_mgr::create_scanner_g400}
|
||||
, {0x31c9, 0x8529, SCANNER_NAME_LSC_G52S, "G52x0F", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x31c9, 0x8620, SCANNER_NAME_LSC_G62S, "G6290U", "", &hg_scanner_mgr::create_scanner_g100}
|
||||
, {0x31c9, 0x8629, SCANNER_NAME_LSC_G62S, "G6290U", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x31c9, 0x8730, SCANNER_NAME_LSC_G73S, "G73x0U", "", &hg_scanner_mgr::create_scanner_g100}
|
||||
, {0x31c9, 0x8739, SCANNER_NAME_LSC_G73S, "G73x0U", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x31c9, 0x8529, SCANNER_NAME_LSC_G52S, "G52x0F", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x31c9, 0x8429, SCANNER_NAME_LSC_G42S, "G42x0F", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
|
||||
#elif defined(OEM_HANWANG)
|
||||
{0x2903, 0x1000, SCANNER_NAME_HW_1000, SCANNER_NAME_HW_1000, "",& hg_scanner_mgr::create_scanner_g300} // "HW-1060A"
|
||||
|
@ -51,16 +51,16 @@ g_supporting_devices[] = {
|
|||
, {0x2903, 0x9000, SCANNER_NAME_HW_9000, SCANNER_NAME_HW_9000, "", &hg_scanner_mgr::create_scanner_g239} // "HW-9110E"
|
||||
#else
|
||||
{0x3072, 0x100, SCANNER_NAME_HG_G100, "GScanO200", "", &hg_scanner_mgr::create_scanner_g100}
|
||||
, {0x3072, 0x139, SCANNER_NAME_HG_G100, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x3072, 0x200, SCANNER_NAME_HG_G200, "GScanO200", "", &hg_scanner_mgr::create_scanner_g100}
|
||||
, {0x3072, 0x239, SCANNER_NAME_HG_G200, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x3072, 0x300, SCANNER_NAME_HG_G300, "GScanO400", "", &hg_scanner_mgr::create_scanner_g300}
|
||||
, {0x3072, 0x400, SCANNER_NAME_HG_G400, "GScanO400", "", &hg_scanner_mgr::create_scanner_g400}
|
||||
, {0x3072, 0x139, SCANNER_NAME_HG_G139, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x3072, 0x239, SCANNER_NAME_HG_G239, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x3072, 0x339, SCANNER_NAME_HG_G339, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
, {0x3072, 0x439, SCANNER_NAME_HG_G439, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x064B, 0x7823, SCANNER_NAME_HG_G200, "GScanO200", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
, {0x3072, 0x302, SCANNER_NAME_HG_G300, "GScanO400", "", &hg_scanner_mgr::create_scanner_g302}
|
||||
, {0x3072, 0x402, SCANNER_NAME_HG_G402, "GScanO4003399", "", &hg_scanner_mgr::create_scanner_g402}
|
||||
, {0x3072, 0x339, SCANNER_NAME_HG_G300, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
, {0x3072, 0x400, SCANNER_NAME_HG_G400, "GScanO400", "", &hg_scanner_mgr::create_scanner_g400}
|
||||
, {0x3072, 0x402, SCANNER_NAME_HG_G400, "GScanO4003399", "", &hg_scanner_mgr::create_scanner_g402}
|
||||
, {0x3072, 0x439, SCANNER_NAME_HG_G400, "GScanO1003399", "", &hg_scanner_mgr::create_scanner_g239}
|
||||
, {0x064B, 0x7823,SCANNER_NAME_HG_G200, "GScanO200", "", &hg_scanner_mgr::create_scanner_empty}
|
||||
#endif
|
||||
};
|
||||
static std::string g_vendor = COMPANY_NAME;
|
||||
|
|
Loading…
Reference in New Issue