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
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......@@ -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
......@@ -23,7 +23,7 @@
</rect>
</property>
<property name="text">
<string>Initializing camera...</string>
<string>Checking camera...</string>
</property>
</widget>
</widget>
......
......@@ -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 ){
......
......@@ -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);
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment