summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
blob: d67ced5e266fc22ef784c03b7ba178f5ab7fb98c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (c) 2012 Patrick Ruoff
 *
 * 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_pt.h"
#include <QCoreApplication>
#include <QSettings>

//-----------------------------------------------------------------------------
void TrackerSettings::load_ini()
{
	qDebug("TrackerSettings::load_ini()");
	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( "PointTracker" );

	cam_index      = iniFile.value("CameraId", 0).toInt();
	cam_f          = iniFile.value("CameraF", 1).toFloat();
	cam_res_x      = iniFile.value("CameraResX", 640).toInt();
	cam_res_y      = iniFile.value("CameraResY", 480).toInt();
	cam_fps        = iniFile.value("CameraFPS", 30).toInt();
	threshold      = iniFile.value("PointExtractThreshold", 128).toInt();
	min_point_size = iniFile.value("PointExtractMinSize", 2).toInt();
	max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt();
	M01[0]  = iniFile.value("PointModelM01x", 0).toFloat();
	M01[1]  = iniFile.value("PointModelM01y", 40).toFloat();
	M01[2]  = iniFile.value("PointModelM01z", -30).toFloat();
	M02[0]  = iniFile.value("PointModelM02x", 0).toFloat();
	M02[1]  = iniFile.value("PointModelM02y", -70).toFloat();
	M02[2]  = iniFile.value("PointModelM02z", -80).toFloat();
	t_MH[0] = iniFile.value("tMHx", 0).toFloat();
	t_MH[1] = iniFile.value("tMHy", 0).toFloat();
	t_MH[2] = iniFile.value("tMHz", 0).toFloat();
	video_widget = iniFile.value("VideoWidget", true).toBool();
	sleep_time   = iniFile.value("SleepTime", 10).toInt();
	reset_time   = iniFile.value("ResetTime", 3).toInt();
	
	iniFile.endGroup();
}

void TrackerSettings::save_ini() const
{
	qDebug("TrackerSettings::save_ini()");
	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 ( "PointTracker" );

	iniFile.setValue("CameraId", cam_index);
	iniFile.setValue("CameraF",  cam_f);
	iniFile.setValue("CameraResX",  cam_res_x);
	iniFile.setValue("CameraResY",  cam_res_y);
	iniFile.setValue("CameraFPS",  cam_fps);
	iniFile.setValue("PointExtractThreshold", threshold);
	iniFile.setValue("PointExtractMinSize", min_point_size);
	iniFile.setValue("PointExtractMaxSize", max_point_size);
	iniFile.setValue("PointModelM01x", M01[0]);
	iniFile.setValue("PointModelM01y", M01[1]);
	iniFile.setValue("PointModelM01z", M01[2]);
	iniFile.setValue("PointModelM02x", M02[0]);
	iniFile.setValue("PointModelM02y", M02[1]);
	iniFile.setValue("PointModelM02z", M02[2]);
	iniFile.setValue("tMHx", t_MH[0]);
	iniFile.setValue("tMHy", t_MH[1]);
	iniFile.setValue("tMHz", t_MH[2]);
	iniFile.setValue("VideoWidget", video_widget);
	iniFile.setValue("SleepTime", sleep_time);
	iniFile.setValue("ResetTime", reset_time);

	iniFile.endGroup();
}