-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTImageSegmentation.lf
39 lines (37 loc) · 1.49 KB
/
RTImageSegmentation.lf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @file RTImageSegmentation.lf
* @author Vincenzo Barbuto
* @brief Examples of how to perform real-time image segmentation using a TensorFlow Lite model.
*/
target Python {
keepalive: true,
single-threaded: true # OpenCV crashes if we use the multithreaded version.
}
import Camera from "lib/Input.lf"
import SegmentationVisualizer from "lib/Display.lf"
import ImageSegmenter from "lib/ComputerVision.lf"
/**
* @brief This reactor tests the real-time image segmentation functionality by connecting a Camera,
* an ImageSegmenter, and a SegmentationVisualizer reactor.
*
* The `SegmentationVisualizer` reactor receives the segmentations results and inference time from
* the `ImageSegmenter`, shows results in a video window and prints the inference time to the
* console.
*
* The `main` reactor creates instances of the `Camera`, `ImageSegmenter`, and
* `SegmentationVisualizer` reactors, and connects them together to form the test pipeline.
*
* @note Remember to set the `model` parameter to the absolute path of the image segmentation model
* you want to use.
*/
main reactor {
camera = new Camera()
display = new SegmentationVisualizer()
segmenter = new ImageSegmenter(
model = {= os.path.join(os.getcwd(),"models/vision/segmentation/deeplab.tflite") =})
camera.camera_frame -> segmenter.input_data
camera.camera_frame -> display.original_frame
camera.camera_frame ~> camera.trigger
segmenter.inference_time -> display.inference_time
segmenter.results -> display.results
}