summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2012-03-17 16:15:51 +0000
committerWim Vriend <facetracknoir@gmail.com>2012-03-17 16:15:51 +0000
commit9184ea73941814b95c2768d8bcca8bdb77655891 (patch)
tree9cf5977e95abb7e42a719730560c145c1b33c9ba /FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp
parent9ae8a2212d0c85cfa904ea3bf03c0631f6c1369a (diff)
Changed Tracker code, so the DLL's are true plug-ins.
FaceTrackNoIR will scan the bin folder for FTNoIR_Tracker*.dll and put the names in the combobox. All Trackers have 3 new member-functions (like the filters). git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@104 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp')
-rw-r--r--FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp208
1 files changed, 208 insertions, 0 deletions
diff --git a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp
new file mode 100644
index 00000000..a39d8bf2
--- /dev/null
+++ b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp
@@ -0,0 +1,208 @@
+/* Copyright (c) 2012 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.
+ */
+
+#include "ftnoir_tracker_fd.h"
+#include <Qt>
+#include <QPainter>
+#include <QPaintEngine>
+
+//*******************************************************************************************************
+// faceDetect Settings-dialog.
+//*******************************************************************************************************
+
+static void load_settings(struct face_detect_settings* out) {
+ qDebug("[!] load_settings()");
+ 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)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ out->redetect_ms = iniFile.value("RedetectMs", 500).toInt();
+ out->camera_id = iniFile.value("CameraId", 0).toInt();
+ out->quit = 0;
+ out->newOutput = 0;
+ out->magic = FD_MAGIC;
+ out->widgetp = iniFile.value("VideoWidget", true).toBool();
+ iniFile.endGroup ();
+}
+
+static void save_settings(const struct face_detect_settings* in) {
+
+ 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)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ iniFile.setValue("RedetectMs", in->redetect_ms);
+ iniFile.setValue("CameraId", in->camera_id);
+ iniFile.setValue("VideoWidget", in->widgetp);
+ iniFile.endGroup ();
+}
+
+
+//
+// Constructor for server-settings-dialog
+//
+TrackerControls::TrackerControls() :
+QWidget()
+{
+ qDebug("[!] TrackerControls::TrackerControls()");
+ hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct face_detect_shm), fd_shm_name);
+ shm = (struct face_detect_shm*) MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, sizeof(struct face_detect_shm));
+ hMutex = CreateMutex(NULL, false, fd_mutex_name);
+ ui.setupUi( this );
+
+ load_settings(&shm->settings);
+
+ ui.redetect_ms->setValue(shm->settings.redetect_ms);
+ ui.cameraId->setValue(shm->settings.camera_id);
+ ui.videoWidget->setChecked(shm->settings.widgetp);
+
+ settingsDirty = false;
+
+ // what a load of boilerplate...
+ QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(doOK()));
+ QObject::connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(doCancel()));
+ QObject::connect(ui.redetect_ms, SIGNAL(valueChanged(int)), this, SLOT(doSetRedetectMs(int)));
+ QObject::connect(ui.cameraId, SIGNAL(valueChanged(int)), this, SLOT(doSetCameraId(int)));
+ QObject::connect(ui.videoWidget, SIGNAL(toggled(bool)), this, SLOT(doSetVideoWidget(bool)));
+
+ //populate the description strings
+ trackerFullName = "faceDetect V1.0.0";
+ trackerShortName = "faceDetect";
+ trackerDescription = "Stans' faceDetect V1.0.0";
+
+}
+
+void TrackerControls::save() {
+ save_settings(&shm->settings);
+ settingsDirty = false;
+}
+
+void TrackerControls::doSetCameraId(int val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.camera_id = val;
+ ReleaseMutex(hMutex);
+}
+
+void TrackerControls::doSetVideoWidget(bool val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.widgetp = val;
+ ReleaseMutex(hMutex);
+}
+
+void TrackerControls::doSetRedetectMs(int val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.redetect_ms = val;
+ ReleaseMutex(hMutex);
+}
+
+//
+// Destructor for server-dialog
+//
+TrackerControls::~TrackerControls() {
+ UnmapViewOfFile(shm);
+ //CloseHandle(hMutex);
+ //CloseHandle(hMapFile);
+}
+
+void TrackerControls::Release()
+{
+ delete this;
+}
+
+//
+// Initialize tracker-client-dialog
+//
+void TrackerControls::Initialize(QWidget *parent) {
+
+ QPoint offsetpos(200, 200);
+ if (parent) {
+ this->move(parent->pos() + offsetpos);
+ }
+ show();
+}
+
+//
+// OK clicked on server-dialog
+//
+void TrackerControls::doOK() {
+ save();
+ this->close();
+}
+
+//
+// Cancel clicked on server-dialog
+//
+void TrackerControls::doCancel() {
+ //
+ // Ask if changed Settings should be saved
+ //
+ 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();
+ }
+}
+
+void TrackerControls::getFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerFullName;
+};
+
+
+void TrackerControls::getShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerShortName;
+};
+
+
+void TrackerControls::getDescription(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerDescription;
+};
+
+void TrackerControls::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/SeeingMachines.ico");
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// 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")
+
+FTNOIR_TRACKER_BASE_EXPORT TRACKERDIALOGHANDLE __stdcall GetTrackerDialog( )
+{
+ return new TrackerControls;
+}