#include "CameraHelper.h" #include "IniHelper.h" #include #ifndef _WIN32 #include // Linux for so #endif #include CCameraHelper* CCameraHelper::m_instance; CCameraHelper* CCameraHelper::Get() { if (CCameraHelper::m_instance == nullptr) { CCameraHelper::m_instance = new CCameraHelper(); // 待优化 } return CCameraHelper::m_instance; } CCameraHelper::CCameraHelper() { } CCameraHelper::~CCameraHelper() { } int CCameraHelper::Init() { #ifndef _WIN32 const char* libPath = "./libCameraDriver.so"; void* handle = dlopen(libPath, RTLD_LAZY); if (!handle) { // Linux std::cerr << "无法加载动态库: " << dlerror() << std::endl; return CAMERA_DLL_INIT_ERROR; } pfuccamera_init = (PFuccamera_init)dlsym(handle, "camera_init"); pfuccamera_start = (PFuccamera_start)dlsym(handle, "camera_start"); pfuccamera_stop = (PFuccamera_stop)dlsym(handle, "camera_stop"); pfuccamera_cap = (PFuccamera_cap)dlsym(handle, "camera_cap"); if (G(camera_cap_fake) == "true") return 0; else { this->pfuccamera_init(); //this->pfuccamera_start(12 * 10000); return 0; //return this->pfuccamera_init(); } #endif return 0; } int CCameraHelper::Start(int epx_time) { return this->pfuccamera_start(epx_time); } int CCameraHelper::Stop() { return this->pfuccamera_stop(); } int CCameraHelper::Cap(void** data, int& w, int& h, int timeout) { return this->pfuccamera_cap(data, w, h, timeout); } #ifndef _WIN32 #endif