SqueezeBrains SDK 1.13
retina_detect.c
Go to the documentation of this file.
1
47#include "../common/common.h"
48
52int main(void)
53{
55 sb_t_info* sb_info = NULL;
56 SB_HANDLE project = NULL;
57 sb_t_roi* roi = NULL;
58 sb_t_image* image = NULL;
59 sb_t_res* res = NULL;
60 sb_t_folder* folder = NULL;
61 sb_t_solution_info* solution = NULL;
62 int i;
63
65 printf("Initialize the SqueezeBrains library\n");
66 CHECK_FN_GOTO(sb_init("../sb.lic"))
67
68 // Print library version.
69 CHECK_FN_GOTO(sb_get_info(&sb_info, 0))
70 printf("sb ver. %s, compiled on %s %s\n", sb_info->version_str, sb_info->compile_date, sb_info->compile_time);
71
73 printf("wait for license...\n");
75
76
77 CHECK_FN_GOTO(sb_solution_get_info("../images/wheels." SB_SOLUTION_EXT, &solution));
80 CHECK_FN_GOTO(sb_folder_load(&folder, "../images", "ppm", 1, 0))
81 for (i = 0; i < folder->n; i++)
82 {
84 CHECK_FN_GOTO(sb_image_load(&image, folder->file[i].name))
86 CHECK_FN_GOTO(sb_roi_create(&roi, image->width, image->height))
88 CHECK_FN_GOTO(sb_roi_set_rect(roi, 255, sb_rect(0, 0, image->width, image->height), 0))
90 CHECK_FN_GOTO(sb_project_detection(project, image, roi, NULL, NULL))
92 CHECK_FN_GOTO(sb_project_get_res(project, &res, 0))
93 // Print the results
94 printf("image: %s\n", folder->file[i].fname);
95 for (int j = 0; j < res->samples.size; ++j)
96 printf(" centre=(%d,%d), weight=%f\n", res->samples.sample[j].centre.x, res->samples.sample[j].centre.y, res->samples.sample[j].weight);
97 // Destroy the handles.
101 }
102
103FnExit:
105 sb_destroy_info(&sb_info);
106 sb_project_destroy(&project);
107 sb_image_destroy(&image);
108 sb_roi_destroy(&roi);
109 sb_res_destroy(&res);
110 sb_folder_destroy(&folder);
111 sb_solution_destroy_info(&solution);
112
114 printf("Release SqueezeBrains library\n");
115 sb_release();
116
117 printf("Press ENTER to terminate\n");
118 getchar();
119 return (int)err;
120}
EXTERN_C sb_t_err wait_license(void)
The functions wait until the license status is active.
Definition: common.c:11
#define CHECK_FN_GOTO(function)
Definition: common.h:34
sb_t_err
Errors code enum.
Definition: sb.h:5541
@ SB_ERR_NONE
No errors.
Definition: sb.h:5542
sb_t_err sb_folder_destroy(sb_t_folder **folder)
Frees all the resources of the sb_t_folder structure.
sb_t_err sb_folder_load(sb_t_folder **const f, const char *const path, const char *const ext, int sort, int verbosity)
Creates the list of the name of the files in a specified folder.
sb_t_err sb_destroy_info(sb_t_info **const info)
Destroys the structure.
sb_t_err sb_release(void)
Releases all the resources allocates in the library.
sb_t_err sb_init(const char *const license_file)
Initializes the SB library.
void * SB_HANDLE
HANDLE definition.
Definition: sb.h:6042
sb_t_err sb_get_info(sb_t_info **const info, int gpu_info)
The function gets information about the sb library and the available computational devices.
SB_INLINE sb_t_rect sb_rect(int x, int y, int width, int height)
Inline constructor of structure sb_t_rect.
Definition: sb.h:5918
sb_t_err sb_image_destroy(sb_t_image **const pimg)
Destroys the image.
sb_t_err sb_image_load(sb_t_image **const img, const char *const file)
Loads an image from a file.
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.
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.
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.
sb_t_err sb_project_destroy(SB_HANDLE *phandle)
Frees all the resources of the project handle.
@ SB_PROJECT_MODE_DETECTION_ONLY
Load/save the minimum module information to allow detection.
Definition: sb.h:9026
sb_t_err sb_res_destroy(sb_t_res **const res)
Destroys the module results structure.
sb_t_err sb_roi_set_rect(sb_t_roi *const roi, unsigned char gl, sb_t_rect rect, int reset_roi)
Sets a rectangular ROI.
sb_t_err sb_roi_create(sb_t_roi **const roi, int width, int height)
Creates a ROI.
sb_t_err sb_roi_destroy(sb_t_roi **const roi)
Destroys the ROI.
sb_t_err sb_solution_get_info(const char *const solution_file, sb_t_solution_info **const solution)
Returns the information contained in the solution_file.
#define SB_SOLUTION_EXT
Extension of the SqueezeBrains solution file.
Definition: sb.h:8925
sb_t_err sb_solution_destroy_info(sb_t_solution_info **const solution)
Destroys the structure of the solution information.
int main(void)
Definition: retina_detect.c:52
char name[256]
Name of the file included of path.
Definition: sb.h:6578
char * fname
Name of file excluded the path.
Definition: sb.h:6579
defines the list of the file in a folder.
Definition: sb.h:6586
sb_t_file * file
Array of files.
Definition: sb.h:6587
int n
Number of elements of the array file.
Definition: sb.h:6588
Defines an image.
Definition: sb.h:7310
int width
Width, in pixel, of the image.
Definition: sb.h:7314
int height
Height, in pixel, of the image.
Definition: sb.h:7315
General information about sb library and computing devices like CPU and GPUs.
Definition: sb.h:6180
char compile_time[32]
String with the compilation time of the sb library.
Definition: sb.h:6184
char compile_date[32]
String with the compilation date of the sb library.
Definition: sb.h:6183
char version_str[16]
String with the version of the sb library.
Definition: sb.h:6182
int x
abscissa of the point
Definition: sb.h:5766
int y
ordinate of the point
Definition: sb.h:5767
char uuid[SB_PROJECT_UUID_LEN]
Project UUID.
Definition: sb.h:8901
sb_t_project_info * info
Array of solution project information.
Definition: sb.h:8911
Results of detection.
Definition: sb.h:11276
sb_t_samples samples
Samples found in the image.
Definition: sb.h:11296
Defines a roi.
Definition: sb.h:7730
sb_t_point centre
Coordinates of the centre of the sample.
Definition: sb.h:8126
float weight
Weight of classification.
Definition: sb.h:8223
int size
Number of samples that is number of elements of the array sb_t_samples::sample .
Definition: sb.h:8379
sb_t_sample * sample
Pointer to the array of sample. The number of element is sb_t_samples::size .
Definition: sb.h:8378
Solution info structure.
Definition: sb.h:8931
sb_t_projects_info projects
Array of the projects info.
Definition: sb.h:8932
int current_project
Index of the current project in the projects array.
Definition: sb.h:8933