-
Notifications
You must be signed in to change notification settings - Fork 0
/
yolov8.gen
119 lines (97 loc) · 4.23 KB
/
yolov8.gen
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright (c) 2023-2023 LAAS/CNRS
*
* Author: Selvakumar H S - LAAS/CNRS
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma require "openrobots2-idl >= 2.1"
#pragma require "felix-idl"
#pragma require "vision-idl"
#include "or/sensor/camera.gen"
#include "Yolo.idl"
/* -------------------------- MODULE DECLARATION --------------------------- */
component Yolov8 {
version "1.0";
email "[email protected]";
lang "c";
doc "A GenoM module for Yolov8 integration using a monocular camera.";
codels-require "opencv4 >= 4.7, felix-g3utils, eigen3, vision-idl";
exception e_BAD_IMAGE_PORT { short code; string<128> message; };
exception e_OPENCV_ERROR { short code; string<128> message; };
exception e_OUT_OF_MEM { short code; string<128> message; };
exception e_BAD_CONFIG { short code; string<128> message; };
/* -------------------------- IDS --------------------------- */
ids {
or::sensor::frame image_frame; // Image frame
sequence<string> classes; // Class names
string resource_path; // Resource path
boolean debug, show_frames, start_detection, pause_object_detection;
octet verbose_level;
};
/* ------------- DEFINITION OF PORTS -------------- */
port in or::sensor::frame ImageFrame {
doc "The image frame to process.";
};
port out or::Yolo::Detections Detections {
doc "The detected classes from the image frame.";
};
/* ------------------ TASK DEFINITION -------------------- */
task detect_objects {
period 100 ms;
doc "Detect the objects in the image.";
codel <start> FetchPorts(ids in start_detection, port in ImageFrame, port out Detections, ids in resource_path, ids in debug)
yield pause::start, main;
codel <main> DetectObjects(ids in classes, ids in start_detection, ids in pause_object_detection, port in ImageFrame, port out Detections,
ids in debug, ids in show_frames)
yield main, pause::main, ether;
throw e_BAD_IMAGE_PORT, e_OPENCV_ERROR, e_BAD_CONFIG, e_OUT_OF_MEM;
};
/* ------------------ ACTIVITY DEFINITION --------------------- */
activity start_object_detection() {
doc "Start detecting the object.";
before stop_object_detection;
validate check_resource_path(ids out resource_path);
task detect_objects;
codel <start> SetupClasses(ids out resource_path, ids inout classes, ids in debug)
yield setup, pause::start, ether;
codel<setup> SetStartDetection(ids out start_detection)
yield pause::setup, ether;
};
/* ------------------ SERVICE DEFINITION: Attributes -------------------- */
attribute set_classes(in classes =: "Set the class names to be detected." ) {
doc "Set the class names to be detected.";
};
attribute set_debug(in debug = FALSE : "Set debug mode (default: false)" ) {
doc "Set the debug mode.";
};
attribute show_image_frames(in show_frames = FALSE : "Show image frames (default: false)" ) {
doc "Show image frames.";
};
attribute set_verbose_level(in verbose_level = 0 : "Verbose level") {
doc "Set the verbose level.";
};
/* ------------------ SERVICE DEFINITION: Functions -------------------- */
function stop_object_detection() {
doc "Stop detecting the object.";
codel StopDetection(ids out start_detection);
};
function pause_object_detection() {
doc "Pause detecting the object.";
codel PauseDetection(ids out pause_object_detection);
};
function resume_object_detection() {
doc "Resume detecting the object.";
codel ResumeDetection(ids out pause_object_detection);
};
};