SqueezeBrains SDK 1.13
|
Project management interface. More...
Data Structures | |
struct | sb_t_project_info |
Project info structure. More... | |
struct | sb_t_projects_info |
Array of the projects info. More... | |
struct | sb_t_par_model_lut |
Information about mapping between old and new models and levels in the sb_t_par structure. More... | |
struct | sb_t_par_changes_info |
Information on what sb_project_set_par and sb_image_info_apply_par_changes do when they apply the new parameters. More... | |
Enumerations | |
enum | sb_t_project_type { SB_PROJECT_TYPE_RETINA = 0 , SB_PROJECT_TYPE_SURFACE , SB_PROJECT_TYPE_DEEP_SURFACE , SB_PROJECT_TYPE_DEEP_CORTEX } |
Project types enum. More... | |
enum | sb_t_project_mode { SB_PROJECT_MODE_DETECTION_ONLY = 0 , SB_PROJECT_MODE_DETECTION_AND_SVL } |
Defines the loading or saving mode of a project. More... | |
Functions | |
const char * | sb_project_type_format (sb_t_project_type type) |
Returns the string of the project type. More... | |
sb_t_err | sb_project_get_info (SB_HANDLE handle, sb_t_project_info *project_info) |
Gets the project information from the handle. More... | |
sb_t_err | sb_project_destroy (SB_HANDLE *phandle) |
Frees all the resources of the project handle. More... | |
sb_t_err | sb_project_create (SB_HANDLE *phandle, const char *const project_name, sb_t_project_type project_type) |
Creates a new project of the specifed type. More... | |
sb_t_err | sb_project_load (SB_HANDLE *phandle, const char *const solution_file, const char *const project_uuid, sb_t_project_mode mode) |
Loads an existing project from file. More... | |
sb_t_err | sb_project_save (SB_HANDLE handle, const char *const solution_file, sb_t_project_mode mode) |
Saves the project to file. More... | |
sb_t_err | sb_project_clone (SB_HANDLE src, SB_HANDLE *pdst, sb_t_project_mode mode, int regenerate_uuid) |
Clones the SqueezeBrains project. More... | |
sb_t_err | sb_project_invalidate (SB_HANDLE handle, const char *const model_name, float scale) |
Eliminates the training of the models. More... | |
sb_t_err | sb_project_check_trained (SB_HANDLE handle, const char *const model_name, float scale, int *const is_trained) |
Checks if the project is trained. More... | |
sb_t_err | sb_project_get_default_features (SB_HANDLE handle, char *str, int size) |
Get the project default features depending on the project type (Retina or Surface) | |
sb_t_err | sb_project_set_sensitivity (SB_HANDLE handle, const char *const model_name, float scale, float sensitivity) |
Sets the sensitivity of the detection in the project handle. More... | |
sb_t_err | sb_project_get_sensitivity (SB_HANDLE handle, const char *const model_name, float scale, float *const sensitivity) |
Gets the classification threshold from the project handle. More... | |
sb_t_err | sb_project_get_notes (SB_HANDLE handle, char **const note) |
Gets the note from the project handle. More... | |
sb_t_err | sb_project_set_notes (SB_HANDLE handle, const char *const note) |
Sets the note into the project handle. More... | |
sb_t_err | sb_project_get_name (SB_HANDLE handle, char **const name) |
Gets the name from the project handle. More... | |
sb_t_err | sb_project_set_name (SB_HANDLE handle, const char *const name) |
Sets the name into the project handle. More... | |
sb_t_err | sb_project_get_custom_par_root (SB_HANDLE handle, SB_HANDLE *node_root) |
Returns the xml root node of your own custom parameters. More... | |
sb_t_err | sb_project_get_svl_version (SB_HANDLE handle, sb_t_version *const version, char *const version_str, int size_version_str) |
Returns the version of the SB library when the last SVL was made. More... | |
sb_t_err | sb_project_detection (SB_HANDLE handle, const sb_t_image *const img, const sb_t_roi *const roi, const sb_t_roi *const roi_defects, const sb_t_samples *const samples) |
Detection function. More... | |
sb_t_err | sb_project_copy_labeling (const char *const path_solution_dst, const char *const path_solution_src, int copy_roi, int copy_labeling, int verbosity) |
Copies the analysis roi and the labeling between two current projects of two different solutions. More... | |
sb_t_err | sb_project_set_scale_offset (SB_HANDLE handle, sb_t_size_flt scale_offset) |
Sets in the project handle the scale offset used at detection time. More... | |
sb_t_err | sb_project_get_scale_offset (SB_HANDLE handle, sb_t_size_flt *const scale_offset) |
Gets the scale offset from the project handle. More... | |
sb_t_err | sb_project_get_par_changes_info (SB_HANDLE handle, const sb_t_par *const par, sb_t_par_changes_info **const par_changes_info) |
Returns the information on what sb_project_set_par and sb_image_info_apply_par_changes do when they apply the new parameters. More... | |
sb_t_err | sb_project_destroy_par_changes_info (sb_t_par_changes_info **const par_changes_info) |
Destroys the structure. More... | |
sb_t_err | sb_project_change_type (const char *const solution_file, const char *const project_uuid, sb_t_project_type project_type) |
Change the project type. More... | |
sb_t_err | sb_project_get_par (SB_HANDLE handle, sb_t_par *const par) |
Retrieves the project parameters structure. More... | |
sb_t_err | sb_project_set_par (SB_HANDLE handle, const sb_t_par *const par) |
Sets the parameters structure into the project handle. More... | |
sb_t_err | sb_project_get_res (SB_HANDLE handle, sb_t_res **const res, int details) |
Retrieves the results of the last elaborated image. More... | |
sb_t_err | sb_project_reset_stat (SB_HANDLE handle) |
Resets the internal statistics of the elaborations. More... | |
sb_t_err | sb_project_get_stat (SB_HANDLE handle, sb_t_stat **const stat) |
Gets the statistics from the handle. More... | |
Project management interface.
See Solution and projects management for more information.
enum sb_t_project_mode |
enum sb_t_project_type |
sb_t_err sb_project_change_type | ( | const char *const | solution_file, |
const char *const | project_uuid, | ||
sb_t_project_type | project_type | ||
) |
Change the project type.
The function changes the project type in the solution file.
It also updates the project type in all rtn files associated with images in sb_t_svl_par::project_path.
The function returns SB_ERR_DIR_NOT_EXIST if sb_t_svl_par::project_path is not an existing folder, and SB_ERR_STRING_EMPTY if it is an empty string.
When the project type is changed the training and all the analysis results will be lost, moreover some data is initialized, others are kept.
Regarding the parameters of the project the models number, their name and sb_t_par. collaborations "collaboration matrix" are always kept.
While, for image data, ROI analysis and labeling can be retained or lost.
The following table shows what happens when you change the project type.
Source project type | Destination project type | ROI analysis | Samples | ROI defects | Model size | Network |
---|---|---|---|---|---|---|
Retina | Surface | full image | / | empty | / | / |
Deep Surface | full image | / | empty | / | initialized if necessary | |
Deep Cortex | / | / | / | / | initialized if necessary | |
Surface | Retina | full image | none | / | initialized | / |
Deep Surface | kept | / | kept | / | initialized if necessary | |
Deep Cortex | / | / | / | / | initialized if necessary | |
Deep Surface | Retina | full image | none | / | initialized if necessary | / |
Surface | kept | / | kept | / | / | |
Deep Cortex | / | / | / | / | initialized | |
Deep Cortex | Retina | full image | none | / | initialized if necessary | / |
Surface | full image | / | empty | / | / | |
Deep Surface | full image | / | empty | / | initialized |
[in] | solution_file | Solution file name. |
[in] | project_uuid | UUID of the project. |
[in] | project_type | New project type. |
sb_t_err sb_project_check_trained | ( | SB_HANDLE | handle, |
const char *const | model_name, | ||
float | scale, | ||
int *const | is_trained | ||
) |
Checks if the project is trained.
Usually, to check if a project is trained and the sb_project_detection function can be called, the function is called with model_name equal to NULL and scale equal to 0.
The function works in a slightly different way depending on the project type.
In case of a Surface project the model_name and scale parameters can be configured in 4 different ways explained below.
model_name | scale | Condition | is_trained |
---|---|---|---|
NULL | 0 | ||
All models are disabled | 1 | ||
All the enabled models and all their enabled scale levels are trained | 1 | ||
There is an enabled model with all scale levels disabled | 1 | ||
There is an enabled model with no scale levels | 0 | ||
There is an enabled model with an enabled scale level that is no trained | 0 | ||
The project has no models | 0 | ||
!=NULL | >=1.0 | ||
The model is disabled | 1 | ||
The model is enabled and the scale is disabled | 1 | ||
the specified combination model_name - scale has been trained | 1 | ||
the specified combination model_name - scale has not been trained | 0 | ||
NULL | >=1.0 | ||
All the enabled models that have the specified scale level are trained | 1 | ||
There is an enabled model with the specified scale level that is not trained | 0 | ||
!=NULL | 0 | ||
The model is disabled | 1 | ||
The model is enabled and all the enabled scale levels are trained | 1 | ||
The model is enabled and all the scale levels are disabled | 1 | ||
The model is enabled and it has no scale levels | 0 | ||
The model is enabled and there is an enabled scale level that is no trained | 0 |
In case of Retina, Deep Cortex or Deep Surface project type the parameter scale is not used, so the table can be simplified as the one below:
model_name | Condition | is_trained |
---|---|---|
NULL | ||
All models are disabled | 1 | |
All the enabled models are trained | 1 | |
The project has no models | 0 | |
!=NULL | ||
The model is disabled | 1 | |
The model is enabled and it is trained | 1 | |
The model is enabled but it isn't trained | 0 |
[in] | handle | Project Handle. |
[in] | model_name | Name of the model to be checked. If the model_name is not found the function returns the error SB_ERR_MODEL_NOT_FOUND. |
[in] | scale | Level scale to check. Used only by Surface projects. The permitted values are 0 and between SB_PAR_LEVEL_SCALE_MIN and SB_PAR_LEVEL_SCALE_MAX with steps of SB_PAR_LEVEL_SCALE_GRANULARITY, i.e. 1, 1.5, 2, 2.5 etc. If scale has no allowed value, the function returns the error SB_ERR_WRONG_PARAMETER. If the scale has an allowed value but it is not found the function returns the error SB_ERR_SCALE_NOT_FOUND. |
[out] | is_trained | It is set to 1 or 0, see the tables above. |
sb_t_err sb_project_clone | ( | SB_HANDLE | src, |
SB_HANDLE * | pdst, | ||
sb_t_project_mode | mode, | ||
int | regenerate_uuid | ||
) |
Clones the SqueezeBrains project.
The function returns the SB_ERR_PROJECT_LOAD_MODE error if the load mode of the source project is lower than the new load mode.
[in] | src | The source project handle. |
[out] | pdst | The pointer to the new project handle. |
[in] | mode | Loading method of the module of a project.
|
[in] | regenerate_uuid | If true it generates a new project uuid for the new project |
sb_t_err sb_project_copy_labeling | ( | const char *const | path_solution_dst, |
const char *const | path_solution_src, | ||
int | copy_roi, | ||
int | copy_labeling, | ||
int | verbosity | ||
) |
Copies the analysis roi and the labeling between two current projects of two different solutions.
For each image of the destination project it searches the source project for the image with the same name and if the .rtn file exists, it copies the required data.
The source and destination image must have the same resolution.
path_solution_dst | Folder of the destination solution, the current project is used |
path_solution_src | Folder of the source solution, the current project is used |
copy_roi | Set to 1 if you need to copy ROI analysis. |
copy_labeling | Set to 1 if you need to copy labeling (i.e. samples or ROI defects). |
verbosity | Message verbosity, 0 disable all trace |
sb_t_err sb_project_create | ( | SB_HANDLE * | phandle, |
const char *const | project_name, | ||
sb_t_project_type | project_type | ||
) |
Creates a new project of the specifed type.
[out] | phandle | Pointer to the project handle |
[in] | project_name | Project Name. |
[in] | project_type | Project type. |
Frees all the resources of the project handle.
[in,out] | phandle | Pointer to the project handle |
sb_t_err sb_project_destroy_par_changes_info | ( | sb_t_par_changes_info **const | par_changes_info | ) |
Destroys the structure.
[in,out] | par_changes_info | Pointer to the structure. The function sets it to NULL. |
sb_t_err sb_project_detection | ( | SB_HANDLE | handle, |
const sb_t_image *const | img, | ||
const sb_t_roi *const | roi, | ||
const sb_t_roi *const | roi_defects, | ||
const sb_t_samples *const | samples | ||
) |
Detection function.
The function elaborates the image inside the ROI.
You should use the function sb_project_get_res to get the results.
Remember to call sb_roi_evaluate_bounding_box if the ROI is changed.
In case of Surface and Deep Surface projects the function also executes a blob analysis on the voting plane in order to cluster the defects areas. The funcion does the blob analyis if the parameter roi_defects is valorized or if the sb_t_par.surface_blob_analysis is set.
If you want to reset the statistic you should call the funcion sb_project_reset_stat before to call sb_project_detection .
[in] | handle | Project handle. |
[in] | img | Pointer to the image. It is analyzed inside the ROI. |
[in] | roi | Pointer of the ROI. |
[in] | roi_defects | Pointer to the defects ROI. Is it used only with Surface and Deep Surface projects. The parameter can be NULL. In the case roi_defects is valorized, the function executes the blob analysis on the voting plane and does the following operation:
|
[in] | samples | Pointer to the samples of the image that is the ground truth or labeling. It is used only with Retina and Deep Cortex projects. The parameter can be NULL. If samples if valorized, the function works in test mode and can perform the following operation:
|
Returns the xml root node of your own custom parameters.
[in] | handle | Project handle. |
[out] | node_root | The variable is filled with the xml root node of your own custom parameters. The handle returned by the function must not be destroyed. |
sb_t_err sb_project_get_info | ( | SB_HANDLE | handle, |
sb_t_project_info * | project_info | ||
) |
Gets the project information from the handle.
[in] | handle | The project handle |
[out] | project_info | Pointer to the project information structure |
Gets the name from the project handle.
[in] | handle | Project handle. |
[out] | name | Pointer to the name. On successful return, this parameter will be filled with the pointer to the name. The pointer should be freed with sb_free. |
Gets the note from the project handle.
[in] | handle | Project handle. |
[out] | note | Pointer to the note. On successful return, this parameter will be filled with the pointer to the note. The pointer should be freed with sb_free. |
Retrieves the project parameters structure.
[in] | handle | Project handle. |
[out] | par | Pointer to the parameters structure. On successful return, this parameter will be filled with project parameters structure. |
sb_t_err sb_project_get_par_changes_info | ( | SB_HANDLE | handle, |
const sb_t_par *const | par, | ||
sb_t_par_changes_info **const | par_changes_info | ||
) |
Returns the information on what sb_project_set_par and sb_image_info_apply_par_changes do when they apply the new parameters.
[in] | handle | Project handle. |
[in] | par | Pointer to the new project parameters structure. |
[out] | par_changes_info | Pointer to the structure of information on parameter changes. The structure must be deallocated with sb_project_destroy_par_changes_info . |
Retrieves the results of the last elaborated image.
For more information see sb_t_res .
The field par in the structure sb_t_res is valorized with the parameters saved when the sb_project_detection function was last called.
[in] | handle | Module handle. |
[out] | res | Pointer to the results structure. On successful return, this parameter will be filled with the pointer to sb_t_res structure. The structure should be freed using the function sb_res_destroy. |
[in] | details | If 1 the function also exports some additional details. For Retina project the details are the weight images of each sample, that is the sb_t_sample::weights_image image. For Surface or Deep Surface project the details are the fields sb_t_res_model::surface in the models array sb_t_res::models. For Deep Cortex project the details are currently not available. |
sb_t_err sb_project_get_scale_offset | ( | SB_HANDLE | handle, |
sb_t_size_flt *const | scale_offset | ||
) |
Gets the scale offset from the project handle.
It works only for Deep Surface projects.
[in] | handle | The project handle |
[out] | scale_offset | The variable is filled with the scale offset. |
sb_t_err sb_project_get_sensitivity | ( | SB_HANDLE | handle, |
const char *const | model_name, | ||
float | scale, | ||
float *const | sensitivity | ||
) |
Gets the classification threshold from the project handle.
[in] | handle | The project handle |
[in] | model_name | Model name. |
[in] | scale | Scale value. Used only by Surface projects. |
[out] | sensitivity | The variable is filled with the classification sensitivity. |
Gets the statistics from the handle.
[in] | handle | Module handle. |
[out] | stat | Pointer to the statistics structure. On successful return, this parameter will be filled with the pointer to a sb_t_stat structure. The structure should be freed using the function sb_stat_destroy. The field par in the structure sb_t_stat is valorized with the parameters saved when the sb_project_detection function was last called. |
sb_t_err sb_project_get_svl_version | ( | SB_HANDLE | handle, |
sb_t_version *const | version, | ||
char *const | version_str, | ||
int | size_version_str | ||
) |
Returns the version of the SB library when the last SVL was made.
[in] | handle | Project handle. |
[out] | version | Pointer of the version structure. |
[out] | version_str | Pointer to the string, is filled with the SVL version for example "1.8.0.0". This parameter can be left to NULL if not necessary. |
[in] | size_version_str | Size of the version_str string. |
Eliminates the training of the models.
After calling this function it is necessary to do an SVL before to call again the functions sb_project_detection.
[in] | handle | Project Handle. |
[in] | model_name | Name of the model to be invalidated. If NULL all models will be invalidated. |
[in] | scale | Level / Scale to be invalidated. If 0 all levels will be invalidated. Used only by Surface projects. |
sb_t_err sb_project_load | ( | SB_HANDLE * | phandle, |
const char *const | solution_file, | ||
const char *const | project_uuid, | ||
sb_t_project_mode | mode | ||
) |
Loads an existing project from file.
The project resides in a solution together with other projects for which it is necessary to specify the UUID of the project that uniquely identifies it.
[out] | phandle | Pointer to the project handle |
[in] | solution_file | Filename of the project to load |
[in] | project_uuid | uuid of the project. To get the project uuid use the function sb_solution_get_info . |
[in] | mode | Loading mode of a project from a solution.
|
Resets the internal statistics of the elaborations.
[in] | handle | Module handle. |
sb_t_err sb_project_save | ( | SB_HANDLE | handle, |
const char *const | solution_file, | ||
sb_t_project_mode | mode | ||
) |
Saves the project to file.
The project is saved in a solution along with other projects.
[in] | handle | The project handle |
[in] | solution_file | Filename of the solution where to save the project. If NULL the function uses the parameter solution_file of the function sb_project_load used to create the project. |
[in] | mode | Saving mode of a project into a solution.
|
Sets the name into the project handle.
[in,out] | handle | Project handle. |
[in] | name | Name to be written. The string must be compliant to UTF-8 format. |
Sets the note into the project handle.
[in,out] | handle | Project handle. |
[in] | note | Note to be written. The string must be compliant to UTF-8 format. |
Sets the parameters structure into the project handle.
The function can invalidate the training if some critical parameter is changed.
In the following the list for each project type:
You can call the function sb_project_get_par_changes_info to know which models will be invalidated in a subsequent call of the function sb_project_set_par.
The following table describe all the possible situations in which a model (Retina and Surface) or a level (Surface) or the SVL (Deep Cortex and Deep Surface) will be invalidated or not.
Project type | Changes in parameters sb_t_par | Model is invalidated | Level is invalidated | SVL invalidated |
---|---|---|---|---|
Retina | The size of the model is changed | yes | ||
One of the models it collaborates with is invalidated due to changes in size | yes | |||
One of the models it collaborates with is deleted | yes | |||
The model's collaborations have been changed | yes | |||
The model is deleted | yes | |||
The order in the model array has been changed | no | |||
One of the models it collaborates with is disabled | no | |||
The model is disabled | no | |||
The parameter sb_t_svl_par::image_circularity_type is changed | yes | |||
Surface | One of the models it collaborates with is deleted | yes | ||
The model's collaborations have been changed | yes | |||
The model is deleted | yes | |||
The order in the model array has been changed | no | |||
One of the models it collaborates with is disabled | no | |||
The model is disabled | no | |||
The automatic choice of levels is enabled | yes | |||
The level is deleted | yes | |||
The level is disabled | no | |||
The parameter sb_t_par_sl::detection_out_of_roi is changed | yes | |||
The parameter sb_t_svl_par::image_circularity_type is changed | yes | |||
Deep Cortex | The network is changed | yes | ||
The order in the model array has been changed | yes | |||
A model is added | yes | |||
A model is deleted | yes | |||
The model's collaborations have been changed | yes | |||
sb_t_svl_dl_par_network::features_multiplier is changed | yes | |||
A model is disabled | no | |||
Deep Surface | The network is changed | yes | ||
The auto tiling is changed | yes | |||
The tile factor is changed | yes (iff auto tiling is disabled) | |||
The scale is changed | yes (iff auto tiling is enabled) | |||
The order in the model array has been changed | yes | |||
A model is added | yes | |||
A model is deleted | yes | |||
The model's collaborations have been changed | yes | |||
The parameter sb_t_svl_par::image_circularity_type is changed | yes | |||
sb_t_svl_dl_par_network::features_multiplier is changed | yes | |||
A model is disabled | no |
[in,out] | handle | Project handle. |
[in] | par | Pointer to the parameters structure. |
sb_t_err sb_project_set_scale_offset | ( | SB_HANDLE | handle, |
sb_t_size_flt | scale_offset | ||
) |
Sets in the project handle the scale offset used at detection time.
The scale offset give the possbility to the user to vary the scale used by sb_project_detection when auto tiling is enabled. It consists in a couple of positive values that is added to the sb_t_svl_dl_par.scale parameter in order to increase both horizontale and verticaly the actual scale used at detection time. Call this function may be useful when detection is performed over images at different resolution but at the same time is necessary to maintain fixed the number of tiles effectively used by the algorithm and the elaboration times. However, the usage by detection of a scale different from that used by SVL, may affect the results. Therefore it is not recommended to set sensitivity values higher than (1.0, 1.0)
It works only for Deep Surface projects.
[in] | handle | The project handle |
[in] | scale_offset | New value of scale offset to be set |
sb_t_err sb_project_set_sensitivity | ( | SB_HANDLE | handle, |
const char *const | model_name, | ||
float | scale, | ||
float | sensitivity | ||
) |
Sets the sensitivity of the detection in the project handle.
The sensitivity affects only the results of the detection and does not affect training in any way.
[in] | handle | The project handle. |
[in] | model_name | Name of the model to be set. If NULL all models will be set. |
[in] | scale | Level / Scale value. If 0 all levels will be set. Used only by Surface projects. |
[in] | sensitivity | New value of sensitivity to be set. The range of acceptable values is between -1 and 1 excluded. If the value is greater than 1 or less than -1, it is rounded to 1 and -1 respectively. |
const char * sb_project_type_format | ( | sb_t_project_type | type | ) |
Returns the string of the project type.
Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding value.
[in] | type | Project type. |