|
14 | 14 | class DisplayEngine(cognitive_engine.Engine): |
15 | 15 | """A simple cognitive engine that displays the input frame.""" |
16 | 16 |
|
17 | | - def __init__(self, engine_name): |
| 17 | + def __init__(self, engine_id): |
18 | 18 | """Initializes the display engine.""" |
19 | | - self._engine_name = engine_name |
| 19 | + self._engine_id = engine_id |
20 | 20 |
|
21 | 21 | def handle(self, input_frame): |
22 | 22 | """Handles an input frame.""" |
23 | 23 | status = gabriel_pb2.Status() |
24 | 24 | status.code = gabriel_pb2.StatusCode.SUCCESS |
25 | 25 |
|
26 | | - return Result(status, "Hello from engine") |
27 | | - np_data = np.frombuffer(input_frame.payloads[0], dtype=np.uint8) |
| 26 | + np_data = np.frombuffer(input_frame.byte_payload, dtype=np.uint8) |
28 | 27 | frame = cv2.imdecode(np_data, cv2.IMREAD_COLOR) |
29 | | - cv2.imshow(f"Image from engine: {self._engine_name}", frame) |
| 28 | + cv2.imshow(f"Image from engine: {self._engine_id}", frame) |
30 | 29 | cv2.waitKey(1) |
31 | 30 |
|
32 | | - status = gabriel_pb2.ResultWrapper.Status.SUCCESS |
33 | | - result_wrapper = cognitive_engine.create_result_wrapper(status) |
34 | | - return result_wrapper |
| 31 | + return Result(status, "Hello from engine") |
35 | 32 |
|
36 | 33 |
|
37 | 34 | def main(): |
38 | 35 | """Starts the Gabriel engine.""" |
39 | 36 | common.configure_logging() |
40 | | - args = common.parse_engine_name_server_host() |
41 | | - engine = DisplayEngine(args.engine_name) |
| 37 | + args = common.parse_engine_id_server_host() |
| 38 | + engine = DisplayEngine(args.engine_id) |
42 | 39 |
|
43 | 40 | server_address = SERVER_ADDRESS_FORMAT.format( |
44 | 41 | args.server_host, common.SERVER_BACKEND_PORT |
45 | 42 | ) |
46 | | - runner = engine_runner.EngineRunner( |
47 | | - engine, args.engine_name, server_address |
48 | | - ) |
| 43 | + runner = engine_runner.EngineRunner(engine, args.engine_id, server_address) |
49 | 44 | runner.run() |
50 | 45 |
|
51 | 46 |
|
|
0 commit comments