Newer
Older
CasicBioRecNew / utils / SettingConfig.cpp
#include "SettingConfig.h"
#include <QApplication>

SettingConfig::SettingConfig()
{
    filename = QApplication::applicationDirPath() + "/conf/config.ini";
    setting = new QSettings(this->filename, QSettings::IniFormat);

    init();
}


QVariant SettingConfig::getProperty(QString nodeName, QString keyName) {
    QVariant var = this->setting->value(QString("/%1/%2").arg(nodeName).arg(keyName));
    return var;
}

void SettingConfig::setProperty(QString nodeName, QString keyName, QString value) {
    this->setting->setValue(QString("/%1/%2").arg(nodeName).arg(keyName), value);
}

void SettingConfig::init()
{
    WINDOW_WIDTH = getProperty("window", "width").toInt();
    WINDOW_HEIGHT = getProperty("window", "height").toInt();
    WINDOW_BACKGROUND_COLOR = getProperty("window", "backgroundColor").toString();

    OUT_EXE_FILE = getProperty("exe", "outExeFile").toString();

    FACE_CAMERA_INDEX = getProperty("camera", "faceIndex").toInt();
    FACE_FRAME_WIDTH = getProperty("camera", "faceFrameWidth").toInt();
    FACE_FRAME_HEIGHT = getProperty("camera", "faceFrameHeight").toInt();
    FACE_FRAME_INTERVAL = getProperty("camera", "frameInterval").toInt();
    IRIS_FRAME_WIDTH = getProperty("camera", "irisFrameWidth").toInt();
    IRIS_FRAME_HEIGHT = getProperty("camera", "irisFrameHeight").toInt();
    IRIS_WIDTH = getProperty("camera", "irisWidth").toInt();
    IRIS_HEIGHT = getProperty("camera", "irisHeight").toInt();
    IRIS_FRAME_INTERVAL = getProperty("camera", "irisFrameInterval").toInt();

    MAX_MATCH_TIME = getProperty("recognize", "maxMatchTime").toInt();
    SUCCESS_TIPS_LAST = getProperty("recognize", "successTipsLast").toInt();
    FAILURE_TIPS_LAST = getProperty("recognize", "failureTipsLast").toInt();
    MAX_FACE_TRY_COUNT = getProperty("recognize", "maxFaceTryCount").toInt();
    MAX_FACE_NOT_FOUND_COUNT = getProperty("recognize", "maxFaceNotFoundCount").toInt();
    MAX_IRIS_TRY_COUNT = getProperty("recognize", "maxIrisTryCount").toInt();
    MAX_EYE_NOT_FOUND_COUNT = getProperty("recognize", "maxEyeNotFoundCount").toInt();
    MIN_FACE_REGIST_SIZE = getProperty("recognize", "minFaceRegist").toInt();
    MIN_FACE_RECOG_SIZE = getProperty("recognize", "minFaceRecog").toInt();

    MIN_WORK_FACE_SIZE = getProperty("work", "minFaceSize").toInt();
    MIN_WORK_FACE_POSX = getProperty("work", "minFacePosX").toInt();
    MAX_WORK_FACE_POSX = getProperty("work", "maxFacePosX").toInt();
    MIN_WORK_FACE_POSY = getProperty("work", "minFacePosY").toInt();
    MAX_WORK_FACE_POSY = getProperty("work", "maxFacePosY").toInt();
    FACE_TOO_CLOSE_SIZE = getProperty("work", "faceCloseSize").toInt();
    FACE_TOO_FAR_SIZE = getProperty("work", "faceFarSize").toInt();

    PORT_NAME = getProperty("com", "motoPortName").toString();

    RECOG_TYPE = getProperty("recognize", "recogType").toInt();

    LOG_FILE = getProperty("log", "logFile").toString();
    LOG_LEVEL = getProperty("log", "logLevel").toString();
}