Skip to content
Snippets Groups Projects
Commit 10e5c7ff authored by simon.fanetti's avatar simon.fanetti
Browse files

check for connected device in InitCamera

parent d0526fb9
Branches
No related tags found
No related merge requests found
...@@ -9,9 +9,13 @@ CameraStartThread::CameraStartThread(Camera *c) : QThread() { ...@@ -9,9 +9,13 @@ CameraStartThread::CameraStartThread(Camera *c) : QThread() {
void CameraStartThread::run() { void CameraStartThread::run() {
camera->start(); int err = camera->start();
camera->warmUpDepthLens(); emit deviceFound(err);
emit setupReady();
if(!err){
camera->warmUpDepthLens();
emit setupReady(0);
}
} }
...@@ -25,6 +29,7 @@ InitCamera::InitCamera(SandboxSetup *_setup, QWidget *parent) : ...@@ -25,6 +29,7 @@ InitCamera::InitCamera(SandboxSetup *_setup, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
workerThread = new CameraStartThread(setup->getCamera()); workerThread = new CameraStartThread(setup->getCamera());
connect(workerThread, &CameraStartThread::deviceFound, this, &InitCamera::deviceFound);
connect(workerThread, &CameraStartThread::setupReady, this, &InitCamera::setupReady); connect(workerThread, &CameraStartThread::setupReady, this, &InitCamera::setupReady);
connect(workerThread, &CameraStartThread::finished, workerThread, &QObject::deleteLater); connect(workerThread, &CameraStartThread::finished, workerThread, &QObject::deleteLater);
} }
...@@ -48,8 +53,17 @@ void InitCamera::setupCamera(){ ...@@ -48,8 +53,17 @@ void InitCamera::setupCamera(){
workerThread->start(); workerThread->start();
} }
void InitCamera::setupReady(){ void InitCamera::deviceFound(int err){
emit sendNotif(0); 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);
} }
...@@ -21,7 +21,8 @@ public: ...@@ -21,7 +21,8 @@ public:
void run(); void run();
signals: signals:
void setupReady(); void setupReady(int state);
void deviceFound(int err);
private: private:
Camera *camera; Camera *camera;
...@@ -46,7 +47,8 @@ private: ...@@ -46,7 +47,8 @@ private:
CameraStartThread *workerThread; CameraStartThread *workerThread;
void setupCamera(); void setupCamera();
void setupReady(); void setupReady(int state);
void deviceFound(int err);
}; };
#endif // INITCAMERA_H #endif // INITCAMERA_H
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Initializing camera...</string> <string>Checking camera...</string>
</property> </property>
</widget> </widget>
</widget> </widget>
......
...@@ -64,8 +64,12 @@ void MainWindow::receiveNotif(int state){ ...@@ -64,8 +64,12 @@ void MainWindow::receiveNotif(int state){
// active app : InitCamera // active app : InitCamera
if( strcmp( applist.at(step)->metaObject()->className(), init->metaObject()->className() ) == 0 ){ if( strcmp( applist.at(step)->metaObject()->className(), init->metaObject()->className() ) == 0 ){
ui->btnNext->setVisible(true); if(state){
nextApp(); ui->btnFinish->setVisible(true);
}else{
ui->btnNext->setVisible(true);
nextApp();
}
} }
// active app : BeamerLocation // active app : BeamerLocation
else if( strcmp( applist.at(step)->metaObject()->className(), bl->metaObject()->className() ) == 0 ){ else if( strcmp( applist.at(step)->metaObject()->className(), bl->metaObject()->className() ) == 0 ){
......
...@@ -30,7 +30,7 @@ class Camera{ ...@@ -30,7 +30,7 @@ class Camera{
void setCroppingMask(cv::Rect mask){ croppingMask = mask; }; void setCroppingMask(cv::Rect mask){ croppingMask = mask; };
cv::Rect getCroppingMask(){ return croppingMask; }; cv::Rect getCroppingMask(){ return croppingMask; };
void start(); int start();
void warmUpDepthLens(); void warmUpDepthLens();
void stop(); void stop();
cv::Point3f deprojectPixelToPoint(float coord[], float z1); cv::Point3f deprojectPixelToPoint(float coord[], float z1);
......
...@@ -12,12 +12,12 @@ Camera::Camera() { ...@@ -12,12 +12,12 @@ Camera::Camera() {
*/ */
void Camera::start(){ int Camera::start(){
// check for a device availible // check for a device availible
if(!cfg.can_resolve(pipe)){ if(!cfg.can_resolve(pipe)){
std::cout << "Error: No device found" << std::endl; //std::cout << "Error: No device found" << std::endl;
exit(0); return 1;
} }
std::remove("./camera.logs"); std::remove("./camera.logs");
...@@ -35,7 +35,8 @@ void Camera::start(){ ...@@ -35,7 +35,8 @@ void Camera::start(){
for (auto i = range.min; i < range.max; i += range.step) 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") if (std::string(sensor.get_option_value_description(RS2_OPTION_VISUAL_PRESET, i)) == "High Density")
sensor.set_option(RS2_OPTION_VISUAL_PRESET, i); sensor.set_option(RS2_OPTION_VISUAL_PRESET, i);
//warmUpDepthLens();
return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment