SB SDK 1.11
Samples

Samples interface. More...

Collaboration diagram for Samples:

Data Structures

struct  sb_t_sample_weights_image
 Image of weights of the sample. More...
 
struct  sb_t_sample
 Sample of an image. More...
 
struct  sb_t_samples
 Samples of an image. More...
 

Enumerations

enum  sb_t_obj_type { SB_OBJ_TEST = 0 , SB_OBJ_LEARNING }
 Defines the type of the object. More...
 
enum  sb_t_truth {
  SB_TRUTH_UNDEFINED = 0 , SB_TRUTH_TRUE_POSITIVE , SB_TRUTH_TRUE_NEGATIVE , SB_TRUTH_FALSE_POSITIVE ,
  SB_TRUTH_FALSE_NEGATIVE , SB_TRUTH_OPTIONAL_POSITIVE , SB_TRUTH_OPTIONAL_NEGATIVE , SB_TRUTH_OUT_OF_ROI ,
  SB_TRUTH_MODEL_DISABLED
}
 Type of truth of a sample. More...
 
enum  sb_t_sample_classify_mode { SB_SAMPLE_REQUIRED = 0 , SB_SAMPLE_OPTIONAL }
 Enumeration of the classification modes of a sample. More...
 

Functions

const char * sb_format_truth (sb_t_truth truth)
 Returns the string of the truth of the object. More...
 
sb_t_err sb_sample_clone (const sb_t_sample *const src, sb_t_sample *const dst)
 Copies a single sample. More...
 
sb_t_err sb_sample_destroy (sb_t_sample *const sample)
 Destroys the content of sample structure. More...
 
sb_t_err sb_sample_weights_image_overlay (sb_t_image *const image, const sb_t_sample *const s)
 Draws the image of the weights of the sample on a image. More...
 
sb_t_err sb_samples_create (sb_t_samples **const samples)
 Creates a samples structure. More...
 
sb_t_err sb_samples_destroy (sb_t_samples **const samples)
 Destroy the samples structure. More...
 
sb_t_err sb_samples_clone (sb_t_samples **const dst, const sb_t_samples *const src)
 Copies the samples of an image. More...
 
sb_t_err sb_samples_insert (sb_t_samples *const samples, const sb_t_sample *const sample, int sample_index)
 Inserts a sample in the list of the samples of an image. More...
 
sb_t_err sb_samples_remove (sb_t_samples *const samples, int sample_index)
 Removes a sample from the list of the samples of an image. More...
 
sb_t_err sb_sample_get_vertex (sb_t_point centre, float scale, sb_t_size obj_size, sb_t_point *const ul, sb_t_point *const br, sb_t_size *const size)
 Evaluates the vertices of the rectangle of the sample. More...
 
sb_t_err sb_sample_get_model_index (const sb_t_sample *const s, SB_HANDLE handle, int *const model_index)
 Returns the model index of the sample. More...
 
sb_t_err sb_sample_get_level_index (const sb_t_sample *const s, SB_HANDLE handle, int *const level_index)
 Returns the index of scale level of the sample. More...
 
sb_t_err sb_samples_distance (SB_HANDLE project, const sb_t_sample *const sample1, const sb_t_sample *const sample2, float *const distance, int *const are_near)
 Evaluates the distance between two samples. More...
 

Detailed Description

Samples interface.

Enumeration Type Documentation

◆ sb_t_obj_type

Defines the type of the object.

The values are 32 bits both for 32 and 64 bits library version.

Enumerator
SB_OBJ_TEST 

Object is not used for learning.

SB_OBJ_LEARNING 

Object is used for learning.

Definition at line 7290 of file sb.h.

◆ sb_t_sample_classify_mode

Enumeration of the classification modes of a sample.

The values are 32 bits both for 32 and 64 bits library version.

See also
sb_t_sample.classify_mode
Enumerator
SB_SAMPLE_REQUIRED 

The sample must be found, otherwise it will be classified as False Negative.

SB_SAMPLE_OPTIONAL 

The positive sample is optional in the sense that if it is found it is classified as Optional Positive, otherwise as Optional Negative. Another way to define an optional sample is a "border line" or a "boundary" sample, in the sense, it is not clear if it is a positive or negative instance, if it is a good or bad sample.

Definition at line 7369 of file sb.h.

◆ sb_t_truth

enum sb_t_truth

Type of truth of a sample.

The values are 32 bits both for 32 and 64 bits library version.
The SB GUI uses the following conventional colors to represent the truth of sample occurrences and defects.

truth color map
Enumerator
SB_TRUTH_UNDEFINED 

Truth not defined.

SB_TRUTH_TRUE_POSITIVE 

Truth True Positive.

It is an occurrences with positive weight.

SB_TRUTH_TRUE_NEGATIVE 

Truth True Negative.

In case of Retina detection it is used:

  • an occurrence with negative weight. It can happen when the parameter sb_t_par_model::num_occurrences has a value other than 0.
  • to classify an image that meets the following conditions:
    • there are no occurrences
    • all required samples have disabled models
    • the optional samples are ignored In case of Surface it is the sample of the background.
SB_TRUTH_FALSE_POSITIVE 

Truth False Positive.

A object occurrence was found in a wrong place, or it was identified with the wrong model.

SB_TRUTH_FALSE_NEGATIVE 

Truth False Negative.

A object occurrence wasn't found.

SB_TRUTH_OPTIONAL_POSITIVE 

Truth Optional Positive.

A optional sample with positive weight.

SB_TRUTH_OPTIONAL_NEGATIVE 

Truth Optional Negative.

A optional sample with negative weight.

SB_TRUTH_OUT_OF_ROI 

Truth Out Of ROI.

The sample is out of the ROI and then it is not found, but it cannot become a False Negative.
In this case the object will not be considered in the statistic.

SB_TRUTH_MODEL_DISABLED 

A sample of a disabled model.

Definition at line 7302 of file sb.h.

Function Documentation

◆ sb_format_truth()

const char * sb_format_truth ( sb_t_truth  truth)

Returns the string of the truth of the object.

Interprets the contents of the code and converts it to a C-string containing a human-readable version of the corresponding truth.
The string must not be freed.

Parameters
[in]truthTruth of the sample.
Returns
A C-string containing the truth of the object in a human-readable format.

◆ sb_sample_clone()

sb_t_err sb_sample_clone ( const sb_t_sample *const  src,
sb_t_sample *const  dst 
)

Copies a single sample.

Parameters
[in]srcPointer to the structure of the source sample.
[out]dstPointer to the structure of the destination sample.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_sample_destroy

◆ sb_sample_destroy()

sb_t_err sb_sample_destroy ( sb_t_sample *const  sample)

Destroys the content of sample structure.

Parameters
[in,out]sampleSample to be destroy.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_sample_clone

◆ sb_sample_get_level_index()

sb_t_err sb_sample_get_level_index ( const sb_t_sample *const  s,
SB_HANDLE  handle,
int *const  level_index 
)

Returns the index of scale level of the sample.

Parameters
[in]sPointer to the sample.
[in]handleProject handle.
[out]level_indexThe variable is filled with the index of the scale level in the sb_t_models structure
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_sample_get_model_index()

sb_t_err sb_sample_get_model_index ( const sb_t_sample *const  s,
SB_HANDLE  handle,
int *const  model_index 
)

Returns the model index of the sample.

Parameters
[in]sPointer to the sample.
[in]handleProject handle.
[out]model_indexThe variable is filled with the index of the model in the sb_t_par structure
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_sample_get_vertex()

sb_t_err sb_sample_get_vertex ( sb_t_point  centre,
float  scale,
sb_t_size  obj_size,
sb_t_point *const  ul,
sb_t_point *const  br,
sb_t_size *const  size 
)

Evaluates the vertices of the rectangle of the sample.

Parameters
[in]centreCoordinates of the sample centre.
[in]scaleScale factor of the object.
[in]obj_sizeDimension, in pixel, of the model of the sample.
[out]ulUpper Left corner. ul = center - size / 2. It can be NULL.
[out]brBotton Right corner. br = ul + size. It can be NULL.
[out]sizeDimension, in pixel, of the real object. size = model_sixe * scale. It can be NULL
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_sample_weights_image_overlay()

sb_t_err sb_sample_weights_image_overlay ( sb_t_image *const  image,
const sb_t_sample *const  s 
)

Draws the image of the weights of the sample on a image.

Warning
The image must have the same resolution of the one used to detect the sample.

The function draws the weights using a variable trasparence: is zero for weight equal to zero and increase up to 1 for weight equal to the maximum or the minimum.

Parameters
[in,out]imagedestination image.
[in]sPointer to the structure of the sample.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_samples_clone()

sb_t_err sb_samples_clone ( sb_t_samples **const  dst,
const sb_t_samples *const  src 
)

Copies the samples of an image.

Parameters
[out]dstPointer to the new structure of samples.
On successful return, this parameter will be updated with the pointer of the structure sb_t_samples.
[in]srcPointer to the structure of the samples to be copied.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_samples_create
sb_samples_remove
sb_samples_insert
sb_samples_destroy
sb_image_info_get_samples
sb_image_info_set_samples

◆ sb_samples_create()

sb_t_err sb_samples_create ( sb_t_samples **const  samples)

Creates a samples structure.

Parameters
[out]samplesPointer to samples.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_samples_destroy
sb_samples_remove
sb_samples_insert
sb_samples_destroy
sb_image_info_set_samples

◆ sb_samples_destroy()

sb_t_err sb_samples_destroy ( sb_t_samples **const  samples)

Destroy the samples structure.

Parameters
[in,out]samplesPointer to the samples structure. On successful return it is set to NULL.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_samples_create
sb_samples_clone
sb_image_info_get_samples

◆ sb_samples_distance()

sb_t_err sb_samples_distance ( SB_HANDLE  project,
const sb_t_sample *const  sample1,
const sb_t_sample *const  sample2,
float *const  distance,
int *const  are_near 
)

Evaluates the distance between two samples.

Parameters
[in]projectProject handle.
[in]sample1Pointer to the first sample.
[in]sample2Pointer to the second sample.
[out]distancePointer to the distance. It can be NULL.
[out]are_nearIt is set to 1 if the samples have a distance less than the sb_t_par_model::obj_min_distance , 0 otherwise. It can be NULL.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_t_par_model::obj_min_distance

◆ sb_samples_insert()

sb_t_err sb_samples_insert ( sb_t_samples *const  samples,
const sb_t_sample *const  sample,
int  sample_index 
)

Inserts a sample in the list of the samples of an image.

Parameters
[in,out]samplesPointer to the structure of the samples.
[in]samplePointer to the sample to be added.
[in]sample_indexIndex position where inserts the sample.
If the index is < 0 or greater than the number to sample, the new sample will be added last.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_samples_create
sb_samples_remove
sb_samples_clone
sb_samples_destroy
sb_image_info_get_samples
sb_image_info_set_samples

◆ sb_samples_remove()

sb_t_err sb_samples_remove ( sb_t_samples *const  samples,
int  sample_index 
)

Removes a sample from the list of the samples of an image.

Parameters
[in,out]samplesPointer to the structure of the samples.
[in]sample_indexIndex of the sample to remove.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_samples_create
sb_samples_insert
sb_samples_clone
sb_samples_destroy
sb_image_info_get_samples
sb_image_info_set_samples