visageSDK

VisageConfiguration.h
1 //
3 // (c) Visage Technologies AB 2002 - 2023 All rights reserved.
4 //
5 // This file is part of visage|SDK(tm).
6 // Unauthorized copying of this file, via any medium is strictly prohibited.
7 //
8 // No warranty, explicit or implicit, provided.
9 //
10 // This is proprietary software. No part of this software may be used or
11 // reproduced in any form or by any means otherwise than in accordance with
12 // any written license granted by Visage Technologies AB.
13 //
15
16 #ifndef __VisageConfiguration_h__
17 #define __VisageConfiguration_h__
18
19 #ifdef IOS
20 #import <Foundation/Foundation.h>
21 #endif
22
23 #ifdef ANDROID
24 #include <android/log.h>
25 #define LOG_TAG "VisageConfiguration"
26 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
27 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
28 #endif
29
30 #ifdef VISAGE_STATIC
31 #define VISAGE_DECLSPEC
32 #else
33
34 #ifdef VISAGE_EXPORTS
35 #define VISAGE_DECLSPEC __declspec(dllexport)
36 #else
37 #define VISAGE_DECLSPEC __declspec(dllimport)
38 #endif
39
40 #endif
41
42 #pragma once
43
44 #include <string>
45 #include "Common.h"
46
47 enum class ConfigOwner
48 {
49 VisageTracker, VisageDetector
50 };
51
52
128 template <class T>
129 struct VISAGE_DECLSPEC VsCfgArr
130 {
131 int size;
132
133 T* ptr;
134
135 VsCfgArr(int size);
136
137 VsCfgArr(VsCfgArr<T>&& origin) noexcept;
138
139 VsCfgArr(T* ptr, int size);
140
141 VsCfgArr(const VsCfgArr<T>& origin);
142
143 VsCfgArr<T>& operator=(const VsCfgArr<T>& origin);
144
145 VsCfgArr<T>& operator=(VsCfgArr<T>&& origin) noexcept;
146
147 T& operator[](int index);
148
149 const T& operator[](int index) const;
150
151 ~VsCfgArr();
152 };
153
154 namespace VisageSDK
155 {
156 class ModelConfiguration;
157
158 /* FittingAlgorithms namespace contains values that specify fitting algorithm used to estimate 3D head pose and 3D model deformations that include shape units and action units.
159 */
160 namespace FittingAlgorithms
161 {
162 /* Enables 3D face fitting.
163 */
164 static const char* EIF_POSE_SU_AU = "eif_pose_su_au";
165 /* Disables 3D face fitting.
166 */
167 static const char* NONE = "none";
168
169 static const char* const valid_list[] = {
170 EIF_POSE_SU_AU,
171 NONE
172 };
173 }
174
272 class VISAGE_DECLSPEC VisageConfiguration
273 {
274 public:
279 VisageConfiguration(const char* trackerConfigFile);
280
285 VisageConfiguration(const VisageConfiguration& configuration);
286
287 ~VisageConfiguration();
288
293 float getCameraFocus() const;
294
299 float getRecoveryTimeout() const;
300
305 VsCfgArr<float> getSmoothingFactors() const;
306
311 unsigned int getEnableSmoothing() const;
312
317 unsigned int getTemporallyDenoiseInput() const;
318
323 const std::string& getVftDataPath() const;
324
329 const std::string& getVfdDataPath() const;
330
335 const std::string& getPrDataPath() const;
336
341 const std::string& getErDataPath() const;
342
347 unsigned int getProcessEyes() const;
348
355 unsigned int getRefineLandmarks() const;
356
361 unsigned int getRefineEars() const;
362
367 float getMinFaceScale() const;
368
373 float getMaxFaceScale() const;
374
379 float getFaceDetectorSensitivity() const;
380
381 /* @brief Returns the value of the fitting_algorithm parameter.
382 *
383 * @return String containing value of the fitting_algorithm parameter.
384 */
385 const std::string& getFittingAlgorithm() const;
386
391 const std::string& getPoseFittingModelConfiguration() const;
392
397 const std::string& getAuFittingModelConfiguration() const;
398
403 const std::string& getMeshFittingModelConfiguration() const;
404
412 bool setCameraFocus(float camera_focus);
413
421 bool setRecoveryTimeout(float recovery_timeout);
422
430 bool setSmoothingFactors(const VsCfgArr<float>& smoothing_factors);
431
439 bool setEnableSmoothing(unsigned int enable_smoothing);
440
448 bool setTemporallyDenoiseInput(unsigned int temporally_denoise_input);
449
457 bool setVftDataPath(std::string vft_data_path);
458
466 bool setVfdDataPath(std::string vfd_data_path);
467
475 bool setPrDataPath(std::string pr_data_path);
476
484 bool setErDataPath(std::string er_data_path);
485
493 bool setProcessEyes(unsigned int process_eyes);
494
504 bool setRefineLandmarks(unsigned int refine_landmarks);
505
513 bool setRefineEars(unsigned int refine_ears);
514
522 bool setMinFaceScale(float min_face_scale);
523
531 bool setMaxFaceScale(float max_face_scale);
532
540 bool setFaceDetectorSensitivity(float face_detector_sensitivity);
541
542 /* @brief Sets the value of the fitting_algorithm parameter.
543 *
544 * Valid parameter values are listed in section 2.1. of <a href="../VisageTracker Configuration Manual.pdf">VisageTracker Configuration Manual</a>. Values are also defined within FittingAlgorithms namespace.
545 * The fitting will be disabled if the passed string is empty ("") or "none".
546 *
547 * @param fitting_algorithm String that specifies which fitting algorithm to use
548 * @return True if the parameter was changed, false if the input was invalid
549 */
550 bool setFittingAlgorithm(std::string fitting_algorithm);
551
563 bool setPoseFittingModelConfiguration(std::string pose_fitting_model_configuration);
564
576 bool setAuFittingModelConfiguration(std::string au_fitting_model_configuration);
577
589 bool setMeshFittingModelConfiguration(std::string mesh_fitting_model_configuration);
590
594 void enableAuModel();
595
599 void enableMeshModel();
600
604 void disableAuModel();
605
609 void disableMeshModel();
610
615 bool setConfigurationFile(const char* trackerConfigFile);
616
621 VisageConfiguration& operator=(VisageConfiguration configuration);
622 private:
623 VisageConfiguration();
624
625 #ifdef IOS
626 NSBundle* mainBundle;
627 #endif
628
629 friend class VisageTracker;
630 friend class VisageFeaturesDetector;
631 friend class Candide3Model;
632
633 int changes;
634
635 std::string m_vft_data_path;
636 std::string m_vfd_data_path;
637 std::string m_pr_data_path;
638 std::string m_er_data_path;
639 std::string m_fitting_algorithm;
640 std::string m_pose_fitting_model_configuration;
641 std::string m_au_fitting_model_configuration;
642 std::string m_mesh_fitting_model_configuration;
643
644 VsMat* m_smoothing_factors;
645
646 float m_camera_focus;
647 float m_recovery_timeout;
648 float m_min_face_scale;
649 float m_max_face_scale;
650 float m_face_detector_sensitivity;
651
652 unsigned int m_enable_smoothing;
653 unsigned int m_temporally_denoise_input;
654 unsigned int m_process_eyes;
655 unsigned int m_refine_landmarks;
656 unsigned int m_refine_ears;
657
658 bool m_disable_au_model;
659 bool m_disable_mesh_model;
660
661 const ModelConfiguration* m_pose_fitting_model_cfg;
662 const ModelConfiguration* m_au_fitting_model_cfg;
663 const ModelConfiguration* m_mesh_fitting_model_cfg;
664
665 std::string m_log_filename;
666 std::string m_cfg_dir_string;
667
668 /* Release memory of VsMat objects and arrays.
669 */
670 void clean();
671
672 /* Initialize class members.
673 */
674 void init();
675
676 /* Return changes of the class members.
677 * Changes are represented with integer variable. Each type of change set the particular bit of the integer variable to 1.
678 * Once the function is called integer variable is set to 0 (reset).
679 */
680 int getChanges();
681
682 void swap(VisageConfiguration& first, VisageConfiguration& second);
683 };
684 }
685 #endif
VisageSDK::VisageTracker
VisageTracker is a face tracker capable of tracking the head pose, facial features and gaze for multi...
Definition: VisageTracker.h:260
VisageSDK::VisageFeaturesDetector
Faces and facial features detector implementation.
Definition: VisageFeaturesDetector.h:106
VisageSDK::VisageConfiguration
VisageConfiguration is a class used to change, apply, load and save configuration parameters used by ...
Definition: VisageConfiguration.h:272
VsCfgArr
This is a templated structure that can store an array of values of varying types, including: ...
Definition: VisageConfiguration.h:129
VisageSDK
Namespace.
Definition: linux_header.h:1