stop device correctly

parent d47ca0b0
......@@ -24,6 +24,7 @@
#include <unistd.h>
#include <stdio.h>
#include <thread>
using namespace std;
using namespace cv;
......@@ -44,6 +45,7 @@ std::function<void(std::string, int)> *faceCheckCallback;
FaceDetection::Mode newMode;
bool started=false;
bool looping=false;
struct facePosition {int x, y, width, height; };
......@@ -71,7 +73,7 @@ void FaceDetector::Start(
faceCheckCallback = &checkCallback;
faceFrameReadyCallback = &faceCallback;
if(!started)
if (!looping)
{
started = true;
Loop();
......@@ -80,8 +82,9 @@ void FaceDetector::Start(
///
///
void FaceDetector::Stop() {
started=false;
void FaceDetector::Stop()
{
started = false;
}
///
......@@ -145,6 +148,7 @@ int Loop()
device->start();
int trainClock = 0;
looping = true;
while (started)
{
FaceDetection::Mode currentMode = newMode;
......@@ -251,7 +255,7 @@ int Loop()
{
writePLY(model, filename.c_str());
printf("train switch, filename: %s\n",filename.c_str());
printf("train switch, filename: %s\n", filename.c_str());
(*faceSaveCallback)(filename);
printf("callback fired");
newMode = IDLE;
......@@ -282,7 +286,18 @@ int Loop()
}
}
if (device->is_streaming())
device->stop();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
for (int j = 0; j < 4; ++j)
{
auto s = (rs::stream) j;
if (device->is_stream_enabled(s)) device->disable_stream(s);
}
looping = false;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment