summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2011-02-04 15:07:16 +0000
committerWim Vriend <facetracknoir@gmail.com>2011-02-04 15:07:16 +0000
commit4acd072afb9cc76231b1d666d933f3dbbb4b3baa (patch)
tree3b3464d8a81c990bf6446af4d7e850a001a2c2b1
parent6a168be69e38cbfba522666ced2fb3f6579b0f29 (diff)
Testing Client/Server configuration.
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@47 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
-rw-r--r--FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp12
-rw-r--r--FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj4
-rw-r--r--FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp117
-rw-r--r--FaceTrackNoIR.suobin334848 -> 343552 bytes
-rw-r--r--FaceTrackNoIR/FTNoIR_FGcontrols.ui10
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.ui3
-rw-r--r--bin/FaceTrackNoIR.exebin757760 -> 757760 bytes
7 files changed, 107 insertions, 39 deletions
diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
index 4748f879..957f5aec 100644
--- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
+++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
@@ -186,16 +186,16 @@ void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_posit
//calculate the alphas
//work out the dynamic smoothing factors
- if (newTarget) {
+// if (newTarget) {
for (i=0;i<6;i++)
{
alpha[i]=1.0f/(parameterValueAsFloat[kMinSmoothing]+((1.0f-pow(norm_output_delta[i],parameterValueAsFloat[kSmoothingScaleCurve]))*smoothing_frames_range));
smoothed_alpha[i]=(alpha_smoothing*alpha[i])+((1.0f-alpha_smoothing)*prev_alpha[i]);
}
- }
+// }
- qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range;
- qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() alpha[3] = " << alpha[3];
+ //qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range;
+ //qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() alpha[3] = " << alpha[3];
//use the same (largest) smoothed alpha for each channel
//NB: larger alpha = *less* lag (opposite to what you'd expect)
@@ -211,8 +211,8 @@ void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_posit
//move the camera
for (i=0;i<6;i++)
{
-// output[i]=(largest_alpha*target[i])+((1.0f-largest_alpha)*prev_output[i]);
- output[i]=(smoothed_alpha[i]*target[i])+((1.0f-smoothed_alpha[i])*prev_output[i]);
+ output[i]=(largest_alpha*target[i])+((1.0f-largest_alpha)*prev_output[i]);
+// output[i]=(smoothed_alpha[i]*target[i])+((1.0f-smoothed_alpha[i])*prev_output[i]);
}
new_camera_position->x=output[0];
diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj
index d5df6fc0..55e6d66b 100644
--- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj
+++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj
@@ -38,7 +38,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".\GeneratedFiles;&quot;$(QTDIR)\include&quot;;&quot;.\GeneratedFiles\$(ConfigurationName)&quot;;&quot;$(QTDIR)\include\qtmain&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;.\"
+ AdditionalIncludeDirectories=".\GeneratedFiles;&quot;$(QTDIR)\include&quot;;&quot;.\GeneratedFiles\$(ConfigurationName)&quot;;&quot;$(QTDIR)\include\qtmain&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;&quot;$(QTDIR)\include\QtGui&quot;;.\"
PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB"
RuntimeLibrary="2"
TreatWChar_tAsBuiltInType="false"
@@ -55,7 +55,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="qtmain.lib QtCore4.lib QtNetwork4.lib"
+ AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib QtNetwork4.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
AdditionalLibraryDirectories="$(QTDIR)\lib"
GenerateDebugInformation="false"
diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp
index d3c67d71..9dfb26a7 100644
--- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp
+++ b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp
@@ -1,7 +1,9 @@
#include "ftnoir_tracker_base.h"
#include <QThread>
#include <QUdpSocket>
+#include <QMessageBox>
#include "Windows.h"
+#include "math.h"
class FTNoIR_Tracker_UDP : public ITracker, QThread
{
@@ -14,6 +16,8 @@ public:
void StartTracker();
void GiveHeadPoseData(THeadPoseData *data);
+ bool setParameterValue(const int index, const float newvalue);
+
protected:
void run(); // qthread override run method
@@ -31,6 +35,16 @@ private:
int srcPort; // Source port-number
THeadPoseData newHeadPose; // Structure with new headpose
+
+ //parameter list for the filter-function(s)
+ enum
+ {
+ kPortAddress=0, // Index in QList
+ kNumFilterParameters // Indicate number of parameters used
+ };
+ QList<std::pair<float,float>> parameterRange;
+ QList<float> parameterValueAsFloat;
+
};
FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP()
@@ -42,12 +56,38 @@ FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP()
m_StopThread = CreateEvent(0, TRUE, FALSE, 0);
m_WaitThread = CreateEvent(0, TRUE, FALSE, 0);
- newHeadPose.x = 1.0f;
- newHeadPose.y = 2.0f;
- newHeadPose.z = 3.0f;
- newHeadPose.yaw = 4.0f;
- newHeadPose.pitch = 5.0f;
- newHeadPose.roll = 6.0f;
+ //allocate memory for the parameters
+ parameterValueAsFloat.clear();
+ parameterRange.clear();
+
+ // Add the parameters to the list
+ parameterRange.append(std::pair<float,float>(1000.0f,9999.0f));
+ parameterValueAsFloat.append(0.0f);
+ setParameterValue(kPortAddress,5551.0f);
+
+ newHeadPose.x = 0.0f;
+ newHeadPose.y = 0.0f;
+ newHeadPose.z = 0.0f;
+ newHeadPose.yaw = 0.0f;
+ newHeadPose.pitch = 0.0f;
+ newHeadPose.roll = 0.0f;
+
+ //
+ // Create UDP-sockets if they don't exist already.
+ // They must be created here, because they must be in the new thread (FTNoIR_Tracker_UDP::run())
+ //
+ if (inSocket == 0) {
+ qDebug() << "FTNoIR_Tracker_UDP::run() creating insocket";
+ inSocket = new QUdpSocket();
+ // Connect the inSocket to the port, to receive messages
+
+ if (!inSocket->bind(QHostAddress::Any, (int) parameterValueAsFloat[kPortAddress], QUdpSocket::ShareAddress )) {
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
+ delete inSocket;
+ inSocket = 0;
+ }
+ }
+
}
FTNoIR_Tracker_UDP::~FTNoIR_Tracker_UDP()
@@ -83,17 +123,6 @@ QHostAddress sender;
quint16 senderPort;
//
- // Create UDP-sockets if they don't exist already.
- // They must be created here, because they must be in the new thread (FTNoIR_Tracker_UDP::run())
- //
- if (inSocket == 0) {
- qDebug() << "FTNoIR_Tracker_UDP::run() creating insocket";
- inSocket = new QUdpSocket();
- // Connect the inSocket to the port, to receive messages
- inSocket->bind(QHostAddress::Any, destPort+1);
- }
-
- //
// Read the data that was received.
//
forever {
@@ -107,18 +136,23 @@ quint16 senderPort;
return;
}
- while (inSocket->hasPendingDatagrams()) {
+ if (inSocket != 0) {
+ while (inSocket->hasPendingDatagrams()) {
- QByteArray datagram;
- datagram.resize(inSocket->pendingDatagramSize());
+ QByteArray datagram;
+ datagram.resize(inSocket->pendingDatagramSize());
- inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort);
+ inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort);
+ }
+ }
+ else {
+ qDebug() << "FTNoIR_Tracker_UDP::run() insocket not ready: exit run()";
+ return;
}
//for lower cpu load
- usleep(5000);
+ usleep(10000);
yieldCurrentThread();
-
}
}
@@ -140,14 +174,6 @@ void FTNoIR_Tracker_UDP::StartTracker()
void FTNoIR_Tracker_UDP::GiveHeadPoseData(THeadPoseData *data)
{
-
- //newHeadPose.x += 1.0f;
- //newHeadPose.y += 2.0f;
- //newHeadPose.z += 3.0f;
- //newHeadPose.yaw += 4.0f;
- //newHeadPose.pitch += 5.0f;
- //newHeadPose.roll += 6.0f;
-
data->x = newHeadPose.x;
data->y = newHeadPose.y;
data->z = newHeadPose.z;
@@ -157,6 +183,35 @@ void FTNoIR_Tracker_UDP::GiveHeadPoseData(THeadPoseData *data)
return;
}
+bool FTNoIR_Tracker_UDP::setParameterValue(const int index, const float newvalue)
+{
+ if ((index >= 0) && (index < parameterValueAsFloat.size()))
+ {
+ //
+ // Limit the new value, using the defined range.
+ //
+ if (newvalue < parameterRange[index].first) {
+ parameterValueAsFloat[index] = parameterRange[index].first;
+ }
+ else {
+ if (newvalue > parameterRange[index].second) {
+ parameterValueAsFloat[index] = parameterRange[index].second;
+ }
+ else {
+ parameterValueAsFloat[index] = newvalue;
+ }
+ }
+
+// updateParameterString(index);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+};
+
+
////////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Tracker object.
diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo
index d5744f58..ff1e1575 100644
--- a/FaceTrackNoIR.suo
+++ b/FaceTrackNoIR.suo
Binary files differ
diff --git a/FaceTrackNoIR/FTNoIR_FGcontrols.ui b/FaceTrackNoIR/FTNoIR_FGcontrols.ui
index 270a0ee5..5f5d1563 100644
--- a/FaceTrackNoIR/FTNoIR_FGcontrols.ui
+++ b/FaceTrackNoIR/FTNoIR_FGcontrols.ui
@@ -259,6 +259,16 @@
</item>
</layout>
</widget>
+ <tabstops>
+ <tabstop>spinIPFirstNibble</tabstop>
+ <tabstop>spinIPSecondNibble</tabstop>
+ <tabstop>spinIPThirdNibble</tabstop>
+ <tabstop>spinIPFourthNibble</tabstop>
+ <tabstop>spinPortNumber</tabstop>
+ <tabstop>btnOK</tabstop>
+ <tabstop>btnCancel</tabstop>
+ <tabstop>chkLocalPC</tabstop>
+ </tabstops>
<resources/>
<connections/>
<slots>
diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui
index 698929cb..25adf15f 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.ui
+++ b/FaceTrackNoIR/FaceTrackNoIR.ui
@@ -1191,6 +1191,9 @@ background:none;</string>
<property name="styleSheet">
<string notr="true">background:none;</string>
</property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
<property name="maximum">
<number>50</number>
</property>
diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe
index 191feaa9..e98c084a 100644
--- a/bin/FaceTrackNoIR.exe
+++ b/bin/FaceTrackNoIR.exe
Binary files differ