diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd29a8..e915cc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,5 +53,5 @@ set(PROJECT_SOURCES add_executable(MAClient ${PROJECT_SOURCES}) target_compile_options(MAClient PRIVATE "-std=gnu++17" "-Wall" "-O2" "-fno-strict-aliasing") -target_link_libraries(MAClient PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Concurrent ${OpenCV_LIBS} -luvoscam -luvosled -luvosunwrap) +target_link_libraries(MAClient PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Concurrent ${OpenCV_LIBS} -luvoscam -luvosled -luvosunwrap -pthread) target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} src src/ui) diff --git a/src/cameras.cpp b/src/cameras.cpp index 2f002f3..682aaa9 100644 --- a/src/cameras.cpp +++ b/src/cameras.cpp @@ -3,7 +3,8 @@ #include #include #include -#include +#include +#include #include Cameras::Cameras(uvosled* led): led_(led) @@ -80,8 +81,7 @@ bool Cameras::addCamera(const cam::Camera::Description& desc) camera->cam()->setAcquisitionMode(cam::Camera::MODE_FREE); camera->cam()->setFrameRate(10); camera->cam()->startAcquisition(); - struct timespec tv = {0, 200000000}; - nanosleep(&tv, nullptr); + std::this_thread::sleep_for (std::chrono::milliseconds(200)); camera->cam()->stopAcquisition(); cameras_.pop_back(); camera = nullptr; @@ -97,7 +97,7 @@ bool Cameras::addCamera(const cam::Camera::Description& desc) camera->cam()->setAcquisitionMode(cam::Camera::MODE_FREE); camera->cam()->setFrameRate(10); camera->cam()->startAcquisition(); - QTimer::singleShot(5000, [camera, this](){finishAddCamera(camera);}); + QTimer::singleShot(5000, [this, camera](){finishAddCamera(camera);}); } else { diff --git a/src/main.cpp b/src/main.cpp index 075774e..7b9f00a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -23,6 +24,8 @@ const char* organziation = "UVOS"; const char* application = "UVOS"; const char* version = "UVOS"; +std::atomic closeSplash = false; + std::vector showCameraSelectionDialog(bool* accepted = nullptr) { std::vector ret; @@ -54,24 +57,34 @@ void showProfileDialog(Cameras* cameras) cameras->disable(false); } +void showSplash() +{ + QSplashScreen splash(QPixmap(":/images/splash.png")); + splash.show(); + while(!closeSplash) + { + splash.repaint(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } +} + int main(int argc, char *argv[]) { Log::level = Log::WARN; + QApplication a(argc, argv); + QCoreApplication::setOrganizationName("UVOS"); + QCoreApplication::setOrganizationDomain("uvos.xyz"); + QCoreApplication::setApplicationName("LubircantThiknessMapperUi"); + QCoreApplication::setApplicationVersion("0.1"); + + std::thread splashThred(&showSplash); + uvosled led; int uvosledRet = uvosled_connect(&led); int ret; { - QApplication a(argc, argv); - QCoreApplication::setOrganizationName("UVOS"); - QCoreApplication::setOrganizationDomain("uvos.xyz"); - QCoreApplication::setApplicationName("LubircantThiknessMapperUi"); - QCoreApplication::setApplicationVersion("0.1"); - - QSplashScreen splash(QPixmap(":/images/splash.png")); - splash.show(); - QDir().mkpath(Profile::profileLocation()); qRegisterMetaType("cv::Mat"); @@ -88,7 +101,7 @@ int main(int argc, char *argv[]) uvosled_poweron(&led); // Give cameras some time to power on // TODO: figure out how to do this better - sleep(10); + std::this_thread::sleep_for(std::chrono::seconds(10)); } Cameras cameras(uvosledRet < 0 ? nullptr : &led); @@ -127,7 +140,7 @@ int main(int argc, char *argv[]) cameras.load(settings); - splash.hide(); + closeSplash = true; w.show(); if(uvosledRet < 0)