mirror of http://192.168.1.51:8099/lmh188/twain3.0
增加利用CMAKE 构建TWAIN工程文件,编译debug、release版本已通过
This commit is contained in:
parent
287843624e
commit
89338002ad
|
@ -0,0 +1,108 @@
|
||||||
|
# CMake 最低版本号要求
|
||||||
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
project(huagotwainds)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git log -1 --format=%H
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_VERSION
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git remote -v
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_REMOTE_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
#string (REGEX REPLACE ".*\t| .*" "" GIT_PATH ${GIT_REMOTE_PATH})
|
||||||
|
string (REGEX REPLACE "[\n\t\r]" "" GIT_VERSION ${GIT_VERSION})
|
||||||
|
|
||||||
|
file(GLOB DEV_SRC ${PROJECT_SOURCE_DIR}/Device/*.h ${PROJECT_SOURCE_DIR}/Device/*.cpp)
|
||||||
|
file(GLOB IMGPROC_SRC ${PROJECT_SOURCE_DIR}/ImageProcess/*.h ${PROJECT_SOURCE_DIR}/ImageProcess/*.cpp)
|
||||||
|
file(GLOB SRC ${PROJECT_SOURCE_DIR}/*.h ${PROJECT_SOURCE_DIR}/*.cpp)
|
||||||
|
|
||||||
|
aux_source_directory(${PROJECT_SOURCE_DIR} DIR_SRCS)
|
||||||
|
aux_source_directory(${PROJECT_SOURCE_DIR}/Device DIR_DEVICE)
|
||||||
|
aux_source_directory(${PROJECT_SOURCE_DIR}/ImageProcess DIR_IMGPROC)
|
||||||
|
|
||||||
|
set(DIR_RC huagaotwds.rc)
|
||||||
|
source_group("RC Files" FILES ${DIR_RC})
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${PROJECT_SOURCE_DIR}
|
||||||
|
${PROJECT_SOURCE_DIR}/..
|
||||||
|
${PROJECT_SOURCE_DIR}/../twpp
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/nick
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/libtiff/include
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/gpdf/
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/include
|
||||||
|
)
|
||||||
|
|
||||||
|
message($ENV{windir})
|
||||||
|
|
||||||
|
link_directories(${PROJECT_SOURCE_DIR}/../3rdparty/opencv/x86/staticlib/
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/libtiff/
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/gpdf/x86/staticlib/
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/gpdf/3rdparty/tesseract/staticlib/x86/)
|
||||||
|
|
||||||
|
MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}")
|
||||||
|
|
||||||
|
MACRO(RW_LINK_3RD_PART_LIBRARY FULL_LIBRARY_NAME)
|
||||||
|
link_libraries(optimized ${FULL_LIBRARY_NAME})
|
||||||
|
link_libraries(debug ${FULL_LIBRARY_NAME}d)
|
||||||
|
ENDMACRO()
|
||||||
|
|
||||||
|
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
MESSAGE(STATUS "current platform: Linux ")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||||
|
link_libraries(hg_gpdf)
|
||||||
|
link_libraries(cvblob)
|
||||||
|
link_libraries(libjpeg)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(opencv_core343)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(opencv_highgui343)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(opencv_imgcodecs343)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(opencv_imgproc343)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(IlmImf)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(libjasper)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(libjpeg-turbo)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(libpng)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(libtiff)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(libwebp)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(zlib)
|
||||||
|
RW_LINK_3RD_PART_LIBRARY(ittnotify)
|
||||||
|
link_libraries(libwebp)
|
||||||
|
link_libraries(libleptonica)
|
||||||
|
link_libraries(libprotobuf)
|
||||||
|
link_libraries(quirc)
|
||||||
|
link_libraries(tesseract_api)
|
||||||
|
link_libraries(tesseract_arch)
|
||||||
|
link_libraries(tesseract_ccmain)
|
||||||
|
link_libraries(tesseract_ccstruct)
|
||||||
|
link_libraries(tesseract_ccutil)
|
||||||
|
link_libraries(tesseract_classify)
|
||||||
|
link_libraries(tesseract_cutil)
|
||||||
|
link_libraries(tesseract_dict)
|
||||||
|
link_libraries(tesseract_lstm)
|
||||||
|
link_libraries(tesseract_opencl)
|
||||||
|
link_libraries(tesseract_textord)
|
||||||
|
link_libraries(tesseract_viewer)
|
||||||
|
link_libraries(tesseract_wordrec)
|
||||||
|
MESSAGE(STATUS "current platform: Windows")
|
||||||
|
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
|
MESSAGE(STATUS "current platform: FreeBSD")
|
||||||
|
ELSE ()
|
||||||
|
MESSAGE(STATUS "other platform: ${CMAKE_SYSTEM_NAME}")
|
||||||
|
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
|
||||||
|
add_definitions(-DTWPP_IS_DS -D_CRT_SECURE_NO_WARNINGS -D_DIRECT_BUILD -D_NOT_USE -D_AFXDLL -D_UNICODE -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_CRT_NON_CONFORMING_SWPRINTFS -D_WIN32)
|
||||||
|
add_definitions(-DGIT_VERSION=\"${GIT_VERSION}\")
|
||||||
|
|
||||||
|
|
||||||
|
# 指定生成目标
|
||||||
|
add_library(huagaotwain SHARED ${DIR_SRCS} ${PROJECT_SOURCE_DIR}/exports.def ${DEV_SRC} ${IMGPROC_SRC} ${SRC} ${DIR_RC})
|
||||||
|
#target_link_libraries(huagaotwain PRIVATE Qt5::Widgets ${Qt5_STATIC_LINK_LIBRARIES} gdev gimgproc)
|
||||||
|
#target_link_directories(huagaotwain PRIVATE ${Qt5_STATIC_LINK_DIR})
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/redistribute)
|
||||||
|
|
||||||
|
set(huagaotwain_path "$<$<CONFIG:Debug>:${LIBRARY_OUTPUT_PATH}\\Debug\\huagaotwain.dll>" "$<$<CONFIG:Release>:${LIBRARY_OUTPUT_PATH}\\Release\\huagaotwain.dll>")
|
||||||
|
string(REPLACE "/" "\\" huagaotwain_path ${huagaotwain_path})
|
||||||
|
add_custom_command(TARGET huagaotwain POST_BUILD COMMAND copy ${huagaotwain_path} $ENV{windir}\\twain_32\\huagoscan\\huagaotwain.ds)
|
|
@ -4,7 +4,6 @@
|
||||||
#include "UsbScanEx.h"
|
#include "UsbScanEx.h"
|
||||||
#include "StopWatch.h"
|
#include "StopWatch.h"
|
||||||
#include "scn_config.h"
|
#include "scn_config.h"
|
||||||
#include "JpegBuffer.h"
|
|
||||||
#include "ImageMatQueue.h"
|
#include "ImageMatQueue.h"
|
||||||
#include "filetools.h"
|
#include "filetools.h"
|
||||||
#include "GetMemoryUsage.h"
|
#include "GetMemoryUsage.h"
|
||||||
|
@ -176,7 +175,7 @@ void GScanO200::open(int vid, int pid)
|
||||||
ipid = 0x0100;
|
ipid = 0x0100;
|
||||||
#else
|
#else
|
||||||
ivid = 0x3072;
|
ivid = 0x3072;
|
||||||
ipid = 0x0200;
|
ipid = 0x0100;
|
||||||
#endif // ISG100
|
#endif // ISG100
|
||||||
|
|
||||||
#elif defined(G300)
|
#elif defined(G300)
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
#include "StdAfx.h"
|
|
||||||
#include "JpegBuffer.h"
|
|
||||||
#include "jpeglib.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
JpegBuffer::JpegBuffer(cv::Mat buffer, int color_type,int side,int mFilter)
|
|
||||||
{
|
|
||||||
this->m_buffer = buffer;
|
|
||||||
this->m_color_type=color_type;
|
|
||||||
this->m_side=side;
|
|
||||||
this->m_mFilter=mFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
JpegBuffer::JpegBuffer(std::vector<cv::Mat> mats, int color_type, int mFilter)
|
|
||||||
{
|
|
||||||
matdatas = mats;
|
|
||||||
this->m_color_type = color_type;
|
|
||||||
this->m_mFilter = mFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
JpegBuffer::JpegBuffer()
|
|
||||||
{
|
|
||||||
this->m_buffer = cv::Mat();
|
|
||||||
this->m_color_type = 2;
|
|
||||||
this->m_side = 0;
|
|
||||||
this->m_mFilter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JpegBuffer::~JpegBuffer(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char* JpegBuffer::getBuffer()
|
|
||||||
{
|
|
||||||
return m_buffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::Mat JpegBuffer::buffer()
|
|
||||||
{
|
|
||||||
return m_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegBuffer::getSize()
|
|
||||||
{
|
|
||||||
return m_buffer.cols;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cv::Mat JpegBuffer::getMat( int pixType)
|
|
||||||
{
|
|
||||||
JpegLib jl;
|
|
||||||
cv::Mat image = jl.decode(m_buffer, pixType);
|
|
||||||
return image.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<cv::Mat> JpegBuffer::getMats()
|
|
||||||
{
|
|
||||||
std::vector<cv::Mat> retmats;
|
|
||||||
for (int i = 0; i < matdatas.size(); i++)
|
|
||||||
{
|
|
||||||
JpegLib jl;
|
|
||||||
cv::Mat image = jl.decode(matdatas[i], m_color_type);
|
|
||||||
retmats.push_back(image.clone());
|
|
||||||
image.release();
|
|
||||||
}
|
|
||||||
return retmats;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegBuffer::getMFilter()
|
|
||||||
{
|
|
||||||
return m_mFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegBuffer::getSide()
|
|
||||||
{
|
|
||||||
return m_side;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JpegBuffer::empty()
|
|
||||||
{
|
|
||||||
return matdatas.empty();
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <opencv2\opencv.hpp>
|
|
||||||
|
|
||||||
class JpegBuffer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
JpegBuffer(cv::Mat buffer,int color_type=6,int side=0,int mFilter=0);
|
|
||||||
JpegBuffer(std::vector<cv::Mat> mats, int color_type = 6,int mFilter = 0);
|
|
||||||
JpegBuffer();
|
|
||||||
virtual ~JpegBuffer(void);
|
|
||||||
|
|
||||||
unsigned char* getBuffer();
|
|
||||||
cv::Mat buffer();
|
|
||||||
int getSize();
|
|
||||||
cv::Mat getMat( int pixType);
|
|
||||||
std::vector<cv::Mat> getMats();
|
|
||||||
int getMFilter();
|
|
||||||
int getSide();
|
|
||||||
bool empty();
|
|
||||||
|
|
||||||
private:
|
|
||||||
cv::Mat m_buffer;
|
|
||||||
std::vector<cv::Mat> matdatas;
|
|
||||||
int m_color_type;
|
|
||||||
int m_side;
|
|
||||||
int m_mFilter;
|
|
||||||
};
|
|
|
@ -1,67 +0,0 @@
|
||||||
#include "stdafx.h"
|
|
||||||
#include "jpeglib.h"
|
|
||||||
|
|
||||||
JpegLib::JpegLib() :
|
|
||||||
img_buffer(NULL), sizeBuffer(0)
|
|
||||||
{
|
|
||||||
handle = std::shared_ptr<void> (tjInitDecompress(),tjDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
JpegLib::~JpegLib()
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JpegLib::clear()
|
|
||||||
{
|
|
||||||
img_buffer.reset();
|
|
||||||
sizeBuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::Mat JpegLib::decode(cv::Mat buf, int pixelFormat)
|
|
||||||
{
|
|
||||||
if(buf.rows != 1)
|
|
||||||
return cv::Mat();
|
|
||||||
|
|
||||||
decode(buf.data, buf.cols, pixelFormat);
|
|
||||||
|
|
||||||
return cv::Mat(getHeight(), getWidth() , pixelFormat == TJPF_BGR ? CV_8UC3 : CV_8UC1, getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
void JpegLib::decode(unsigned char* buff, unsigned long buff_size, int pixelFormat)
|
|
||||||
{
|
|
||||||
tjDecompressHeader(handle.get(), buff, buff_size, &width, &height);
|
|
||||||
int size = width * height *tjPixelSize[pixelFormat];
|
|
||||||
|
|
||||||
if (sizeBuffer != size)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
img_buffer = std::shared_ptr<unsigned char>(tjAlloc(size), tjFree);
|
|
||||||
sizeBuffer = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (img_buffer)
|
|
||||||
{
|
|
||||||
tjDecompress2(handle.get(), buff, buff_size, img_buffer.get(), width, 0, height, pixelFormat, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegLib::getWidth()
|
|
||||||
{
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegLib::getHeight()
|
|
||||||
{
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
int JpegLib::getBufferSize()
|
|
||||||
{
|
|
||||||
return sizeBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char* JpegLib::getData()
|
|
||||||
{
|
|
||||||
return img_buffer.get();
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "turbojpeg.h"
|
|
||||||
#include <memory>
|
|
||||||
#include <opencv2\opencv.hpp>
|
|
||||||
|
|
||||||
class JpegLib
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
JpegLib();
|
|
||||||
~JpegLib();
|
|
||||||
|
|
||||||
void clear();
|
|
||||||
cv::Mat decode(cv::Mat buf, int pixelFormat);
|
|
||||||
void decode(unsigned char* buff, unsigned long buff_size, int pixelFormat);
|
|
||||||
int getWidth();
|
|
||||||
int getHeight();
|
|
||||||
int getBufferSize();
|
|
||||||
unsigned char* getData();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<void> handle;
|
|
||||||
std::shared_ptr<unsigned char> img_buffer;
|
|
||||||
int sizeBuffer;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
Loading…
Reference in New Issue