2using System.Collections.Generic;
5using System.Threading.Tasks;
39 Console.WriteLine(
"Sb Init");
40 err =
Sb.
Init(
"../../../sb.lic");
43 Console.WriteLine(
"Sb.Init failed with error " + err);
48 Console.WriteLine(
"Wait for license...");
49 err = Common.WaitLicense();
52 Console.WriteLine(
"SbLicense.WaitLicense failed with error " + err);
60 if (solutionInfo ==
null || solutionInfo.
Error() !=
SbError.SB_ERR_NONE)
62 err = solutionInfo ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : solutionInfo.
Error();
63 Console.WriteLine(
"SbSolution.GetInfo failed");
66 else if (solutionInfo.
projects.Length == 0)
68 err =
SbError.SB_ERR_PROJECT_NOT_FOUND;
69 Console.WriteLine(
"SbSolution.GetInfo no projects found");
72 Console.WriteLine(
"SbSolutionInfo.GetInfo, found " + solutionInfo.
projects.Length +
" projects");
76 if (slice ==
null || slice.
Error() !=
SbError.SB_ERR_NONE)
78 err = slice ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : slice.
Error();
79 Console.WriteLine(
"SbProject.Load failed with error " + err);
87 err = hole ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : hole.
Error();
88 Console.WriteLine(
"SbProject.Load failed with error " + err);
95 for (
int i = 0; i < folder.
files.Length; i++)
101 Console.WriteLine(
"SbImage.Load " + folder.
files[i] +
" failed");
102 err = img ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : img.
Error();
110 Console.WriteLine(
"SbRoi.Create failed");
111 err = roi ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : roi.
Error();
117 if (err !=
SbError.SB_ERR_NONE)
119 Console.WriteLine(
"SbRoi.SetRect failed with error " + err);
125 if (err !=
SbError.SB_ERR_NONE)
127 Console.WriteLine(
"SbProject.Detection failed with error " + err);
133 if (res_slice ==
null || slice.
Error() !=
SbError.SB_ERR_NONE)
135 err = res_slice ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : slice.
Error();
136 Console.WriteLine(
"SbProject.GetRes failed with error " + err);
140 Console.WriteLine(
" slice detection time=" + (res_slice.
timeUs / 1000.0f) +
"ms, " + res_slice.
samples.Length +
" slices found");
142 for (
int j = 0; j < res_slice.
samples.Length; ++j)
146 if (err !=
SbError.SB_ERR_NONE)
148 Console.WriteLine(
"SbRoi.SetRect failed with error " + err);
154 if (err !=
SbError.SB_ERR_NONE)
156 Console.WriteLine(
"SbProject.Detection failed with error " + err);
162 if (res_hole ==
null || hole.
Error() !=
SbError.SB_ERR_NONE)
164 err = res_hole ==
null ?
SbError.SB_ERR_INSUFFICIENT_FREE_MEMORY : hole.
Error();
165 Console.WriteLine(
"SbProject.GetRes failed with error " + err);
168 Console.WriteLine(
" slice " + j +
": hole detection time=" + (res_hole.
timeUs / 1000.0f) +
", " + res_hole.
samples.Length +
" holes found");
170 for (
int k = 0; k < res_hole.
samples.Length; ++k)
171 Console.WriteLine(
" centre=(" + res_hole.
samples[k].centre.x +
"," + res_hole.
samples[k].centre.y +
") weight=" + res_hole.
samples[k].weight);
199 Console.WriteLine(
"Release SqueezeBrains library");
202 Console.WriteLine(
"Press ENTER to terminate");
208 static void Main(
string[] args)
Tutorial 7 - Retina - How to use more than one project to detect objects.
SbError Error()
Returns the error code of the last operation. If no error SbError.SB_ERR_NONE is returned.
static const String SbSolutionExt
Solution file extension
Folder Class that wraps the sb_t_folder structure
static SbFolder Load(String^ path, String ^ext, bool sort, int verbosity)
Creates the list of the name of the files in a specified folder.
array< String^> files
Array of files.
static SbError Release()
Releases all the resources allocated in the library
static SbError Init(String ^ license_file)
Init the SB Library. The function initializes all the functionalities of the library including the li...
SbImage class that wraps the sb_t_image structure. You must call the Dispose() method to free all the...
int Height()
Height, in pixel, of the image.
static SbImage Load(String^ filename)
Loads an image from file.
int Width()
Width, in pixel, of the image.
Project Class You must call the Dispose() method to free all the resources of the returned instance.
static SbProject Load(String^ solution_file, String^ project_uuid, SbProjectMode mode)
Loads an existing project from file.
SbRes GetRes(bool details)
Retrieves the results of the last processed image
SbError Detection(SbImage ^img, SbRoi ^roi)
The function elaborates the image inside the ROI. For Surface projects the function computes also the...
Rectangle class that wraps the sb_t_rect structure
Class of the results of the image elaboration with the SbProject::Detection method....
long long timeUs
Detection time
array< SbSample^> samples
Samples results. Only Retina projects
ROI Class that wraps the sb_t_roi structure. You must call the Dispose() method to free all the resou...
static SbRoi Create(int width, int height)
Creates a ROI.
SbError SetRect(int gl, SbRect^ rect, bool reset_roi)
Sets a rectangular ROI.
static SbSolutionInfo GetInfo(String^ solution_file)
Returns the information contained in the solution_file.
Solution Info Class that wraps the sb_t_solution_info structure
array< SbProjectInfo^> projects
Array of the projects information of the solution. sb_t_solution_info.projects
SbProjectMode
Project loading or saving mode that wraps the sb_t_project_mode enum