diff --git a/src/main.cpp b/src/main.cpp index 5e90587..075774e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,101 +58,104 @@ 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"); - - QSplashScreen splash(QPixmap(":/images/splash.png")); - splash.show(); - - QDir().mkpath(Profile::profileLocation()); - - qRegisterMetaType("cv::Mat"); - qRegisterMetaType("size_t"); - qRegisterMetaType("Camera::Image"); - qRegisterMetaType("Image"); - qRegisterMetaType>("std::vector"); - - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); - uvosled led; int uvosledRet = uvosled_connect(&led); - - if(uvosledRet >= 0) + int ret; + { - qDebug()<<"uvosled_poweron"; - uvosled_poweron(&led); - // Give cameras some time to power on - // TODO: figure out how to do this better - sleep(10); + 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"); + qRegisterMetaType("size_t"); + qRegisterMetaType("Camera::Image"); + qRegisterMetaType("Image"); + qRegisterMetaType>("std::vector"); + + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); + + if(uvosledRet >= 0) + { + qDebug()<<"uvosled_poweron"; + uvosled_poweron(&led); + // Give cameras some time to power on + // TODO: figure out how to do this better + sleep(10); + } + + Cameras cameras(uvosledRet < 0 ? nullptr : &led); + cameras.setFree(false); + ImagePipeline pipe(&cameras); + + MainWindow w; + + QObject::connect(&cameras, &Cameras::cameraAdded, &w, &MainWindow::addCamera); + QObject::connect(&cameras, &Cameras::cameraRemoved, &w, &MainWindow::removeCamera); + QObject::connect(&w, &MainWindow::sigCapture, [&cameras](){cameras.start(); cameras.trigger();}); + + QObject::connect(&w, &MainWindow::sigChooseCameras, [&cameras]() + { + bool accepted; + std::vector descs = showCameraSelectionDialog(&accepted); + if(accepted) + cameras.setCameras(descs); + }); + + QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras); w.refreshProfiles();}); + QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection); + QObject::connect(&pipe, &ImagePipeline::sigResult, [&w](){w.statusMsg("idle");}); + QObject::connect(&pipe, &ImagePipeline::sigInvalidProfile, &w, &MainWindow::profileInconpatible); + + QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name) + { + Profile profile; + profile.load(name); + if(profile.cameras.size() != 0) + qDebug()<<"loading profile"< descs = showCameraSelectionDialog(&accepted); - if(accepted) - cameras.setCameras(descs); - }); - - QObject::connect(&w, &MainWindow::sigEditProfiles, [&cameras, &w](){showProfileDialog(&cameras); w.refreshProfiles();}); - QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection); - QObject::connect(&pipe, &ImagePipeline::sigResult, [&w](){w.statusMsg("idle");}); - QObject::connect(&pipe, &ImagePipeline::sigInvalidProfile, &w, &MainWindow::profileInconpatible); - - QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name) - { - Profile profile; - profile.load(name); - if(profile.cameras.size() != 0) - qDebug()<<"loading profile"<= 0) uvosled_poweroff(&led);