summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_HT
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-01-26 14:52:44 +0000
committerStanislaw Halik <sthalik@misaki.pl>2013-01-26 14:52:44 +0000
commit78bde487da1a9938614e3ddba2959abeb5142d93 (patch)
treee52ec1a93ce796cb65494abf778618faa078697e /FTNoIR_Tracker_HT
parent94dfe7c0ac584d02a28b804587ec291b15af8d74 (diff)
Add camera human-readable names to HT tracker. c14 please do the same PT is your turf :P
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@232 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Tracker_HT')
-rw-r--r--FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj8
-rw-r--r--FTNoIR_Tracker_HT/TrackerControls.ui51
-rw-r--r--FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp61
-rw-r--r--FTNoIR_Tracker_HT/stdafx.h5
4 files changed, 87 insertions, 38 deletions
diff --git a/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj b/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj
index 5ad20937..bf9b23c2 100644
--- a/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj
+++ b/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
Name="FTNoIR_Tracker_HT"
ProjectGUID="{61F2B142-F7DD-4070-8A68-53AD63A5D528}"
RootNamespace="FTNoIR_Tracker_HT"
@@ -121,7 +121,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;.\.GeneratedFiles&quot;"
+ AdditionalIncludeDirectories="&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;.\.GeneratedFiles;&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FTNOIR_TRACKER_HT_EXPORTS;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB"
RuntimeLibrary="2"
EnableEnhancedInstructionSet="2"
@@ -141,7 +141,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="QtCore4.lib QtGui4.lib"
+ AdditionalDependencies="QtCore4.lib QtGui4.lib Strmiids.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SolutionDir)\dinput&quot;;&quot;$(QTDIR)\lib&quot;"
GenerateDebugInformation="true"
@@ -214,7 +214,7 @@
<Tool
Name="VCCustomBuildTool"
Description="Moc&apos;ing ftnoir_tracker_ht.h..."
- CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; &quot;$(InputPath)&quot; -o &quot;.\.GeneratedFiles$(ConfigurationName)\moc_$(InputName).cpp&quot; -DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DFTNOIR_TRACKER_HT_EXPORTS -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -D_WINDLL -D_UNICODE -DUNICODE &quot;-I$(QTDIR)\include&quot; &quot;-I$(QTDIR)\include\QtCore&quot; &quot;-I$(QTDIR)\include\QtGui&quot; &quot;-I.\.GeneratedFiles&quot;&#x0D;&#x0A;"
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; &quot;$(InputPath)&quot; -o &quot;.\.GeneratedFiles$(ConfigurationName)\moc_$(InputName).cpp&quot; -DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DFTNOIR_TRACKER_HT_EXPORTS -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -D_WINDLL -D_UNICODE -DUNICODE &quot;-I$(QTDIR)\include&quot; &quot;-I$(QTDIR)\include\QtCore&quot; &quot;-I$(QTDIR)\include\QtGui&quot; &quot;-I.\.GeneratedFiles&quot; &quot;-IC:\Program Files\Microsoft SDKs\Windows\v6.0A\Include&quot;&#x0D;&#x0A;"
AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
Outputs="&quot;.\.GeneratedFiles$(ConfigurationName)\moc_$(InputName).cpp&quot;"
/>
diff --git a/FTNoIR_Tracker_HT/TrackerControls.ui b/FTNoIR_Tracker_HT/TrackerControls.ui
index 561d6118..23ae4cad 100644
--- a/FTNoIR_Tracker_HT/TrackerControls.ui
+++ b/FTNoIR_Tracker_HT/TrackerControls.ui
@@ -2,11 +2,14 @@
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>333</width>
+ <width>500</width>
<height>127</height>
</rect>
</property>
@@ -18,7 +21,7 @@
</property>
<property name="maximumSize">
<size>
- <width>378</width>
+ <width>500</width>
<height>127</height>
</size>
</property>
@@ -43,7 +46,7 @@
<rect>
<x>130</x>
<y>10</y>
- <width>91</width>
+ <width>251</width>
<height>22</height>
</rect>
</property>
@@ -78,7 +81,7 @@
<rect>
<x>130</x>
<y>40</y>
- <width>81</width>
+ <width>251</width>
<height>22</height>
</rect>
</property>
@@ -113,35 +116,13 @@
</rect>
</property>
<property name="text">
- <string>Camera index</string>
- </property>
- </widget>
- <widget class="QSpinBox" name="cameraIndex">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>70</y>
- <width>42</width>
- <height>22</height>
- </rect>
- </property>
- <property name="minimum">
- <number>-1</number>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- <property name="value">
- <number>-1</number>
+ <string>Camera name</string>
</property>
</widget>
<widget class="QPushButton" name="buttonOK">
<property name="geometry">
<rect>
- <x>170</x>
+ <x>340</x>
<y>100</y>
<width>75</width>
<height>23</height>
@@ -154,7 +135,7 @@
<widget class="QPushButton" name="buttonCancel">
<property name="geometry">
<rect>
- <x>250</x>
+ <x>420</x>
<y>100</y>
<width>75</width>
<height>23</height>
@@ -167,7 +148,7 @@
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
- <x>220</x>
+ <x>390</x>
<y>10</y>
<width>101</width>
<height>81</height>
@@ -255,6 +236,16 @@
</property>
</widget>
</widget>
+ <widget class="QComboBox" name="cameraName">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>70</y>
+ <width>251</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
</widget>
<resources/>
<connections/>
diff --git a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
index cf67c732..ff89c04d 100644
--- a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
+++ b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
@@ -11,6 +11,57 @@ static TCHAR mutexName[] = TEXT(HT_MUTEX_NAME);
#define WIDGET_WIDTH 250
#define WIDGET_HEIGHT 170
+// delicious copypasta
+static QList<QString> get_camera_names(void) {
+ QList<QString> ret;
+ // Create the System Device Enumerator.
+ HRESULT hr;
+ ICreateDevEnum *pSysDevEnum = NULL;
+ hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
+ if (FAILED(hr))
+ {
+ return ret;
+ }
+ // Obtain a class enumerator for the video compressor category.
+ IEnumMoniker *pEnumCat = NULL;
+ hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
+
+ if (hr == S_OK) {
+ // Enumerate the monikers.
+ IMoniker *pMoniker = NULL;
+ ULONG cFetched;
+ while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) {
+ IPropertyBag *pPropBag;
+ hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
+ if (SUCCEEDED(hr)) {
+ // To retrieve the filter's friendly name, do the following:
+ VARIANT varName;
+ VariantInit(&varName);
+ hr = pPropBag->Read(L"FriendlyName", &varName, 0);
+ if (SUCCEEDED(hr))
+ {
+ // Display the name in your UI somehow.
+ QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal));
+ ret.append(str);
+ }
+ VariantClear(&varName);
+
+ ////// To create an instance of the filter, do the following:
+ ////IBaseFilter *pFilter;
+ ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
+ //// (void**)&pFilter);
+ // Now add the filter to the graph.
+ //Remember to release pFilter later.
+ pPropBag->Release();
+ }
+ pMoniker->Release();
+ }
+ pEnumCat->Release();
+ }
+ pSysDevEnum->Release();
+ return ret;
+}
+
static void load_settings(ht_config_t* config, Tracker* tracker)
{
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR");
@@ -256,7 +307,7 @@ TrackerControls::TrackerControls()
{
ui.setupUi(this);
loadSettings();
- connect(ui.cameraIndex, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
@@ -285,11 +336,15 @@ void TrackerControls::Initialize(QWidget* parent)
void TrackerControls::loadSettings()
{
+ ui.cameraName->clear();
+ QList<QString> names = get_camera_names();
+ names.prepend("Any available");
+ ui.cameraName->addItems(names);
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR");
QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat );
iniFile.beginGroup( "HT-Tracker" );
- ui.cameraIndex->setValue(iniFile.value("camera-index", -1).toInt());
+ ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1);
ui.cameraFOV->setValue(iniFile.value("fov", 69).toFloat());
int fps;
switch (iniFile.value("fps", 0).toInt())
@@ -345,7 +400,7 @@ void TrackerControls::save()
break;
}
iniFile.setValue("fps", fps);
- iniFile.setValue("camera-index", ui.cameraIndex->value());
+ iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1);
iniFile.setValue("enable-rx", ui.rx->checkState());
iniFile.setValue("enable-ry", ui.ry->checkState());
iniFile.setValue("enable-rz", ui.rz->checkState());
diff --git a/FTNoIR_Tracker_HT/stdafx.h b/FTNoIR_Tracker_HT/stdafx.h
index a0c72843..9cbe1001 100644
--- a/FTNoIR_Tracker_HT/stdafx.h
+++ b/FTNoIR_Tracker_HT/stdafx.h
@@ -37,4 +37,7 @@
#include <QHBoxLayout>
#include <QTimer>
#include <QPainter>
-#include <QPaintEvent> \ No newline at end of file
+#include <QPaintEvent>
+#include <QList>
+#include <QString>
+#include <dshow.h> \ No newline at end of file