| 98 | |
| 99 | |
| 100 | class CarDetectorGNode : public GNode { |
| 101 | public: |
| 102 | CStatus init() override { |
| 103 | conn_id_ = CGRAPH_BIND_MESSAGE_TOPIC(ImageMParam, EXAMPLE_IMAGE_TOPIC, DEFAULT_MESSAGE_BUF_SIZE) |
| 104 | return CStatus(); |
| 105 | } |
| 106 | |
| 107 | CStatus run() override { |
| 108 | std::shared_ptr<ImageMParam> image = nullptr; |
| 109 | auto status = CGRAPH_SUB_MPARAM(ImageMParam, conn_id_, image); |
| 110 | if (status.isErr()) { |
| 111 | return status; |
| 112 | } |
| 113 | |
| 114 | auto param = CGRAPH_GET_GPARAM_WITH_NO_EMPTY(DetectResultGParam, EXAMPLE_PARAM_KEY); |
| 115 | CGRAPH_ECHO("finding car in frame [%d], info is [%s]", image->frame_id_, image->image_buf_); |
| 116 | // find car in image.image_buf_ ... |
| 117 | param->car_num_ = std::abs((int)std::random_device{}()) % 5; |
| 118 | return CStatus(); |
| 119 | } |
| 120 | |
| 121 | private: |
| 122 | int conn_id_ = 0; |
| 123 | }; |
| 124 | |
| 125 | |
| 126 | class ShowGNode : public GNode { |
nothing calls this directly
no outgoing calls
no test coverage detected