CVBpy 14.0
shapefinder2/ShapeFinder
1# CVBpy Example Script
2#
3
4
5import os
6import cvb
8
9def print_search_result(search_result):
10 i = 0
11 for result in search_result:
12 i += 1
13 x = result.x
14 y = result.y
15 quality = result.quality
16 rot = result.rotation
17 angle = result.rotation.deg
18 print(' {0:2d} Position=[{1:.2f},{2:.2f}], Quality={3:.2f}, Angle={4:.2f}'.format(i, x, y, quality, angle))
19
20sf_example_path = "tutorial/ShapeFinder/Images/SF2/Lusterterminal"
21
22# open device
24 os.path.join(cvb.install_path(), "drivers", "CVMock.vin"),
25 cvb.AcquisitionStack.Vin) as device:
26
27 stream = device.stream()
28 stream.start()
29
30 classifier = cvb.shapefinder2.Classifier(os.path.join(cvb.install_path(), sf_example_path, "Screw.sf2"))
31
32 for i in range(2):
33 image, status = stream.wait()
34 if status == cvb.WaitStatus.Ok:
35 res = classifier.search_all(device.device_image.planes[0], device.device_image.bounds, cvb.shapefinder2.PrecisionMode.CorrelationFine, 0.55, 20, 10)
36 print('Result for image {0:2d}:'.format(i+1))
37 print(' Number of search results: {0:2d}'.format(len(res)))
38 print_search_result(res)
39
40 stream.abort()
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
Opens a device with the given provider and acquisition stack.
Definition: __init__.py:1327
ShapeFinder2 classifier object.
Definition: __init__.py:20
Common Vision Blox ShapeFinder module for Python.
Definition: __init__.py:1
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:7146