diff --git a/app/SandboxSetup/initcamera.cpp b/app/SandboxSetup/initcamera.cpp index f1f397896ea2388d5f1cbf3b774b5a3e6aed8257..3985fe0fe9d6c3adeac8893d6b89685da3e26a28 100644 --- a/app/SandboxSetup/initcamera.cpp +++ b/app/SandboxSetup/initcamera.cpp @@ -9,9 +9,13 @@ CameraStartThread::CameraStartThread(Camera *c) : QThread() { void CameraStartThread::run() { - camera->start(); - camera->warmUpDepthLens(); - emit setupReady(); + int err = camera->start(); + emit deviceFound(err); + + if(!err){ + camera->warmUpDepthLens(); + emit setupReady(0); + } } @@ -25,6 +29,7 @@ InitCamera::InitCamera(SandboxSetup *_setup, QWidget *parent) : ui->setupUi(this); workerThread = new CameraStartThread(setup->getCamera()); + connect(workerThread, &CameraStartThread::deviceFound, this, &InitCamera::deviceFound); connect(workerThread, &CameraStartThread::setupReady, this, &InitCamera::setupReady); connect(workerThread, &CameraStartThread::finished, workerThread, &QObject::deleteLater); } @@ -48,8 +53,17 @@ void InitCamera::setupCamera(){ workerThread->start(); } -void InitCamera::setupReady(){ - emit sendNotif(0); +void InitCamera::deviceFound(int err){ + QString msg = (err) ? "No device found" : "Initializing device..."; + ui->label->setText(msg); + + if(err) + emit sendNotif(err); +} + +void InitCamera::setupReady(int err){ + + emit sendNotif(err); } diff --git a/app/SandboxSetup/initcamera.h b/app/SandboxSetup/initcamera.h index 2157a38ad2da77b7008566dfd183b01e3dfe635d..86862835777611064cec771398bc4d630e523e6e 100644 --- a/app/SandboxSetup/initcamera.h +++ b/app/SandboxSetup/initcamera.h @@ -21,7 +21,8 @@ public: void run(); signals: - void setupReady(); + void setupReady(int state); + void deviceFound(int err); private: Camera *camera; @@ -46,7 +47,8 @@ private: CameraStartThread *workerThread; void setupCamera(); - void setupReady(); + void setupReady(int state); + void deviceFound(int err); }; #endif // INITCAMERA_H diff --git a/app/SandboxSetup/initcamera.ui b/app/SandboxSetup/initcamera.ui index 1f7e11b37a0ed61a41ea96cf5e6fabf7977d1cba..a30f0bd0766fb3e12b2775a5cb4f401217feff1c 100644 --- a/app/SandboxSetup/initcamera.ui +++ b/app/SandboxSetup/initcamera.ui @@ -23,7 +23,7 @@ </rect> </property> <property name="text"> - <string>Initializing camera...</string> + <string>Checking camera...</string> </property> </widget> </widget> diff --git a/app/SandboxSetup/mainwindow.cpp b/app/SandboxSetup/mainwindow.cpp index 0f3b4ccd26c7fbb5353004f514659ca064ada368..c2fb74f66afd5cc41410aeab718c6eb089a4669f 100644 --- a/app/SandboxSetup/mainwindow.cpp +++ b/app/SandboxSetup/mainwindow.cpp @@ -64,8 +64,12 @@ void MainWindow::receiveNotif(int state){ // active app : InitCamera if( strcmp( applist.at(step)->metaObject()->className(), init->metaObject()->className() ) == 0 ){ - ui->btnNext->setVisible(true); - nextApp(); + if(state){ + ui->btnFinish->setVisible(true); + }else{ + ui->btnNext->setVisible(true); + nextApp(); + } } // active app : BeamerLocation else if( strcmp( applist.at(step)->metaObject()->className(), bl->metaObject()->className() ) == 0 ){ diff --git a/inc/camera.h b/inc/camera.h index 15e4b599195b6c7cb689c5f3ef03cfaf0952a325..a1dd321a72ada8541daaa3e147c5e222ddb4f24c 100644 --- a/inc/camera.h +++ b/inc/camera.h @@ -30,7 +30,7 @@ class Camera{ void setCroppingMask(cv::Rect mask){ croppingMask = mask; }; cv::Rect getCroppingMask(){ return croppingMask; }; - void start(); + int start(); void warmUpDepthLens(); void stop(); cv::Point3f deprojectPixelToPoint(float coord[], float z1); diff --git a/src/components/camera.cpp b/src/components/camera.cpp index e38276b7c46fcbb291807a294e0a51ccfc7af5d8..05100752411533bd57f3d64840e9f1522fe9cc3e 100644 --- a/src/components/camera.cpp +++ b/src/components/camera.cpp @@ -12,12 +12,12 @@ Camera::Camera() { */ -void Camera::start(){ +int Camera::start(){ // check for a device availible if(!cfg.can_resolve(pipe)){ - std::cout << "Error: No device found" << std::endl; - exit(0); + //std::cout << "Error: No device found" << std::endl; + return 1; } std::remove("./camera.logs"); @@ -35,7 +35,8 @@ void Camera::start(){ for (auto i = range.min; i < range.max; i += range.step) if (std::string(sensor.get_option_value_description(RS2_OPTION_VISUAL_PRESET, i)) == "High Density") sensor.set_option(RS2_OPTION_VISUAL_PRESET, i); - //warmUpDepthLens(); + + return 0; }