SqueezeBrains SDK 1.18
retina_multi_project.c File Reference

Tutorial 7 - Retina - How to use more than one project to detect objects. More...

#include "../common/common.h"
Include dependency graph for retina_multi_project.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Tutorial 7 - Retina - How to use more than one project to detect objects.

There are many cases in which you have to find objects and then analyze some parts inside the objects, for example to check the presence / absence of parts, or to the search for the defects.
To do this in a reliable and fast way it is necessary to use more than one retina project, the first one to detect the object regardless of how it is done, and the second one to analyze the object inside.
In the code, for each retina project, there will be a call of the function sb_project_detection .
Practically the first project only serves to set the ROI for the second project.
The first project works in a fixed ROI and for each occurrences of the object sets a ROI for the second project.
In order to reduce the computation time the models of the objects in the first project should be as small as possibile, keeping in mind that you can use the scale to fit the object dimension, instead the dimension of the models in the second project should be great enought to allow you to find the parts or the defects.
So we will be able to reduce the computation time and to not loose reliability because the first project works in a big fixed ROI with small models, instead the second project works in small dinamic ROI with great models.
In this tutorial the problem is to find the slices of gruyere and the holes inside them.
We have created 4 synthetic images each of them contains one or more slices of gruyere cheese.
You will find the images in the installation folder C:/SqueezeBrains/1.13/sb_tutorials/C++/tutorial_07_retina_multi_project/dataset .
2 projects have been created with "SB GUI" inside the solution tutorial_7_retina_multi_project.rprj.
You will find the solution in the folder C:/SqueezeBrains/1.13/sb_tutorials/C++/tutorial_07_retina_multi_project/solution

  • Project slice
    The aim of the project is to detect the slices of gruyere cheese and to use their position to create analysis ROI for the project "hole" that has to find holes inside the slice.
    Because the model is small the coarse and the fine step have been reduced respectively to 4 and 2.
    The following precautions have been done in order to reduce the computation time:
    1. dimension of the model = 64x40 (as small as possible)
    2. scale factor = 5
    3. number of thread = 4 (equal to the number of phisical core of the pc)
    4. optimization level = 10%.
    5. SVL optimization mode = fast
  • Project holes
    The aim of the project is to detect the holes inside the slices of gruyere cheese.
    Because the model is small the coarse and the fine step have been reduced respectively to 4 and 2.
    The following precautions have been done in order to reduce computation time:
    1. the detection uses a rectangular ROI centered on the slice.
    2. number of thread = 4 (equal to the number of phisical core of the pc)
    3. optimization level = 40%.
    4. SVL optimization mode = fast

In the following section there is a description of the steps.

  • It loads the handle Retina of the two projects, "slice" and "hole", with the function sb_project_load and prints their configuration parameters on the console.
  • Then it scans the images in the folder using sb_folder_load and it processes each image performing these operations:
    • it loads the image with the function sb_image_load
    • it creates a ROI with the function sb_roi_create on the first image
    • it sets a rectangular region equal to the image dimensions with sb_roi_set_rect
    • it finds the slices of gruyere calling sb_project_detection with the Retina handle of the project "slice"
    • for each slice:
      • it creates a rectangular ROI equal to the slice dimension
      • it finds the holes calling sb_project_detection with the Retina handle of the project "hole"

It is worth noting that in the case there are more that one slice, to reduce the computation time, each slice is elaborated separately, which means that you have to call sb_project_detection for each slice. For more information on the ROI see ROI management .

See also
sb_init
sb_release
sb_get_info
sb_license_get_info
sb_folder_load
sb_folder_destroy
sb_par_format
sb_solution_get_info
sb_solution_destroy_info
sb_project_load
sb_project_destroy
sb_project_get_par
sb_project_set_par
sb_project_detection
sb_project_get_res
sb_res_destroy
sb_image_load
sb_image_destroy
sb_roi_create
sb_roi_destroy
sb_roi_set_rect

Definition in file retina_multi_project.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

In the following the list of the program steps.

  1. Initialization of the SqueezeBrains library.
  2. Wait until the license is active.
  3. Get the solution information. The solution has two projects, "slice" and "hole"
  4. Load the Retina projects from solution file and print configuration parameters.
  5. Scan the images in the dataset folder and for each image:
    • find the slices of gruyere
    • find the holes in the slice
  6. Release the handles and the library
  7. Release the library.

Definition at line 84 of file retina_multi_project.c.

Here is the call graph for this function: