Global Settings#

The following settings are used to configure the global settings of the application. Generally, you’d better to configure them when you start the application and do not change them during the running time, although some of them can be changed at any time.

Product Information#

struct ProductInfo#

VisionFlow production infomation.

This class is used to describe the production infomation of VisionFlow. include the version, build date, and so on.

Public Members

int version_major#

The major version, such as 1.

int version_minor#

The minor version, such as 2.

int version_patch#

The patch version, such as 35.

uint64_t version_num#

The version number, equal to (version_major * 1000000 + version_minor * 1000 + version_patch). e.g. 1.2.35 is 001002035.

std::string version#

The version string, such as “1.2.35”.

std::string version_full#

The full version string with revision, e.g. “1.2.35.beta.a0f8b8b.0”.

std::string file_hash#

The file hash, e.g. “a0f8b8b.0”.

std::string file_full_hash#

The full file hash.

std::string release_tag#

The release tag, one of “alpha”, “beta”, “preview”, “release”.

int64_t build_timestamp#

The build timestamp, e.g. 1514098983.

std::string copyright#

The copyright, e.g. “Copyright (c) 2017-present, Aqrose Technology,

Ltd. All rights reserved.”.

Public Static Functions

static const ProductInfo &Get()#

Get the release version information of VisionFlow. With this function, you can get the release version information at runtime.

Returns:

the version information.

Logging Settings#

using LogSinkFunc = void (*)(int, const char*, size_t)#

Log sink interface. with this interface, you can implement your own log sink to receive log messages.

struct LoggerOptions#

VisionFlow Logger Options.

Public Members

const char *file_sink = nullptr#

Log file path, should be encoded in utf-8; after setting this option, VisionFlow will write the log to the file; if the file does not exist, VisionFlow will try to create it automatically; if the file already exists , The log information will be appended to the file; the default path is empty, which means that the log will not be output to any file.

LogSinkFunc func_sink = nullptr#

Pass in the function pointer used to receive the log, and output the log to your custom function.

bool stdout_sink = true#

print the log to the standard output device, this option is enabled by default.

bool msvc_sink = false#

When debugging on the Windows platform, you can enable this option to print the log to the debug output window of Visual Studio.

unsigned int flush_level = 4#

control the refreshing level of log file. The flush_level range in [0, 6], include on_trace=0, on_debug=1, on_info=2, on_warn=3, on_error=4, on_critical=5, on_off=6. And the default value is 4 (on_error), which means the log file will be refreshed when error or more serious situation (eg:critical) occurring. When flush_level greater than or equal to 6 (on_off), the log file will not be refreshed.

void visionflow::init_logger(const LoggerOptions &options)#

Init Settings#

using visionflow::LicenseErrorCallBack = std::function<bool(const std::string &product_name, const std::string &product_version, const std::string &feature_name, const std::string &error_message)>#
struct LicenseOptions#

Public Members

std::string server_addr = {}#

Server IP address (127.0.0.1): 1.If it is empty, the local lock will be used; 2.If it is not empty, the network lock will be used.

std::string license_id = {}#

Dongle unique ID, The sn of the lock or the user_guid of the slock, you can get them with visionflow::helper::license_devices(). 1. If it is empty, it will automatically find a lock that meets the conditions when logging in. 2. If it is not empty, it will only find and use the specified lock.

LicenseErrorCallBack callback_fun = nullptr#

Callback function in case of an error in the authorization verification phase, if the return value is true, the login will be attempted again, otherwise the verification of this feature will be skipped.

struct InitOptions#

Global initialize options.

Public Members

std::string product_mark = {}#

The product identifier, which is written to the project .vfpro file when a new project is created, identifies that the project was created with this product. Normally only projects with an identifier that matches the identifier of this product will be allowed to be opened (this means that it is a project that is recognized by the current product). If you open an old project (i.e. without a product identification field in the .vfpro file), it will be compatible by default and will write the current product’s identification upon successful opening of the project. Finally, it is advisable not to leave this field empty.

std::vector<std::string> compatible_product_marks = {}#

Sometimes you may want to be able to open projects created by other products, and you can do this by writing the mark of those products to this list. If product_mark is not empty, it will be added to this list automatically, if you don’t want to do the checking of the mark field, leave product_mark and compatible_product_marks both empty. If you want to be compatible with products that have empty identifiers (i.e. they have an identifier field, but the identifier field is empty), you need to explicitly add an empty identifier (e.g. “”) to this list.

LoggerOptions logger = {}#

Logger options.

const char *language = ""#

Language used in VisionFlow. Currently, there are two language you can choose : Chinese (zh_CN) or English (en_US). By default, VisionFlow will use the language consistent with the operating system settings if you don’t set any language or set an empty string.

LicenseOptions license = {}#

Configure license: server addr, license id and callback fun. LicenseOptions.

const char *cloud_project_cache_dir = ""#

Where the cloud project cache directory is located, which will be in the user home directory by default or set this option to empty string.

size_t global_thread_pool_size = 0#

The size of the global thread pool. VisionFlow will create a thread pool to running the asynchronous tasks such as inferring sample in asynchronous mode or synchronize data with the cloud. You can set the thread number of the global thread pool by this option. A value automatically determined based on hardware conditions(typically the

number of CPU cores) will be set if the given value is 0 (by default).

void visionflow::initialize(const InitOptions &options = {})#

Initialize the visionflow library. This function should be called before calling any other interface of the VisionFlow library.

Throws:

excepts::LicenseError – Failed to Initialize authorization verification service or failed to open license client.

Environment Variables#

class Environment#

Environment stores the configurations of environmental variables with a global map.

Public Static Functions

static const std::string &Get(const std::string &key)#

Get the value of the environment with key.

Parameters:

key – The environment key.

Throws:

excepts::DataNotFound – Throws if key not exists in the map.

Returns:

const std::string& the environment value of the key.

static void Set(const std::string &key, const std::string &value)#

Set the environment variable. If the key not exists, it will be added into map. Otherwise, the map will be updated with the new value.

Parameters:
  • key – The key of the environment variable.

  • value – The value of the environment variable.

static bool Exists(const std::string &key)#

Check if the environment variable with the key exists.

Parameters:

key – The key of the environment variable.

Returns:

true

Returns:

false

static void Erase(const std::string &key)#

Erase the environment variable in the map with the key.

Note

Nothing will happen if the key not exists in the map.

Parameters:

key – The key of the environment variable.

static void Clear()#

Clear all the environmental variables.

static std::vector<std::string> AllEnvKeys()#

Get all environment variables’ keys in the map.

Returns:

std::vector<std::string>

static bool MeetRequirements(const std::map<std::string, std::string> &env_vars)#

Check if the current configurations of the Environment Management System meets the environmental conditions with a map of environment variables.

Note

The current Environment system meets requirements means all key-value pairs in the env_vars exist in Environment system.

Parameters:

env_vars – The map of environment variables to be checked.

Returns:

true The current environment system meets the requirements of the param’s environmental condition.

Returns:

false The current environment system does not meet the requirements of the param’s environmental condition.

static std::map<std::string, std::string> GetAllEnvironmentVariables()#

Get the All Environment Variables key-value pairs.

Returns:

std::map<std::string, std::string> The key-value pairs of all Environment Variables.