Parker Schuh | 6691f19 | 2017-01-14 17:01:02 -0800 | [diff] [blame] | 1 | #ifndef _AOS_VIISON_BLOB_CONTOUR_H_ |
| 2 | #define _AOS_VIISON_BLOB_CONTOUR_H_ |
| 3 | |
| 4 | #include "aos/vision/blob/range_image.h" |
| 5 | #include "aos/vision/blob/region_alloc.h" |
| 6 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 7 | namespace aos::vision { |
Parker Schuh | 6691f19 | 2017-01-14 17:01:02 -0800 | [diff] [blame] | 8 | |
| 9 | // Countour nodes are slingly linked list chains of pixels that go around |
| 10 | // the boundary of a blob. |
| 11 | struct ContourNode { |
| 12 | ContourNode(int x, int y) : pt({x, y}) { next = this; } |
| 13 | ContourNode(int x, int y, ContourNode *next) : pt({x, y}), next(next) {} |
| 14 | ContourNode() {} |
| 15 | |
| 16 | // Construction routine to attach a node to the end. |
| 17 | // Prefer to manipulate contours using RangeImgToContour. |
| 18 | ContourNode *append(int x, int y, AnalysisAllocator *alloc) { |
| 19 | next = alloc->cons_obj<ContourNode>(x, y); |
| 20 | return next; |
| 21 | } |
| 22 | // Construction routine to attach a node to the beginning. |
| 23 | // Prefer to manipulate contours using RangeImgToContour. |
| 24 | ContourNode *pappend(int x, int y, AnalysisAllocator *alloc) { |
| 25 | return alloc->cons_obj<ContourNode>(x, y, this); |
| 26 | } |
Ben Fredrickson | f7b6852 | 2019-03-02 21:19:42 -0800 | [diff] [blame] | 27 | void set_point(Point new_pt) { pt = new_pt; } |
Parker Schuh | 6691f19 | 2017-01-14 17:01:02 -0800 | [diff] [blame] | 28 | |
| 29 | Point pt; |
| 30 | ContourNode *next; |
| 31 | }; |
| 32 | |
| 33 | // Converts range image to contour using sweepline analysis. |
| 34 | ContourNode *RangeImgToContour(const RangeImage &rimg, |
| 35 | AnalysisAllocator *alloc); |
| 36 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 37 | } // namespace aos::vision |
Parker Schuh | 6691f19 | 2017-01-14 17:01:02 -0800 | [diff] [blame] | 38 | |
| 39 | #endif // _AOS_VIISON_BLOB_CONTOUR_H_ |