blob: bbd59a9631208d49a85761cf9b37de27bf9c08e0 [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
7namespace aos {
8namespace vision {
9
10// Countour nodes are slingly linked list chains of pixels that go around
11// the boundary of a blob.
12struct 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 }
Ben Fredricksonf7b68522019-03-02 21:19:42 -080028 void set_point(Point new_pt) { pt = new_pt; }
Parker Schuh6691f192017-01-14 17:01:02 -080029
30 Point pt;
31 ContourNode *next;
32};
33
34// Converts range image to contour using sweepline analysis.
35ContourNode *RangeImgToContour(const RangeImage &rimg,
36 AnalysisAllocator *alloc);
37
38} // namespace vision
39} // namespace aos
40
41#endif // _AOS_VIISON_BLOB_CONTOUR_H_