Data Structures | |
| struct | VCSFInit |
| Smart Finder Initialisation. More... | |
| struct | VCSFCfg |
| Smart Finder Configuration. More... | |
| struct | VCSFPat |
| Smart Finder Pattern. More... | |
| struct | VCSFResult |
| Smart Finder Result. More... | |
Macros | |
| #define | VCSFInit_Default { 0, 255, 1.0, 1.0, 2,{2,0,0,0},{6,2,0,0},{3,0,0,0},{0.1,0.008,0.0,0.0},{3,1,0,0}, 2,{1,1,0,0}} |
| #define | vc_sf_pre_mask_small_regions(imgIn, imgOut, minPixel) vc_image_fill_small_regions(imgIn, imgOut, 0, 1, 256, 1, minPixel, 0) |
| Remove Small Noise Regions from Edge Image (Macro). More... | |
Functions | |
| I32 | vc_sf_init (VCSFCfg *cfg, VCSFInit *init) |
| Initializes the Smartfinder Configuration. More... | |
| I32 | vc_sf_deinit (VCSFCfg *cfg) |
| Deinitializes the Smartfinder. More... | |
| I32 | vc_sf_match_image (image *img, VCSFPat *pat, VCSFCfg *cfg, VCSFResult *result) |
| Finds a Pattern Location at an Image. More... | |
| I32 | vc_sf_pattern_from_img (image *vec, VCSFPat *pat, VCSFCfg *cfg) |
| Generates a Pattern from a Vector Image. More... | |
| I32 | vc_sf_pattern_from_file (char *path, VCSFPat *pat, VCSFCfg *cfg) |
| Reads a Pattern from a File. More... | |
| I32 | vc_sf_pattern_from_xylist_I16 (U32 pxCount, I16 *xy, U8 *dir, VCSFPat *pat, VCSFCfg *cfg) |
| Generates a Pattern from a Pixel List (I16). More... | |
| I32 | vc_sf_pattern_to_file (char *path, VCSFPat *pat) |
| Stores a Pattern in a File. More... | |
| I32 | vc_sf_pattern_free (VCSFPat *pat) |
| Frees Memory of a Smartfinder Pattern Structure. More... | |
| I32 | vc_sf_searchimagepattern_generate (VCSFPat *patImg, image *vec, VCSFCfg *cfg) |
| Convert edge search image (vector image) for matching. More... | |
| I32 | vc_sf_match_patterns (VCSFPat *patImg, VCSFPat *pat, VCSFCfg *cfg, VCSFResult *result) |
| Finds a Pattern Location at a Search Image Pattern. More... | |
The smart finder locates patterns under varying rotation or scale at an image. Depending on the needs, the detected rotation angles and scales can be specified by setting interval boundaries. Limiting angles and scales not only dramatically reduces calculation time but also enhances detection reliability.
The angle resolution is 1.4 degrees. The rotation of the pattern when trained defines the zero degree angle. Also the scale factor of 1.0 is defined as the scale of the pattern when trained.
The lesser edges are included for the pattern, the faster the algorithm works.
Minimalistic Example, please also refer to the 'vcdemo_smartfinder'!
| struct VCSFInit |
This structure sets up the the smart finder configuration.
| Data Fields | ||
|---|---|---|
| I32 | angleAng8Start |
start angle of pattern in search image [-128..127] * 1.4deg, 0 is pattern angle |
| I32 | angleAng8End |
stop angle of pattern in search image [-128..127] * 1.4deg, 0 is pattern angle |
| F32 | scaleMin |
Minimum scale of pattern in search image, 1.0 is 100% |
| F32 | scaleMax |
Maximum scale of pattern in search image, 1.0 is 100% |
| I32 | rasters | |
| I32 | patRasterSize[VCSFMaxRasters] | |
| I32 | imgRasterSize[VCSFMaxRasters] | |
| I32 | rasterSizePow[VCSFMaxRasters] | |
| F32 | patRasterScaleStep[VCSFMaxRasters] | |
| I32 | patRasterDirStep[VCSFMaxRasters] | |
| U8 | patSegments | |
| U8 | patSegWeight[VCSFMaxSegments] | |
| struct VCSFCfg |
This structure contains settings for the smart finder.
| struct VCSFPat |
This structure contains a pattern for a smart finder matching operation.
| struct VCSFResult |
| #define VCSFInit_Default { 0, 255, 1.0, 1.0, 2,{2,0,0,0},{6,2,0,0},{3,0,0,0},{0.1,0.008,0.0,0.0},{3,1,0,0}, 2,{1,1,0,0}} |
Smart Finder Default Settings
| #define vc_sf_pre_mask_small_regions | ( | imgIn, | |
| imgOut, | |||
| minPixel | |||
| ) | vc_image_fill_small_regions(imgIn, imgOut, 0, 1, 256, 1, minPixel, 0) |
The function removes small noise present in an edge image later used for pattern generation or pattern matching at the smartfinder. Depending on the application this pre-filtering may enhance detection stability and speed.
The function should be used between the edge() call and the call of the function vc_sf_match_image().
vc_sf_pre_mask_small_regions() is a macro which calls vc_image_fill_small_regions().
| imgIn | Input Edge Image. |
| imgOut | Output Edge Image, may be identical to imgIn. |
| minPixel | Pixel areas with less than this count will be filled with zero at the magnitude part of the edge image, and thus not used by the smartfinder. |
The function initializes the Smartfinder with given initalisation values.
If you want to add your own initialisation settings, please be sure to first pass default values to the initialisation structure, e.g. the contents of the definition VCSFInit_Default, and afterwards apply your changes:
You can provide NULL as value for init, then default values will be used as being given by VCSFInit_Default.
| cfg | Smart Finder Configuration. |
| init | Smart Finder Initialisation Values, or NULL for default values. |
| ERR_PARAM | if rasters or patSegments exceed the maximum allowed value. |
| ERR_INIT | on failing internal initialisation. |
| ERR_MEMORY | if memory allocation fails. |
| ERR_NONE | on success. |
The function deinitializes the Smartfinder.
| cfg | Smart Finder Settings. |
| I32 vc_sf_match_image | ( | image * | vec, |
| VCSFPat * | pat, | ||
| VCSFCfg * | cfg, | ||
| VCSFResult * | result | ||
| ) |
The function matches a smartfinder pattern to similar data in an image. This is the main entry for searching a pattern in an edge image (vector image).
| vec | The Image to be Searched in, must be of type IMAGE_VECTOR. |
| pat | Pattern to be Matched. |
| cfg | Smartfinder Settings, must be initialized beforehand. |
| result | Result Output. |
The function generates a smartfinder pattern from a given vector image which then can be used to find similar data in an image. Since the pattern structure is initialized internally, you have to free the pattern when you do not need it anymore by calling the function vc_sf_pattern_free().
| vec | Source Image of type IMAGE_VECTOR, magnitude 0 marks pattern pixels. |
| pat | Pattern Output. |
| cfg | Ahead Initialized Smartfinder Settings. |
The function generates a smartfinder pattern from a previously stored file which then can be used to find similar data in an image. Since the pattern structure is initialized internally, you have to free the pattern after you do not need it anymore by calling the function vc_sf_pattern_free().
| path | Pattern File to Load. |
| pat | Pattern Output. |
| cfg | Ahead Initialized Smartfinder Settings. |
| ERR_OPEN | if requested file could not be opened for reading. |
The function generates a smartfinder pattern from a given I16 pixel list which then can be used to find similar data in an image. Since the pattern structure is initialized internally, you have to free the pattern after you do not need it anymore by calling the function vc_sf_pattern_free().
IMPORTANT: The xy-list must be lexicographically sorted, i.e. all pixels must be sorted top-down for y and left-to-right for x like the raster scan of a CRT.
| pxCount | Number of Pixels for the xy-list. |
| xy,dir | Source pixels and its directions. |
| pat | Pattern Output. |
| cfg | Pre-initialized Smartfinder Settings. |
The function writes a smartfinder pattern to a file which then can be loaded by the function vc_sf_pattern_from_file().
| path | Pattern File to Store to. |
| pat | Pattern Input. |
| ERR_OPEN | if requested file could not be opened for writing. |
The function frees memory allocated for a loaded/teached pattern structure.
| pat | Pattern to be freed. |
This function generates a smartfinder pattern from the vector image wherein other patterns should be found. Since the pattern structure is initialized internally, you have to free the pattern when you do not need it anymore by calling the function vc_sf_pattern_free().
| vec | Source Image of type IMAGE_VECTOR. |
| pat | Pattern Output. |
| cfg | Smartfinder Settings, must be initialized beforehand. |
| I32 vc_sf_match_patterns | ( | VCSFPat * | patImg, |
| VCSFPat * | pat, | ||
| VCSFCfg * | cfg, | ||
| VCSFResult * | result | ||
| ) |
The function matches a smartfinder search pattern to a search image pattern. The Search Image Pattern patImg must be generated using the function vc_sf_searchimagepattern_generate() while the patterns to be searched must be generated using the function vc_sf_pattern_from_img() or another function starting with vc_sf_pattern_from_..().
If only one pattern has to be matched see vc_sf_match_image() instead. To search for more than one pattern utilize this function in the following manner:
| patImg | Search Image Pattern (vc_sf_searchimagepattern_generate()). |
| pat | Pattern to be found at the Search Image (e.g. vc_sf_pattern_from_file()). |
| cfg | Smartfinder Settings, must be initialized beforehand. |
| result | Result Output. |