Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
tree.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2012, Willow Garage, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of Willow Garage, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 * $Id: $
37 * @authors: Cedric Cagniart, Koen Buys
38 */
39
40#pragma once
41
42#include "label_common.h"
43#include <cstdint>
44#include <iostream>
45#include <vector>
46
47namespace pcl
48{
49 namespace gpu
50 {
51 namespace people
52 {
53 namespace trees
54 {
55 // this has nothing to do here...
56 constexpr double focal = 1000.;
57
58 // ###############################################
59 // compile type values
60 enum { NUM_ATTRIBS = 2000 };
61 enum { NUM_LABELS = 32 };
62
63 // ###############################################
64 // base data types used in the structures
65
66 using std::uint8_t;
67 using std::int16_t;
68 using std::uint16_t;
69 using std::int32_t;
70 using std::uint32_t;
71
72 using Attrib = std::int16_t;
73 using Label = std::uint8_t;
74 using Label32 = std::uint32_t;
75 using Depth = std::uint16_t;
76
78 {
79 inline AttribLocation () {du1=dv1=du2=dv2=0;}
80 inline AttribLocation (int u1, int v1, int u2, int v2): du1 (static_cast<std::int16_t>(u1)),
81 dv1 (static_cast<std::int16_t>(v1)),
82 du2 (static_cast<std::int16_t>(u2)),
83 dv2 (static_cast<std::int16_t>(v2))
84 {}
85
86 std::int16_t du1,dv1,du2,dv2;
87 };
88
89 ////////////////////////////////////////////////
90 // Tree basic Structure
91 struct Node
92 {
93 Node () {}
94 Node (const AttribLocation& l, const Attrib& t) : loc(l), thresh(t) {}
97 };
98
99 struct Histogram
100 {
102 };
103
104 ////////////////////////////////////////////////
105 // tree_io - Reading and writing AttributeLocations
106 inline std::ostream& operator << (std::ostream& os, const AttribLocation& aloc ) { return os<<aloc.du1<<" "<<aloc.dv1<<" "<<aloc.du2<<" "<<aloc.dv2<<"\n"; }
107 inline std::istream& operator >> (std::istream& is, AttribLocation& aloc ) { return is >> aloc.du1 >> aloc.dv1 >> aloc.du2 >> aloc.dv2; }
108 inline std::istream& operator >> (std::istream& is, Node& n) { return is >> n.loc >> n.thresh; }
109
110 void writeAttribLocs( const std::string& filename, const std::vector<AttribLocation>& alocs );
111 void readAttribLocs( const std::string& filename, std::vector<AttribLocation>& alocs );
112 void readThreshs( const std::string& filename, std::vector<Attrib>& threshs );
113 void writeThreshs( const std::string& filename, const std::vector<Attrib>& threshs );
114
115 ////////////////////////////////////////////////
116 // tree_run
117
118 /** The stream points to ascii data that goes:
119 * ##################
120 * TreeHeight
121 * du1 dv1 du2 dv2 thresh
122 * du1 dv1 du2 dv2 thresh
123 * ............
124 * label
125 * label
126 * ##################
127 *
128 * there are 2^threeheight -1 nodes ( [du1 dv1 du2 dv2 thresh] lines )
129 * there are 2^threeheight leaves ( [label] lines )
130 */
131 int loadTree( std::istream& is, std::vector<Node>& tree, std::vector<Label>& leaves );
132 int loadTree( const std::string& filename, std::vector<Node>& tree, std::vector<Label>& leaves );
133 void runThroughTree( int maxDepth, const std::vector<Node>& tree, const std::vector<Label>& leaves, int W, int H, const std::uint16_t* dmap, Label* lmap );
134
135 } // end namespace Trees
136 } // end namespace people
137 } // end namespace gpu
138} // end namespace pcl
std::uint32_t Label32
Definition tree.h:74
void readAttribLocs(const std::string &filename, std::vector< AttribLocation > &alocs)
void writeThreshs(const std::string &filename, const std::vector< Attrib > &threshs)
void readThreshs(const std::string &filename, std::vector< Attrib > &threshs)
void runThroughTree(int maxDepth, const std::vector< Node > &tree, const std::vector< Label > &leaves, int W, int H, const std::uint16_t *dmap, Label *lmap)
void writeAttribLocs(const std::string &filename, const std::vector< AttribLocation > &alocs)
constexpr double focal
Definition tree.h:56
std::uint16_t Depth
Definition tree.h:75
std::istream & operator>>(std::istream &is, AttribLocation &aloc)
Definition tree.h:107
std::uint8_t Label
Definition tree.h:73
std::ostream & operator<<(std::ostream &os, const AttribLocation &aloc)
Definition tree.h:106
int loadTree(std::istream &is, std::vector< Node > &tree, std::vector< Label > &leaves)
The stream points to ascii data that goes:
std::int16_t Attrib
Definition tree.h:72
AttribLocation(int u1, int v1, int u2, int v2)
Definition tree.h:80
float label_prob[NUM_PARTS]
Definition tree.h:101
AttribLocation loc
Definition tree.h:95
Node(const AttribLocation &l, const Attrib &t)
Definition tree.h:94