run splash on own thread
This commit is contained in:
@ -53,5 +53,5 @@ set(PROJECT_SOURCES
|
|||||||
|
|
||||||
add_executable(MAClient ${PROJECT_SOURCES})
|
add_executable(MAClient ${PROJECT_SOURCES})
|
||||||
target_compile_options(MAClient PRIVATE "-std=gnu++17" "-Wall" "-O2" "-fno-strict-aliasing")
|
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)
|
target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS} src src/ui)
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <unistd.h>
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
Cameras::Cameras(uvosled* led): led_(led)
|
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()->setAcquisitionMode(cam::Camera::MODE_FREE);
|
||||||
camera->cam()->setFrameRate(10);
|
camera->cam()->setFrameRate(10);
|
||||||
camera->cam()->startAcquisition();
|
camera->cam()->startAcquisition();
|
||||||
struct timespec tv = {0, 200000000};
|
std::this_thread::sleep_for (std::chrono::milliseconds(200));
|
||||||
nanosleep(&tv, nullptr);
|
|
||||||
camera->cam()->stopAcquisition();
|
camera->cam()->stopAcquisition();
|
||||||
cameras_.pop_back();
|
cameras_.pop_back();
|
||||||
camera = nullptr;
|
camera = nullptr;
|
||||||
@ -97,7 +97,7 @@ bool Cameras::addCamera(const cam::Camera::Description& desc)
|
|||||||
camera->cam()->setAcquisitionMode(cam::Camera::MODE_FREE);
|
camera->cam()->setAcquisitionMode(cam::Camera::MODE_FREE);
|
||||||
camera->cam()->setFrameRate(10);
|
camera->cam()->setFrameRate(10);
|
||||||
camera->cam()->startAcquisition();
|
camera->cam()->startAcquisition();
|
||||||
QTimer::singleShot(5000, [camera, this](){finishAddCamera(camera);});
|
QTimer::singleShot(5000, [this, camera](){finishAddCamera(camera);});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
37
src/main.cpp
37
src/main.cpp
@ -6,7 +6,8 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QThread>
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
#include <opencv2/core/mat.hpp>
|
#include <opencv2/core/mat.hpp>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uvosunwrap/log.h>
|
#include <uvosunwrap/log.h>
|
||||||
@ -23,6 +24,8 @@ const char* organziation = "UVOS";
|
|||||||
const char* application = "UVOS";
|
const char* application = "UVOS";
|
||||||
const char* version = "UVOS";
|
const char* version = "UVOS";
|
||||||
|
|
||||||
|
std::atomic<bool> closeSplash = false;
|
||||||
|
|
||||||
std::vector<cam::Camera::Description> showCameraSelectionDialog(bool* accepted = nullptr)
|
std::vector<cam::Camera::Description> showCameraSelectionDialog(bool* accepted = nullptr)
|
||||||
{
|
{
|
||||||
std::vector<cam::Camera::Description> ret;
|
std::vector<cam::Camera::Description> ret;
|
||||||
@ -54,24 +57,34 @@ void showProfileDialog(Cameras* cameras)
|
|||||||
cameras->disable(false);
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Log::level = Log::WARN;
|
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;
|
uvosled led;
|
||||||
int uvosledRet = uvosled_connect(&led);
|
int uvosledRet = uvosled_connect(&led);
|
||||||
int ret;
|
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());
|
QDir().mkpath(Profile::profileLocation());
|
||||||
|
|
||||||
qRegisterMetaType<cv::Mat>("cv::Mat");
|
qRegisterMetaType<cv::Mat>("cv::Mat");
|
||||||
@ -88,7 +101,7 @@ int main(int argc, char *argv[])
|
|||||||
uvosled_poweron(&led);
|
uvosled_poweron(&led);
|
||||||
// Give cameras some time to power on
|
// Give cameras some time to power on
|
||||||
// TODO: figure out how to do this better
|
// 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);
|
Cameras cameras(uvosledRet < 0 ? nullptr : &led);
|
||||||
@ -127,7 +140,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
cameras.load(settings);
|
cameras.load(settings);
|
||||||
|
|
||||||
splash.hide();
|
closeSplash = true;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
if(uvosledRet < 0)
|
if(uvosledRet < 0)
|
||||||
|
Reference in New Issue
Block a user