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 | |
| 7 | namespace aos { |
| 8 | namespace vision { |
| 9 | |
| 10 | // Countour nodes are slingly linked list chains of pixels that go around |
| 11 | // the boundary of a blob. |
| 12 | struct ContourNode { |
| 13 | ContourNode(int x, int y) : pt({x, y}) { next = this; } |
| 14 | ContourNode(int x, int y, ContourNode *next) : pt({x, y}), next(next) {} |
| 15 | ContourNode() {} |
| 16 | |
| 17 | // Construction routine to attach a node to the end. |
| 18 | // Prefer to manipulate contours using RangeImgToContour. |
| 19 | ContourNode *append(int x, int y, AnalysisAllocator *alloc) { |
| 20 | next = alloc->cons_obj<ContourNode>(x, y); |
| 21 | return next; |
| 22 | } |
| 23 | // Construction routine to attach a node to the beginning. |
| 24 | // Prefer to manipulate contours using RangeImgToContour. |
| 25 | ContourNode *pappend(int x, int y, AnalysisAllocator *alloc) { |
| 26 | return alloc->cons_obj<ContourNode>(x, y, this); |
| 27 | } |
| 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 | |
| 37 | } // namespace vision |
| 38 | } // namespace aos |
| 39 | |
| 40 | #endif // _AOS_VIISON_BLOB_CONTOUR_H_ |