diff options
author | Xavier Hallade <xavier.hallade@intel.com> | 2016-06-01 22:00:13 +0200 |
---|---|---|
committer | Xavier Hallade <xavier.hallade@intel.com> | 2016-06-01 22:00:13 +0200 |
commit | cd6ddb9f572dc9cc0a60b43c1c327709311c072e (patch) | |
tree | 415a5e573a15bd6fa246f9dc90fbbce62c4cdb7e /tracker-rs/ftnoir_tracker_rs_worker.cpp | |
parent | f906076ef1205387f52c03e8eed4ac2419c6d9a6 (diff) |
tracker-rs: updated to SDK 2016 R2. Added more debug information and safeguards.
Diffstat (limited to 'tracker-rs/ftnoir_tracker_rs_worker.cpp')
-rw-r--r-- | tracker-rs/ftnoir_tracker_rs_worker.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/tracker-rs/ftnoir_tracker_rs_worker.cpp b/tracker-rs/ftnoir_tracker_rs_worker.cpp index c0ea6749..0e2c86f4 100644 --- a/tracker-rs/ftnoir_tracker_rs_worker.cpp +++ b/tracker-rs/ftnoir_tracker_rs_worker.cpp @@ -8,10 +8,11 @@ #include "ftnoir_tracker_rs_worker.h" #include "rs_impl/ftnoir_tracker_rs_impl.h" #include <QImage> +#include <QDebug> RSTrackerWorkerThread::RSTrackerWorkerThread(): mPose{0,0,0,0,0,0}{ setObjectName("RSTrackerWorkerThread"); - mPreviewRawData = (uchar*)malloc(1*kPreviewStreamWidth*kPreviewStreamHeight); + mPreviewRawData = (uchar*)malloc(1*kPreviewStreamWidth*kPreviewStreamHeight); // Y8 format memset(mPreviewRawData, 125, kPreviewStreamWidth*kPreviewStreamHeight); //start with a gray image. } @@ -20,6 +21,8 @@ void RSTrackerWorkerThread::run(){ int retValue; retValue = rs_tracker_impl_start(); + qDebug() << "tracker_rs: tracking has started. retValue: " << retValue; + if(retValue==0) emit trackingHasStarted(); else { @@ -29,17 +32,23 @@ void RSTrackerWorkerThread::run(){ while(!isInterruptionRequested()){ retValue = rs_tracker_impl_update_pose(pose); - if(retValue == 0){ // success - QMutexLocker lock(&mMutex); - memcpy(mPose, pose, sizeof(pose)); - } - else if(retValue != -303){ // pose update failed and not because of a timeout (-303) - emit trackingHasFinished(retValue); - break; - } + if (retValue == 0) { // success + QMutexLocker lock(&mMutex); + memcpy(mPose, pose, sizeof(pose)); + } + else if (retValue != -303) { // pose update failed and not because of a timeout (-303) + emit trackingHasFinished(retValue); + break; + } + else + qDebug() << "tracker_rs: timeout in pose update."; } - rs_tracker_impl_end(); + qDebug() << "tracker_rs: tracking is ending. retValue: " << retValue; + + retValue = rs_tracker_impl_end(); + + qDebug() << "tracker_rs: tracking has ended. retValue: " << retValue; } void RSTrackerWorkerThread::getPose(double *pose){ @@ -48,7 +57,8 @@ void RSTrackerWorkerThread::getPose(double *pose){ } const QImage RSTrackerWorkerThread::getPreview(){ - rs_tracker_impl_get_preview(mPreviewRawData, kPreviewStreamWidth, kPreviewStreamHeight); + if(!isInterruptionRequested() && isRunning()) + rs_tracker_impl_get_preview(mPreviewRawData, kPreviewStreamWidth, kPreviewStreamHeight); return QImage((const uchar*)mPreviewRawData, kPreviewStreamWidth, kPreviewStreamHeight, QImage::Format_Grayscale8).copy();//TODO: avoid deep copy? } |