From 4f00c4c74d213a37a4b1a3313e50ce2b4dd51271 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Mar 2013 21:48:15 +0100 Subject: finish rename --- ftnoir_tracker_ht/Tracker.qrc | 5 - ftnoir_tracker_ht/TrackerControls.ui | 295 ------------------ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 422 -------------------------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 80 ----- ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h | 20 -- ftnoir_tracker_ht/headtracker-ftnoir.h | 24 -- ftnoir_tracker_ht/ht-api.h | 85 ------ ftnoir_tracker_ht/images/HT.ico | Bin 15086 -> 0 bytes ftnoir_tracker_ht/images/xxx_ht.ico | Bin 0 -> 15086 bytes ftnoir_tracker_ht/stdafx.h | 14 - ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.cpp | 422 ++++++++++++++++++++++++++ ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.h | 80 +++++ ftnoir_tracker_ht/xxx_ftnoir_tracker_ht_dll.h | 20 ++ ftnoir_tracker_ht/xxx_headtracker-ftnoir.h | 24 ++ ftnoir_tracker_ht/xxx_ht-api.h | 85 ++++++ ftnoir_tracker_ht/xxx_stdafx.h | 14 + ftnoir_tracker_ht/xxx_tracker.qrc | 5 + ftnoir_tracker_ht/xxx_trackercontrols.ui | 295 ++++++++++++++++++ 18 files changed, 945 insertions(+), 945 deletions(-) delete mode 100644 ftnoir_tracker_ht/Tracker.qrc delete mode 100644 ftnoir_tracker_ht/TrackerControls.ui delete mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht.cpp delete mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht.h delete mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h delete mode 100644 ftnoir_tracker_ht/headtracker-ftnoir.h delete mode 100644 ftnoir_tracker_ht/ht-api.h delete mode 100644 ftnoir_tracker_ht/images/HT.ico create mode 100644 ftnoir_tracker_ht/images/xxx_ht.ico delete mode 100644 ftnoir_tracker_ht/stdafx.h create mode 100644 ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.cpp create mode 100644 ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.h create mode 100644 ftnoir_tracker_ht/xxx_ftnoir_tracker_ht_dll.h create mode 100644 ftnoir_tracker_ht/xxx_headtracker-ftnoir.h create mode 100644 ftnoir_tracker_ht/xxx_ht-api.h create mode 100644 ftnoir_tracker_ht/xxx_stdafx.h create mode 100644 ftnoir_tracker_ht/xxx_tracker.qrc create mode 100644 ftnoir_tracker_ht/xxx_trackercontrols.ui (limited to 'ftnoir_tracker_ht') diff --git a/ftnoir_tracker_ht/Tracker.qrc b/ftnoir_tracker_ht/Tracker.qrc deleted file mode 100644 index 9627f700..00000000 --- a/ftnoir_tracker_ht/Tracker.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/HT.ico - - diff --git a/ftnoir_tracker_ht/TrackerControls.ui b/ftnoir_tracker_ht/TrackerControls.ui deleted file mode 100644 index 0a1bc3ae..00000000 --- a/ftnoir_tracker_ht/TrackerControls.ui +++ /dev/null @@ -1,295 +0,0 @@ - - - Form - - - Qt::NonModal - - - - 0 - 0 - 500 - 160 - - - - - 0 - 0 - - - - - 500 - 160 - - - - HT tracker settings - - - - - 10 - 10 - 141 - 16 - - - - Horizontal field of view - - - - - - 130 - 10 - 251 - 22 - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 69.000000000000000 - - - - - - 10 - 40 - 101 - 16 - - - - Frames per second - - - - - - 130 - 40 - 251 - 22 - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - - - 10 - 70 - 71 - 16 - - - - Camera name - - - - - - 340 - 130 - 75 - 23 - - - - OK - - - - - - 420 - 130 - 75 - 23 - - - - Cancel - - - - - - 390 - 10 - 101 - 81 - - - - Enable axes - - - - - 10 - 20 - 70 - 17 - - - - RX - - - - - - 10 - 40 - 70 - 17 - - - - RY - - - - - - 10 - 60 - 70 - 17 - - - - RZ - - - - - - 60 - 20 - 70 - 17 - - - - TX - - - - - - 60 - 40 - 70 - 17 - - - - TY - - - - - - 60 - 60 - 70 - 17 - - - - TZ - - - - - - - 130 - 70 - 251 - 22 - - - - - - - 10 - 100 - 61 - 16 - - - - Resolution - - - - - - 130 - 100 - 251 - 22 - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp deleted file mode 100644 index 336ede2d..00000000 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ /dev/null @@ -1,422 +0,0 @@ -#include "stdafx.h" -#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "headtracker-ftnoir.h" -#include "ftnoir_tracker_ht.h" -#include "ftnoir_tracker_ht_dll.h" -#include "ui_trackercontrols.h" -#include "../facetracknoir/global-settings.h" - -#define WIDGET_WIDTH 250 -#define WIDGET_HEIGHT 188 - -#if defined(_WIN32) || defined(__WIN32) -#include -#else -#include -#endif - -// delicious copypasta -static QList get_camera_names(void) { - QList ret; -#if defined(_WIN32) || defined(__WIN32) - // 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(); -#else - for (int i = 0; i < 16; i++) { - char buf[128]; - sprintf(buf, "/dev/video%d", i); - if (access(buf, R_OK | W_OK) == 0) { - ret.append(buf); - } else { - break; - } - } -#endif - return ret; -} - -typedef struct { - int width; - int height; -} resolution_tuple; - -static resolution_tuple resolution_choices[] = { - { 0, 0 }, - { 640, 480 }, - { 320, 240 }, - { 320, 200 }, - { 0, 0 } -}; - -static void load_settings(ht_config_t* config, Tracker* tracker) -{ - 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" ); - config->classification_delay = 4000; - config->field_of_view = iniFile.value("fov", 69).toFloat(); - config->pyrlk_pyramids = 3; - config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 250; - config->keypoint_quality = 12; - config->keypoint_distance = 2.3f; - config->keypoint_3distance = 6; - //config->force_width = 640; - //config->force_height = 480; - config->force_fps = iniFile.value("fps", 0).toInt(); - config->camera_index = iniFile.value("camera-index", -1).toInt(); - config->ransac_num_iters = 100; - config->ransac_max_reprojection_error = 6.5f; - config->ransac_max_inlier_error = 6.5f; - config->ransac_max_mean_error = 4.0f; - config->ransac_abs_max_mean_error = 7.0f; - config->debug = 0; - config->ransac_min_features = 0.75f; - int res = iniFile.value("resolution", 0).toInt(); - if (res < 0 || res >= (int)(sizeof(*resolution_choices) / sizeof(resolution_tuple))) - res = 0; - resolution_tuple r = resolution_choices[res]; - config->force_width = r.width; - config->force_height = r.height; - if (tracker) - { - tracker->enableRX = iniFile.value("enable-rx", true).toBool(); - tracker->enableRY = iniFile.value("enable-ry", true).toBool(); - tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); - tracker->enableTX = iniFile.value("enable-tx", true).toBool(); - tracker->enableTY = iniFile.value("enable-ty", true).toBool(); - tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); - } - iniFile.endGroup(); -} - -Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fresh(false) -{ - videoWidget = NULL; - layout = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - shm = (ht_shm_t*) lck_shm.mem; - shm->terminate = 0; - load_settings(&shm->config, this); - shm->result.filled = false; -} - -Tracker::~Tracker() -{ - subprocess.kill(); - if (shm) - shm->terminate = true; - if (layout) - delete layout; - if (videoWidget) - delete videoWidget; -} - -void Tracker::StartTracker(QFrame* videoframe) -{ - videoframe->setAttribute(Qt::WA_NativeWindow); - videoframe->show(); - videoWidget = new VideoWidget(videoframe); - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(videoWidget); - if (videoframe->layout()) - delete videoframe->layout(); - videoframe->setLayout(layout); - videoWidget->resize(WIDGET_WIDTH, WIDGET_HEIGHT); - videoWidget->show(); - this->layout = layout; - load_settings(&shm->config, this); - shm->frame.channels = shm->frame.width = shm->frame.height = 0; - shm->pause = shm->terminate = shm->running = false; - shm->timer = 0; - subprocess.setWorkingDirectory(QCoreApplication::applicationDirPath() + "/tracker-ht"); -#if defined(_WIN32) || defined(__WIN32) - subprocess.start("\"" + QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir" + "\""); -#else - subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); -#endif - connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); - timer.start(15); -} - -void Tracker::paint_widget() { - if (fresh) { - fresh = false; - videoWidget->update(); - } -} - -bool Tracker::GiveHeadPoseData(THeadPoseData* data) -{ - bool ret = false; - - lck_shm.lock(); - shm->timer = 0; - if (shm->frame.width > 0) - { - videoWidget->updateImage(shm->frame.frame, shm->frame.width, shm->frame.height); - //memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3); - fresh = true; - } - if (shm->result.filled) { - if (enableRX) - data->yaw = shm->result.rotx; - if (enableRY) - data->pitch = shm->result.roty; - if (enableRZ) - data->roll = shm->result.rotz; - if (enableTX) - data->x = shm->result.tx; - if (enableTY) - data->y = shm->result.ty; - if (enableTZ) - data->z = shm->result.tz; - ret = true; - } - lck_shm.unlock(); - - return ret; -} - -//----------------------------------------------------------------------------- -void TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = "HT 0.7"; -} - -void TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = "HT"; -} - -void TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = ""; -} - -void TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/ht.png"); -} - - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new TrackerDll; -} - -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor() -{ - return (ITracker*) new Tracker; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetDialog( ) -{ - return (ITrackerDialog*) new TrackerControls; -} - -TrackerControls::TrackerControls() -{ - ui.setupUi(this); - loadSettings(); - 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))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); - settingsDirty = false; -} - -TrackerControls::~TrackerControls() -{ -} - -void TrackerControls::showEvent(QShowEvent *event) -{ -} - -void TrackerControls::Initialize(QWidget* parent) -{ - show(); -} - -void TrackerControls::loadSettings() -{ - ui.cameraName->clear(); - QList 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.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()) - { - default: - case 0: - fps = 0; - break; - case 30: - fps = 1; - break; - case 60: - fps = 2; - break; - case 120: - fps = 3; - break; - } - ui.cameraFPS->setCurrentIndex(fps); - ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::save() -{ - 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" ); - iniFile.setValue("fov", ui.cameraFOV->value()); - int fps; - switch (ui.cameraFPS->currentIndex()) - { - case 0: - default: - fps = 0; - break; - case 1: - fps = 30; - break; - case 2: - fps = 60; - break; - case 3: - fps = 120; - break; - } - iniFile.setValue("fps", fps); - iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); - iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::doOK() -{ - save(); - this->close(); -} - -void TrackerControls::doCancel() -{ - if (settingsDirty) { - int ret = QMessageBox::question ( this, - "Settings have changed", - "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, - QMessageBox::Discard ); - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h deleted file mode 100644 index 1a449dca..00000000 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef FTNOIR_TRACKER_HT_H -#define FTNOIR_TRACKER_HT_H - -#include "stdafx.h" -#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "headtracker-ftnoir.h" -#include "ui_trackercontrols.h" -#include "video_widget.h" -#include "../compat/compat.h" -#include -#include - -class Tracker : public QObject, public ITracker -{ - Q_OBJECT -public: - Tracker(); - ~Tracker(); - void StartTracker(QFrame* frame); - bool GiveHeadPoseData(THeadPoseData *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - ht_shm_t* shm; - bool NeedsTimeToFinish() { - return true; - } - void WaitForExit() { - if (shm) { - shm->terminate = true; - subprocess.waitForFinished(5000); - } - subprocess.kill(); - } -private: - QTimer timer; - PortableLockedShm lck_shm; - QProcess subprocess; - VideoWidget* videoWidget; - QHBoxLayout* layout; - volatile bool fresh; -private slots: - void paint_widget(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls : public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; - -private: - Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; - void settingChanged(double) { settingsDirty = true; }; -}; - -#endif - diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h deleted file mode 100644 index f3bfd381..00000000 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2013 Stanisław Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "../facetracknoir/global-settings.h" - -//----------------------------------------------------------------------------- -class TrackerDll : public Metadata -{ - // ITrackerDll interface - void Initialize() {} - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); -}; diff --git a/ftnoir_tracker_ht/headtracker-ftnoir.h b/ftnoir_tracker_ht/headtracker-ftnoir.h deleted file mode 100644 index 48510997..00000000 --- a/ftnoir_tracker_ht/headtracker-ftnoir.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include "ht-api.h" - -#define HT_SHM_NAME "ftnoir-tracker-ht-shm" -#define HT_MUTEX_NAME "ftnoir-tracker-ht-mutex" - -#define HT_MAX_VIDEO_WIDTH 2048 -#define HT_MAX_VIDEO_HEIGHT 1536 -#define HT_MAX_VIDEO_CHANNELS 3 - -typedef struct { - int width, height, channels; - unsigned char frame[HT_MAX_VIDEO_WIDTH * HT_MAX_VIDEO_HEIGHT * HT_MAX_VIDEO_CHANNELS]; -} ht_video_t; - -typedef struct { - ht_video_t frame; - ht_config_t config; - ht_result_t result; - volatile int timer; - volatile bool pause, terminate, running; -} ht_shm_t; diff --git a/ftnoir_tracker_ht/ht-api.h b/ftnoir_tracker_ht/ht-api.h deleted file mode 100644 index ac8d45cf..00000000 --- a/ftnoir_tracker_ht/ht-api.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once -#ifndef HT_API -#ifndef __cplusplus -# define HT_EXTERN -#else -# define HT_EXTERN extern "C" -#endif -# if defined(_WIN32) && !defined(MINGW) -# define HT_API(t) HT_EXTERN __declspec(dllexport) t __stdcall -# else -# define HT_API(t) HT_EXTERN t -# endif -#endif -#if !defined(_WIN32) && !defined(_isnan) -# define _isnan isnan -#endif -#include -struct ht_context; -typedef struct ht_context headtracker_t; - -typedef struct ht_config { - float field_of_view; - float classification_delay; - int pyrlk_pyramids; - int pyrlk_win_size_w; - int pyrlk_win_size_h; - float ransac_max_inlier_error; - float ransac_max_reprojection_error; - int max_keypoints; - int keypoint_quality; - float keypoint_distance; - float keypoint_3distance; - int force_width; - int force_height; - int force_fps; - int camera_index; - bool debug; - int ransac_num_iters; - float ransac_min_features; - float ransac_max_mean_error; - float ransac_abs_max_mean_error; -} ht_config_t; - -typedef struct { - double rotx, roty, rotz; - double tx, ty, tz; - bool filled; -} ht_result_t; - -typedef enum { - cfg_type_float = 0, - cfg_type_int = 1, - cfg_type_bool = 2, - cfg_type_double = 3 -} ht_cfg_type_t; - -typedef union -{ - double d; - float f; - int i; -} ht_cfg_value_t; - -typedef struct { - const char* name; - int offset; - ht_cfg_type_t type; - ht_cfg_value_t default_value; - ht_cfg_value_t min; - ht_cfg_value_t max; - const char* docstring; -} ht_reflection_t; - -typedef struct { - int rows, cols, channels; - unsigned char* data; -} ht_frame_t; - -HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); -HT_API(void) ht_load_config(FILE* stream, ht_config_t* cfg); -HT_API(void) ht_free_context(headtracker_t* ctx); -HT_API(void) ht_get_bgr_frame(headtracker_t* ctx, ht_frame_t* ret); -HT_API(void) ht_make_config(ht_config_t* cfg); -HT_API(bool) ht_cycle(headtracker_t* ctx, ht_result_t* euler); -HT_API(void) ht_reset(headtracker_t* ctx); diff --git a/ftnoir_tracker_ht/images/HT.ico b/ftnoir_tracker_ht/images/HT.ico deleted file mode 100644 index 7555ce25..00000000 Binary files a/ftnoir_tracker_ht/images/HT.ico and /dev/null differ diff --git a/ftnoir_tracker_ht/images/xxx_ht.ico b/ftnoir_tracker_ht/images/xxx_ht.ico new file mode 100644 index 00000000..7555ce25 Binary files /dev/null and b/ftnoir_tracker_ht/images/xxx_ht.ico differ diff --git a/ftnoir_tracker_ht/stdafx.h b/ftnoir_tracker_ht/stdafx.h deleted file mode 100644 index 0e532c9f..00000000 --- a/ftnoir_tracker_ht/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.cpp new file mode 100644 index 00000000..336ede2d --- /dev/null +++ b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.cpp @@ -0,0 +1,422 @@ +#include "stdafx.h" +#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "headtracker-ftnoir.h" +#include "ftnoir_tracker_ht.h" +#include "ftnoir_tracker_ht_dll.h" +#include "ui_trackercontrols.h" +#include "../facetracknoir/global-settings.h" + +#define WIDGET_WIDTH 250 +#define WIDGET_HEIGHT 188 + +#if defined(_WIN32) || defined(__WIN32) +#include +#else +#include +#endif + +// delicious copypasta +static QList get_camera_names(void) { + QList ret; +#if defined(_WIN32) || defined(__WIN32) + // 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(); +#else + for (int i = 0; i < 16; i++) { + char buf[128]; + sprintf(buf, "/dev/video%d", i); + if (access(buf, R_OK | W_OK) == 0) { + ret.append(buf); + } else { + break; + } + } +#endif + return ret; +} + +typedef struct { + int width; + int height; +} resolution_tuple; + +static resolution_tuple resolution_choices[] = { + { 0, 0 }, + { 640, 480 }, + { 320, 240 }, + { 320, 200 }, + { 0, 0 } +}; + +static void load_settings(ht_config_t* config, Tracker* tracker) +{ + 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" ); + config->classification_delay = 4000; + config->field_of_view = iniFile.value("fov", 69).toFloat(); + config->pyrlk_pyramids = 3; + config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; + config->max_keypoints = 250; + config->keypoint_quality = 12; + config->keypoint_distance = 2.3f; + config->keypoint_3distance = 6; + //config->force_width = 640; + //config->force_height = 480; + config->force_fps = iniFile.value("fps", 0).toInt(); + config->camera_index = iniFile.value("camera-index", -1).toInt(); + config->ransac_num_iters = 100; + config->ransac_max_reprojection_error = 6.5f; + config->ransac_max_inlier_error = 6.5f; + config->ransac_max_mean_error = 4.0f; + config->ransac_abs_max_mean_error = 7.0f; + config->debug = 0; + config->ransac_min_features = 0.75f; + int res = iniFile.value("resolution", 0).toInt(); + if (res < 0 || res >= (int)(sizeof(*resolution_choices) / sizeof(resolution_tuple))) + res = 0; + resolution_tuple r = resolution_choices[res]; + config->force_width = r.width; + config->force_height = r.height; + if (tracker) + { + tracker->enableRX = iniFile.value("enable-rx", true).toBool(); + tracker->enableRY = iniFile.value("enable-ry", true).toBool(); + tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); + tracker->enableTX = iniFile.value("enable-tx", true).toBool(); + tracker->enableTY = iniFile.value("enable-ty", true).toBool(); + tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); + } + iniFile.endGroup(); +} + +Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fresh(false) +{ + videoWidget = NULL; + layout = NULL; + enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; + shm = (ht_shm_t*) lck_shm.mem; + shm->terminate = 0; + load_settings(&shm->config, this); + shm->result.filled = false; +} + +Tracker::~Tracker() +{ + subprocess.kill(); + if (shm) + shm->terminate = true; + if (layout) + delete layout; + if (videoWidget) + delete videoWidget; +} + +void Tracker::StartTracker(QFrame* videoframe) +{ + videoframe->setAttribute(Qt::WA_NativeWindow); + videoframe->show(); + videoWidget = new VideoWidget(videoframe); + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(videoWidget); + if (videoframe->layout()) + delete videoframe->layout(); + videoframe->setLayout(layout); + videoWidget->resize(WIDGET_WIDTH, WIDGET_HEIGHT); + videoWidget->show(); + this->layout = layout; + load_settings(&shm->config, this); + shm->frame.channels = shm->frame.width = shm->frame.height = 0; + shm->pause = shm->terminate = shm->running = false; + shm->timer = 0; + subprocess.setWorkingDirectory(QCoreApplication::applicationDirPath() + "/tracker-ht"); +#if defined(_WIN32) || defined(__WIN32) + subprocess.start("\"" + QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir" + "\""); +#else + subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); +#endif + connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); + timer.start(15); +} + +void Tracker::paint_widget() { + if (fresh) { + fresh = false; + videoWidget->update(); + } +} + +bool Tracker::GiveHeadPoseData(THeadPoseData* data) +{ + bool ret = false; + + lck_shm.lock(); + shm->timer = 0; + if (shm->frame.width > 0) + { + videoWidget->updateImage(shm->frame.frame, shm->frame.width, shm->frame.height); + //memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3); + fresh = true; + } + if (shm->result.filled) { + if (enableRX) + data->yaw = shm->result.rotx; + if (enableRY) + data->pitch = shm->result.roty; + if (enableRZ) + data->roll = shm->result.rotz; + if (enableTX) + data->x = shm->result.tx; + if (enableTY) + data->y = shm->result.ty; + if (enableTZ) + data->z = shm->result.tz; + ret = true; + } + lck_shm.unlock(); + + return ret; +} + +//----------------------------------------------------------------------------- +void TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = "HT 0.7"; +} + +void TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = "HT"; +} + +void TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = ""; +} + +void TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/ht.png"); +} + + +//----------------------------------------------------------------------------- +//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new TrackerDll; +} + +//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor() +{ + return (ITracker*) new Tracker; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetDialog( ) +{ + return (ITrackerDialog*) new TrackerControls; +} + +TrackerControls::TrackerControls() +{ + ui.setupUi(this); + loadSettings(); + 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))); + connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); + settingsDirty = false; +} + +TrackerControls::~TrackerControls() +{ +} + +void TrackerControls::showEvent(QShowEvent *event) +{ +} + +void TrackerControls::Initialize(QWidget* parent) +{ + show(); +} + +void TrackerControls::loadSettings() +{ + ui.cameraName->clear(); + QList 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.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()) + { + default: + case 0: + fps = 0; + break; + case 30: + fps = 1; + break; + case 60: + fps = 2; + break; + case 120: + fps = 3; + break; + } + ui.cameraFPS->setCurrentIndex(fps); + ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); + iniFile.endGroup(); + settingsDirty = false; +} + +void TrackerControls::save() +{ + 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" ); + iniFile.setValue("fov", ui.cameraFOV->value()); + int fps; + switch (ui.cameraFPS->currentIndex()) + { + case 0: + default: + fps = 0; + break; + case 1: + fps = 30; + break; + case 2: + fps = 60; + break; + case 3: + fps = 120; + break; + } + iniFile.setValue("fps", fps); + iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); + iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("resolution", ui.resolution->currentIndex()); + iniFile.endGroup(); + settingsDirty = false; +} + +void TrackerControls::doOK() +{ + save(); + this->close(); +} + +void TrackerControls::doCancel() +{ + if (settingsDirty) { + int ret = QMessageBox::question ( this, + "Settings have changed", + "Do you want to save the settings?", + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, + QMessageBox::Discard ); + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} diff --git a/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.h b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.h new file mode 100644 index 00000000..1a449dca --- /dev/null +++ b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef FTNOIR_TRACKER_HT_H +#define FTNOIR_TRACKER_HT_H + +#include "stdafx.h" +#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "headtracker-ftnoir.h" +#include "ui_trackercontrols.h" +#include "video_widget.h" +#include "../compat/compat.h" +#include +#include + +class Tracker : public QObject, public ITracker +{ + Q_OBJECT +public: + Tracker(); + ~Tracker(); + void StartTracker(QFrame* frame); + bool GiveHeadPoseData(THeadPoseData *data); + bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + ht_shm_t* shm; + bool NeedsTimeToFinish() { + return true; + } + void WaitForExit() { + if (shm) { + shm->terminate = true; + subprocess.waitForFinished(5000); + } + subprocess.kill(); + } +private: + QTimer timer; + PortableLockedShm lck_shm; + QProcess subprocess; + VideoWidget* videoWidget; + QHBoxLayout* layout; + volatile bool fresh; +private slots: + void paint_widget(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls : public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) {}; + void unRegisterTracker() {}; + +private: + Ui::Form ui; + void loadSettings(); + void save(); + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; + void settingChanged(double) { settingsDirty = true; }; +}; + +#endif + diff --git a/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht_dll.h b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht_dll.h new file mode 100644 index 00000000..f3bfd381 --- /dev/null +++ b/ftnoir_tracker_ht/xxx_ftnoir_tracker_ht_dll.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2013 Stanisław Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "../facetracknoir/global-settings.h" + +//----------------------------------------------------------------------------- +class TrackerDll : public Metadata +{ + // ITrackerDll interface + void Initialize() {} + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); +}; diff --git a/ftnoir_tracker_ht/xxx_headtracker-ftnoir.h b/ftnoir_tracker_ht/xxx_headtracker-ftnoir.h new file mode 100644 index 00000000..48510997 --- /dev/null +++ b/ftnoir_tracker_ht/xxx_headtracker-ftnoir.h @@ -0,0 +1,24 @@ +#pragma once +#include +#include +#include "ht-api.h" + +#define HT_SHM_NAME "ftnoir-tracker-ht-shm" +#define HT_MUTEX_NAME "ftnoir-tracker-ht-mutex" + +#define HT_MAX_VIDEO_WIDTH 2048 +#define HT_MAX_VIDEO_HEIGHT 1536 +#define HT_MAX_VIDEO_CHANNELS 3 + +typedef struct { + int width, height, channels; + unsigned char frame[HT_MAX_VIDEO_WIDTH * HT_MAX_VIDEO_HEIGHT * HT_MAX_VIDEO_CHANNELS]; +} ht_video_t; + +typedef struct { + ht_video_t frame; + ht_config_t config; + ht_result_t result; + volatile int timer; + volatile bool pause, terminate, running; +} ht_shm_t; diff --git a/ftnoir_tracker_ht/xxx_ht-api.h b/ftnoir_tracker_ht/xxx_ht-api.h new file mode 100644 index 00000000..ac8d45cf --- /dev/null +++ b/ftnoir_tracker_ht/xxx_ht-api.h @@ -0,0 +1,85 @@ +#pragma once +#ifndef HT_API +#ifndef __cplusplus +# define HT_EXTERN +#else +# define HT_EXTERN extern "C" +#endif +# if defined(_WIN32) && !defined(MINGW) +# define HT_API(t) HT_EXTERN __declspec(dllexport) t __stdcall +# else +# define HT_API(t) HT_EXTERN t +# endif +#endif +#if !defined(_WIN32) && !defined(_isnan) +# define _isnan isnan +#endif +#include +struct ht_context; +typedef struct ht_context headtracker_t; + +typedef struct ht_config { + float field_of_view; + float classification_delay; + int pyrlk_pyramids; + int pyrlk_win_size_w; + int pyrlk_win_size_h; + float ransac_max_inlier_error; + float ransac_max_reprojection_error; + int max_keypoints; + int keypoint_quality; + float keypoint_distance; + float keypoint_3distance; + int force_width; + int force_height; + int force_fps; + int camera_index; + bool debug; + int ransac_num_iters; + float ransac_min_features; + float ransac_max_mean_error; + float ransac_abs_max_mean_error; +} ht_config_t; + +typedef struct { + double rotx, roty, rotz; + double tx, ty, tz; + bool filled; +} ht_result_t; + +typedef enum { + cfg_type_float = 0, + cfg_type_int = 1, + cfg_type_bool = 2, + cfg_type_double = 3 +} ht_cfg_type_t; + +typedef union +{ + double d; + float f; + int i; +} ht_cfg_value_t; + +typedef struct { + const char* name; + int offset; + ht_cfg_type_t type; + ht_cfg_value_t default_value; + ht_cfg_value_t min; + ht_cfg_value_t max; + const char* docstring; +} ht_reflection_t; + +typedef struct { + int rows, cols, channels; + unsigned char* data; +} ht_frame_t; + +HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); +HT_API(void) ht_load_config(FILE* stream, ht_config_t* cfg); +HT_API(void) ht_free_context(headtracker_t* ctx); +HT_API(void) ht_get_bgr_frame(headtracker_t* ctx, ht_frame_t* ret); +HT_API(void) ht_make_config(ht_config_t* cfg); +HT_API(bool) ht_cycle(headtracker_t* ctx, ht_result_t* euler); +HT_API(void) ht_reset(headtracker_t* ctx); diff --git a/ftnoir_tracker_ht/xxx_stdafx.h b/ftnoir_tracker_ht/xxx_stdafx.h new file mode 100644 index 00000000..0e532c9f --- /dev/null +++ b/ftnoir_tracker_ht/xxx_stdafx.h @@ -0,0 +1,14 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/ftnoir_tracker_ht/xxx_tracker.qrc b/ftnoir_tracker_ht/xxx_tracker.qrc new file mode 100644 index 00000000..9627f700 --- /dev/null +++ b/ftnoir_tracker_ht/xxx_tracker.qrc @@ -0,0 +1,5 @@ + + + images/HT.ico + + diff --git a/ftnoir_tracker_ht/xxx_trackercontrols.ui b/ftnoir_tracker_ht/xxx_trackercontrols.ui new file mode 100644 index 00000000..0a1bc3ae --- /dev/null +++ b/ftnoir_tracker_ht/xxx_trackercontrols.ui @@ -0,0 +1,295 @@ + + + Form + + + Qt::NonModal + + + + 0 + 0 + 500 + 160 + + + + + 0 + 0 + + + + + 500 + 160 + + + + HT tracker settings + + + + + 10 + 10 + 141 + 16 + + + + Horizontal field of view + + + + + + 130 + 10 + 251 + 22 + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 69.000000000000000 + + + + + + 10 + 40 + 101 + 16 + + + + Frames per second + + + + + + 130 + 40 + 251 + 22 + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + + + + + 10 + 70 + 71 + 16 + + + + Camera name + + + + + + 340 + 130 + 75 + 23 + + + + OK + + + + + + 420 + 130 + 75 + 23 + + + + Cancel + + + + + + 390 + 10 + 101 + 81 + + + + Enable axes + + + + + 10 + 20 + 70 + 17 + + + + RX + + + + + + 10 + 40 + 70 + 17 + + + + RY + + + + + + 10 + 60 + 70 + 17 + + + + RZ + + + + + + 60 + 20 + 70 + 17 + + + + TX + + + + + + 60 + 40 + 70 + 17 + + + + TY + + + + + + 60 + 60 + 70 + 17 + + + + TZ + + + + + + + 130 + 70 + 251 + 22 + + + + + + + 10 + 100 + 61 + 16 + + + + Resolution + + + + + + 130 + 100 + 251 + 22 + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + -- cgit v1.2.3