Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Minos_CodeExample01.py
Go to the documentation of this file.
1import os
2import cvb.minos
4
5if __name__ == '__main__':
6
7 # Load the image
8 image = cvb.Image.load(os.path.join(cvb.install_path(), "Tutorial/Minos/Images/Clara/Clara1.bmp"))
9
10 # Load the classifier
11 classifier = cvb.minos.Classifier(os.path.join(cvb.install_path(), "Tutorial/Minos/Images/Clara/Clara.clf"))
12
13 # define the search area: complete image
14 w = image.width
15 h = image.height
16 search_aoi = cvb.Area2D(cvb.Point2D(0.0, 0.0), # top left
17 cvb.Point2D(w-1, 0.0), # top right
18 cvb.Point2D(0.0, h-1)) # bottom left
19
20 # Perform pattern recognition
21 search_result = classifier.search(image.planes[0], cvb.minos.SearchMode.FindFirst, search_aoi, density=1000)
22 x = search_result.position.x
23 y = search_result.position.y
24 q = search_result.quality
25 print(x, y, q) # x=94.0, y=135.0, q=26.0
26
27 # Refine the result to subpixel accuracy
28 search_aoi = cvb.Area2D(cvb.Point2D(x-10, y-10), # top left
29 cvb.Point2D(x+10, y-10), # top right
30 cvb.Point2D(x-10, y+10)) # bottom left
31 search_result = classifier.search(image.planes[0], cvb.minos.SearchMode.FindBestSubPixel, search_aoi, density=1000)
32 x = search_result.position.x
33 y = search_result.position.y
34 q = search_result.quality
35 print(x, y, q) # x=93.999, y=137.001, q=1.0
36
37 # Let's add some noise to the image
38 image = cvb.foundation.add_uniform_noise(image, -150, 150, seed=42)
39 search_result = classifier.search(image.planes[0], cvb.minos.SearchMode.FindBestSubPixel, search_aoi, density=1000)
40 x = search_result.position.x
41 y = search_result.position.y
42 q = search_result.quality
43 print(x, y, q) # x=94.964, y=137.121, q=0.802
cvb.Image load(str file_name)
cvb.Image add_uniform_noise(cvb.Image image, float lowest, float highest, int seed)
str install_path()