blob: c192a755a2cfbdf2a4dc29cf1e5cf621730e200e [file] [log] [blame]
Parker Schuh6691f192017-01-14 17:01:02 -08001#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 Pleinesd99b1ee2024-02-02 20:56:44 -08007namespace aos::vision {
Parker Schuh6691f192017-01-14 17:01:02 -08008
9// Countour nodes are slingly linked list chains of pixels that go around
10// the boundary of a blob.
11struct 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 Fredricksonf7b68522019-03-02 21:19:42 -080027 void set_point(Point new_pt) { pt = new_pt; }
Parker Schuh6691f192017-01-14 17:01:02 -080028
29 Point pt;
30 ContourNode *next;
31};
32
33// Converts range image to contour using sweepline analysis.
34ContourNode *RangeImgToContour(const RangeImage &rimg,
35 AnalysisAllocator *alloc);
36
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080037} // namespace aos::vision
Parker Schuh6691f192017-01-14 17:01:02 -080038
39#endif // _AOS_VIISON_BLOB_CONTOUR_H_