diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-13 00:45:20 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-04-13 00:45:20 +0200 |
commit | b89195cee53549704e0807a802f5f05ed5d4e87a (patch) | |
tree | 1042585a3bc0a9deabe491d5c00322736e37d99f | |
parent | c98efcbfdebd2e6ce85cb1b3b08a1bc48f3d968b (diff) |
Fix last commit, remove duplicated code
-rw-r--r-- | facetracknoir/facetracknoir.cpp | 32 | ||||
-rw-r--r-- | facetracknoir/tracker.cpp | 3 | ||||
-rw-r--r-- | facetracknoir/tracker.h | 3 | ||||
-rw-r--r-- | ftnoir_filter_accela/default-points.cpp | 38 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 22 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 3 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 19 | ||||
-rw-r--r-- | qfunctionconfigurator/functionconfig.cpp | 76 | ||||
-rw-r--r-- | qfunctionconfigurator/functionconfig.h | 4 |
9 files changed, 40 insertions, 160 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 7442940f..37f54aaa 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -740,9 +740,22 @@ void FaceTrackNoIR::startTracker( ) { delete tracker;
}
- if (GlobalPose)
- delete GlobalPose;
- GlobalPose = new HeadPoseData();
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+ GlobalPose->X.curvePtr->loadSettings(iniFile);
+ GlobalPose->Y.curvePtr->loadSettings(iniFile);
+ GlobalPose->Z.curvePtr->loadSettings(iniFile);
+ GlobalPose->Yaw.curvePtr->loadSettings(iniFile);
+ GlobalPose->Pitch.curvePtr->loadSettings(iniFile);
+ GlobalPose->Roll.curvePtr->loadSettings(iniFile);
+
+ GlobalPose->X.curvePtrAlt->loadSettings(iniFile);
+ GlobalPose->Y.curvePtrAlt->loadSettings(iniFile);
+ GlobalPose->Z.curvePtrAlt->loadSettings(iniFile);
+ GlobalPose->Yaw.curvePtrAlt->loadSettings(iniFile);
+ GlobalPose->Pitch.curvePtrAlt->loadSettings(iniFile);
+ GlobalPose->Roll.curvePtrAlt->loadSettings(iniFile);
tracker = new Tracker ( this );
@@ -788,11 +801,10 @@ void FaceTrackNoIR::startTracker( ) { // Get the TimeOut value for minimizing FaceTrackNoIR
// Only start the Timer if value > 0
//
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
- int timevalue = settings.value ( "AutoMinimizeTime", 0 ).toInt() * 1000;
+ int timevalue = iniFile.value ( "AutoMinimizeTime", 0 ).toInt() * 1000;
if (timevalue > 0) {
- bool minimizeTaskBar = settings.value ( "MinimizeTaskBar", 1 ).toBool();
+ bool minimizeTaskBar = iniFile.value ( "MinimizeTaskBar", 1 ).toBool();
if (minimizeTaskBar) {
connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized()));
}
@@ -1958,14 +1970,6 @@ void CurveConfigurationDialog::loadSettings() { iniFile.beginGroup ( "Tracking" );
iniFile.endGroup ();
- ui.rxconfig->loadSettings(currentFile);
- ui.ryconfig->loadSettings(currentFile);
- ui.rzconfig->loadSettings(currentFile);
-
- ui.rxconfig_alt->loadSettings(currentFile);
- ui.ryconfig_alt->loadSettings(currentFile);
- ui.rzconfig_alt->loadSettings(currentFile);
-
GlobalPose->Yaw.altp = iniFile.value("rx_alt", false).toBool();
GlobalPose->Pitch.altp = iniFile.value("ry_alt", false).toBool();
GlobalPose->Roll.altp = iniFile.value("rz_alt", false).toBool();
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index c3a61263..ed39765d 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -169,6 +169,8 @@ void Tracker::run() { if (Libraries->pTracker) {
bTracker1Confid = Libraries->pTracker->GiveHeadPoseData(&newpose);
}
+
+ confid = (bTracker1Confid || bTracker2Confid);
bool newp = last.yaw != newpose.yaw ||
last.pitch != newpose.pitch ||
@@ -301,7 +303,6 @@ void Tracker::run() { }
//for lower cpu load
- confid = (bTracker1Confid || bTracker2Confid);
usleep(1000);
}
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index d67fc533..e413c8d7 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -108,7 +108,8 @@ public: curvePtr = new FunctionConfig(primary, maxInput1, maxOutput1); // Create the Function-config for input-output translation
curvePtr->loadSettings(iniFile); // Load the settings from the INI-file
- if (secondary != "") {
+ if (secondary != "")
+ {
curvePtrAlt = new FunctionConfig(secondary, maxInput2, maxOutput2);
curvePtrAlt->loadSettings(iniFile);
}
diff --git a/ftnoir_filter_accela/default-points.cpp b/ftnoir_filter_accela/default-points.cpp deleted file mode 100644 index 2cebff6c..00000000 --- a/ftnoir_filter_accela/default-points.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include <QList> -#include <QPointF> - -static QList<QPointF> EmptyList() { - return QList<QPointF>(); -} - -extern const QList<QPointF> defScaleRotation, defScaleTranslation; - -const QList<QPointF> defScaleRotation = - EmptyList() - << QPointF(0, 0) - << QPointF(0.308900523560209, 0.0666666666666667) - << QPointF(0.565445026178011, 0.226666666666667) - << QPointF(0.769633507853403, 0.506666666666667) - << QPointF(0.994764397905759, 1) - << QPointF(1.23560209424084, 1.61333333333333) - << QPointF(1.47643979057592, 2.37333333333333) - << QPointF(1.66492146596859, 3.12) - << QPointF(1.80628272251309, 3.92) - << QPointF(1.91623036649215, 4.70666666666667) - << QPointF(2.00523560209424, 5.44) - << QPointF(2.07329842931937, 6) -; - -const QList<QPointF> defScaleTranslation = - EmptyList() - << QPointF(0, 0) - << QPointF(0.282722513089005, 0.08) - << QPointF(0.492146596858639, 0.306666666666667) - << QPointF(0.764397905759162, 0.84) - << QPointF(1.00523560209424, 1.62666666666667) - << QPointF(1.17277486910995, 2.78666666666667) - << QPointF(1.25130890052356, 3.6) - << QPointF(1.31937172774869, 4.29333333333333) - << QPointF(1.38219895287958, 4.90666666666667) - << QPointF(1.43455497382199, 5.65333333333333) -; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index cb9fb0f5..3e931df4 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -21,8 +21,8 @@ #endif
FTNoIR_Filter::FTNoIR_Filter() :
- functionConfig("Accela-Scaling-Rotation", 4, 6),
- translationFunctionConfig("Accela-Scaling-Translation", 4, 6)
+ functionConfig("Accela-Scaling-Rotation", 4, 6),
+ translationFunctionConfig("Accela-Scaling-Translation", 4, 6)
{
first_run = true;
kMagicNumber = 100.0f;
@@ -39,30 +39,18 @@ void FTNoIR_Filter::Initialize() }
void FTNoIR_Filter::loadSettings() {
- QList<QPointF> defPoints;
-
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- defPoints.clear();
- for (int i = 0; i < defScaleRotation.size(); i++) { // Get the default points (hardcoded!)
- defPoints.append(defScaleRotation[i]);
- }
- functionConfig.loadSettings(iniFile, defPoints);
-
- defPoints.clear();
- for (int i = 0; i < defScaleTranslation.size(); i++) { // Get the default points (hardcoded!)
- defPoints.append(defScaleTranslation[i]);
- }
- translationFunctionConfig.loadSettings(iniFile, defPoints);
+ functionConfig.loadSettings(iniFile);
+ translationFunctionConfig.loadSettings(iniFile);
iniFile.beginGroup ( "Accela" );
kMagicNumber = iniFile.value ( "Reduction", 100 ).toFloat();
kZoomSlowness = iniFile.value("zoom-slowness", 0).toFloat();
iniFile.endGroup ();
-
}
void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position,
@@ -92,8 +80,6 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, if (first_run)
{
- functionConfig.setTrackingActive(true);
- translationFunctionConfig.setTrackingActive(true);
new_camera_position->x=target[0];
new_camera_position->y=target[1];
new_camera_position->z=target[2];
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 32cebf99..701dabaa 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -34,9 +34,6 @@ #include <qfunctionconfigurator/functionconfig.h>
#include "facetracknoir/global-settings.h"
-extern const QList<QPointF> defScaleRotation;
-extern const QList<QPointF> defScaleTranslation;
-
//
// Macro to determine array-size
//
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 9970e962..f9fdcb6f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -39,8 +39,8 @@ //
FilterControls::FilterControls() :
QWidget(),
- functionConfig("Accela-Scaling-Rotation", 4, 8),
- translationFunctionConfig("Accela-Scaling-Translation", 4, 8)
+ functionConfig("Accela-Scaling-Rotation", 4, 8),
+ translationFunctionConfig("Accela-Scaling-Translation", 4, 8)
{
ui.setupUi( this );
@@ -141,8 +141,6 @@ void FilterControls::doCancel() { // Load the current Settings from the currently 'active' INI-file.
//
void FilterControls::loadSettings() {
-QList<QPointF> defPoints;
-
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
@@ -150,21 +148,8 @@ QList<QPointF> defPoints; qDebug() << "FTNoIR_Filter::loadSettings2 says: iniFile = " << currentFile;
-
//qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation);
- defPoints.clear();
- for (int i = 0; i < defScaleRotation.size(); i++) { // Get the default points (hardcoded!)
- defPoints.append(defScaleRotation[i]);
- }
- functionConfig.loadSettings(iniFile, defPoints);
-
- defPoints.clear();
- for (int i = 0; i < defScaleTranslation.size(); i++) { // Get the default points (hardcoded!)
- defPoints.append(defScaleTranslation[i]);
- }
- translationFunctionConfig.loadSettings(iniFile, defPoints);
-
ui.translationScalingConfig->setConfig(&translationFunctionConfig, currentFile);
ui.scalingConfig->setConfig(&functionConfig, currentFile);
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 25d5599a..1c03aa92 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -6,6 +6,7 @@ * notice appear in all copies.
*/
+#include <QCoreApplication>
#include <QPointF>
#include <QList>
#include "functionconfig.h"
@@ -19,32 +20,21 @@ //
// Constructor with List of Points in argument.
//
-FunctionConfig::FunctionConfig(QString title, QList<QPointF> points, int intMaxInput, int intMaxOutput) :
+FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) :
_mutex(QMutex::Recursive)
{
_title = title;
- _points = points;
- _data = 0;
- _size = 0;
- lastValueTracked = QPointF(0,0);
- _tracking_active = false;
- _max_Input = intMaxInput; // Added WVR 20120805
- _max_Output = intMaxOutput;
- reload();
-}
-
-//
-// Constructor with only Title in arguments.
-//
-FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) {
- _title = title;
- _points = QList<QPointF>();
+ _points = QList<QPointF>();
_data = 0;
_size = 0;
lastValueTracked = QPointF(0,0);
_tracking_active = false;
_max_Input = intMaxInput; // Added WVR 20120805
_max_Output = intMaxOutput;
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat );
+ loadSettings(iniFile);
reload();
}
@@ -223,12 +213,15 @@ QList<QPointF> FunctionConfig::getPoints() { // Settings for a specific Curve are loaded from their own Group in the INI-file.
//
void FunctionConfig::loadSettings(QSettings& settings) {
-QPointF newPoint;
+ QPointF newPoint;
QList<QPointF> points;
settings.beginGroup(QString("Curves-%1").arg(_title));
int max = settings.value("point-count", 0).toInt();
+
+ qDebug() << _title << "count" << max;
+
for (int i = 0; i < max; i++) {
newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(),
settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat());
@@ -252,53 +245,6 @@ QPointF newPoint; }
//
-// Load the Points for the Function from the INI-file designated by settings.
-// Settings for a specific Curve are loaded from their own Group in the INI-file.
-//
-// A default List of points is available in defPoints, to be used if "point-count" is missing completely.
-//
-void FunctionConfig::loadSettings(QSettings& settings, QList<QPointF>& defPoints) {
-QPointF newPoint;
-
- QList<QPointF> points;
- settings.beginGroup(QString("Curves-%1").arg(_title));
-
- qDebug() << "FunctionConfig::loadSettings2 title = " << _title;
-
- //
- // Read the number of points, that was last saved. Default to defPoints, if key doesn't exist.
- //
- int max = settings.value("point-count", 0).toInt();
- if (max <= 0) {
- qDebug() << "FunctionConfig::loadSettings2 number of points = " << defPoints.count();
- points = defPoints;
- }
- else {
- qDebug() << "FunctionConfig::loadSettings2 max = " << max;
- for (int i = 0; i < max; i++) {
- newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(),
- settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat());
- //
- // Make sure the new Point fits in the Function Range.
- // Maybe this can be improved?
- //
- if (newPoint.x() > _max_Input) {
- newPoint.setX(_max_Input);
- }
- if (newPoint.y() > _max_Output) {
- newPoint.setY(_max_Output);
- }
- points.append(newPoint);
- }
- }
- settings.endGroup();
- _mutex.lock();
- _points = points;
- reload();
- _mutex.unlock();
-}
-
-//
// Save the Points for the Function to the INI-file designated by settings.
// Settings for a specific Curve are saved in their own Group in the INI-file.
// The number of Points is also saved, to make loading more convenient.
diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 9f380000..e96d7ffc 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -36,8 +36,7 @@ public: //
// Contructor(s) and destructor
//
- FunctionConfig(QString title, QList<QPointF> points, int intMaxInput, int intMaxOutput);
- FunctionConfig(QString title, int intMaxInput, int intMaxOutput);
+ FunctionConfig(QString title, int intMaxInput, int intMaxOutput);
virtual ~FunctionConfig();
float getValue(float x);
@@ -62,7 +61,6 @@ public: //
void saveSettings(QSettings& settings);
void loadSettings(QSettings& settings);
- void loadSettings(QSettings& settings, QList<QPointF>& defPoints);
void setTrackingActive(bool blnActive) {
_tracking_active = blnActive;
|