MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / LaneDetectorGNode

Class LaneDetectorGNode

example/E01-AutoPilot.cpp:72–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71
72class LaneDetectorGNode : public GNode {
73public:
74 CStatus init() override {
75 // 订阅 EXAMPLE_IMAGE_TOPIC 消息。每次 bind的返回值,是不一样的,用于区分
76 conn_id_ = CGRAPH_BIND_MESSAGE_TOPIC(ImageMParam, EXAMPLE_IMAGE_TOPIC, DEFAULT_MESSAGE_BUF_SIZE)
77 return CStatus();
78 }
79
80 CStatus run() override {
81 std::shared_ptr<ImageMParam> image = nullptr;
82 auto status = CGRAPH_SUB_MPARAM(ImageMParam, conn_id_, image);
83 if (status.isErr()) {
84 return status;
85 }
86
87 auto param = CGRAPH_GET_GPARAM_WITH_NO_EMPTY(DetectResultGParam, EXAMPLE_PARAM_KEY)
88 // detector lane in image.image_buf_ ...
89 CGRAPH_ECHO("detecting lane in frame [%d], info is [%s]", image->frame_id_, image->image_buf_);
90 param->frame_id_ = image->frame_id_;
91 param->lane_num_ = std::abs((int)std::random_device{}()) % 10;
92 return CStatus();
93 }
94
95private:
96 int conn_id_ = 0;
97};
98
99
100class CarDetectorGNode : public GNode {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected