#include #include #include #include #include "HGScannerLib.h" #include #define DELEAY_MS(x) std::this_thread::sleep_for(std::chrono::milliseconds((x))) using namespace std; //有图事件回调 static void DeviceScanImageFunc(HGLibDevice device, HGLibImage image, HGPointer param) { static int indeximg = 0; string savepath = std::to_string(++indeximg) + ".jpg"; cout << "save image : " << savepath << endl; auto ret = HGLib_SaveImage(image, savepath.c_str(), 0); cout << "save image : " << savepath << (ret ? " success" : " failed") << endl; } //设备热拔插事件回调 static void DeviceHotPlugEvent(HGUInt event, const HGChar *deviceName, HGPointer param) { cout << "Devices : " << deviceName << " DeviceHotPlugEvent : " << (event == HGLIB_DEVHOTPLUG_EVENT_ARRIVE ? "HGLIB_DEVHOTPLUG_EVENT_ARRIVE " : "HGLIB_DEVHOTPLUG_EVENT_LEFT") << endl; } //扫描状态事件回调 static void DeviceScanEvent(HGLibDevice device, HGUInt event, HGBool err, const HGChar *info, HGPointer param) { switch (event) { case HGLIB_DEVSCAN_EVENT_BEGIN: cout << "DeviceScanEvent Start Scan" << endl; break; case HGLIB_DEVSCAN_EVENT_END: cout << "DeviceScanEvent Scan stopped" << endl; break; case HGLIB_DEVSCAN_EVENT_INFO: cout << "DeviceScanEvent info : " << info << endl; break; default: cout << "Unkownun DeviceScanEvent " << event << endl; break; } } int main(unsigned char argc, unsigned char *argv[]) { std::cout << "*********Enter Scanner SDK Demo *********" << std::endl; HGLib_InitDevice(DeviceHotPlugEvent, 0); //初始化调用模块 DELEAY_MS(5000); HGChar **devNameList = HGLib_GetDeviceNameList(); //获取已连接的设备列表,已字符数组的形式返回 if (devNameList) { HGLibDevice dev = HGLib_OpenDevice(devNameList[0]); //此示例代码中调用设备列表中第一个设备 if (dev) { HGUInt grpCount = 0; HGLibDeviceParamGroup *groups = HGLib_GetDeviceParamGroupList(dev, &grpCount); if (groups) { //获取sdk支持的功能项及配置项内容 for (size_t i = 0; i < grpCount; i++) { cout << "group: " << groups[i].group << endl; for (size_t j = 0; j < groups[i].paramCount; j++) { cout << " option: " << groups[i].param[j].option << " type: " << groups[i].param[j].type << endl; switch (groups[i].param[j].rangeType) { case HGLIB_OPTION_VALUERANGETYPE_INTLIST: for (size_t k = 0; k < groups[i].param[j].intValueList.count; k++) { cout<<"support value["<