Initial commit
This commit is contained in:
commit
5efbdcbd6a
32 changed files with 1914 additions and 0 deletions
93
src/main.cpp
Normal file
93
src/main.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#include <QApplication>
|
||||
#include <uvoscam.h>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QSplashScreen>
|
||||
#include <QDir>
|
||||
#include <QThread>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
|
||||
#include "cameras.h"
|
||||
#include "./ui/cameradialog.h"
|
||||
#include "profile.h"
|
||||
#include "./ui/mainwindow.h"
|
||||
#include "imagepipeline.h"
|
||||
|
||||
const char* organziation = "UVOS";
|
||||
const char* application = "UVOS";
|
||||
const char* version = "UVOS";
|
||||
|
||||
std::vector<cam::Camera::Description> showCameraSelectionDialog()
|
||||
{
|
||||
std::vector<cam::Camera::Description> ret;
|
||||
CameraDialog diag(cam::Camera::getAvailableCameras());
|
||||
|
||||
diag.show();
|
||||
if(diag.exec() == QDialog::Accepted)
|
||||
ret = diag.getDescriptions();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
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(CameraSetup::camerasLocation());
|
||||
|
||||
qRegisterMetaType<cv::Mat>("cv::Mat");
|
||||
qRegisterMetaType<size_t>("size_t");
|
||||
qRegisterMetaType<Camera::Image>("Image");
|
||||
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
|
||||
uvosled led;
|
||||
int uvosledRet = uvosled_connect(&led);
|
||||
|
||||
Cameras cameras(uvosledRet < 0 ? nullptr : &led);
|
||||
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](){cameras.setCameras(showCameraSelectionDialog());});
|
||||
QObject::connect(&pipe, &ImagePipeline::sigResult, w.mainImageViewer(), &CvImageViewer::setImage, Qt::QueuedConnection);
|
||||
|
||||
QObject::connect(&w, &MainWindow::sigProfile, [&pipe](QString name)
|
||||
{
|
||||
Profile profile;
|
||||
profile.load(name);
|
||||
pipe.setProfile(profile);
|
||||
});
|
||||
|
||||
cameras.load(settings);
|
||||
|
||||
splash.hide();
|
||||
w.show();
|
||||
|
||||
if(uvosledRet < 0)
|
||||
QMessageBox::warning(&w, "UVOS LED", "Can not connect to the UVOS LED device");
|
||||
|
||||
if(cameras.getCameras().empty())
|
||||
{
|
||||
QMessageBox::information(&w, "Cameras", "No cameras configured, please choose at least one camera.");
|
||||
cameras.setCameras(showCameraSelectionDialog());
|
||||
}
|
||||
|
||||
int ret = a.exec();
|
||||
|
||||
cameras.store(settings);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue