Loading...
Searching...
No Matches
tree.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: $
* @authors: Cedric Cagniart, Koen Buys
*/
#pragma once
#include "label_common.h"
#include <cstdint>
#include <iostream>
#include <vector>
namespace pcl
{
namespace gpu
{
namespace people
{
namespace trees
{
// this has nothing to do here...
constexpr double focal = 1000.;
// ###############################################
// compile type values
enum { NUM_ATTRIBS = 2000 };
enum { NUM_LABELS = 32 };
// ###############################################
// base data types used in the structures
using std::uint8_t;
using std::int16_t;
using std::uint16_t;
using std::int32_t;
using std::uint32_t;
using Attrib = std::int16_t;
using Label = std::uint8_t;
using Label32 = std::uint32_t;
using Depth = std::uint16_t;
struct AttribLocation
{
inline AttribLocation () {du1=dv1=du2=dv2=0;}
inline AttribLocation (int u1, int v1, int u2, int v2): du1 (static_cast<std::int16_t>(u1)),
dv1 (static_cast<std::int16_t>(v1)),
du2 (static_cast<std::int16_t>(u2)),
dv2 (static_cast<std::int16_t>(v2))
{}
std::int16_t du1,dv1,du2,dv2;
};
////////////////////////////////////////////////
// Tree basic Structure
struct Node
{
Node () {}
Node (const AttribLocation& l, const Attrib& t) : loc(l), thresh(t) {}
AttribLocation loc;
Attrib thresh;
};
struct Histogram
{
float label_prob[NUM_PARTS];
};
////////////////////////////////////////////////
// tree_io - Reading and writing AttributeLocations
inline std::ostream& operator << (std::ostream& os, const AttribLocation& aloc ) { return os<<aloc.du1<<" "<<aloc.dv1<<" "<<aloc.du2<<" "<<aloc.dv2<<"\n"; }
inline std::istream& operator >> (std::istream& is, AttribLocation& aloc ) { return is >> aloc.du1 >> aloc.dv1 >> aloc.du2 >> aloc.dv2; }
inline std::istream& operator >> (std::istream& is, Node& n) { return is >> n.loc >> n.thresh; }
void writeAttribLocs( const std::string& filename, const std::vector<AttribLocation>& alocs );
void readAttribLocs( const std::string& filename, std::vector<AttribLocation>& alocs );
void readThreshs( const std::string& filename, std::vector<Attrib>& threshs );
void writeThreshs( const std::string& filename, const std::vector<Attrib>& threshs );
////////////////////////////////////////////////
// tree_run
/** The stream points to ascii data that goes:
* ##################
* TreeHeight
* du1 dv1 du2 dv2 thresh
* du1 dv1 du2 dv2 thresh
* ............
* label
* label
* ##################
*
* there are 2^threeheight -1 nodes ( [du1 dv1 du2 dv2 thresh] lines )
* there are 2^threeheight leaves ( [label] lines )
*/
int loadTree( std::istream& is, std::vector<Node>& tree, std::vector<Label>& leaves );
int loadTree( const std::string& filename, std::vector<Node>& tree, std::vector<Label>& leaves );
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 );
} // end namespace Trees
} // end namespace people
} // end namespace gpu
} // end namespace pcl
pcl::gpu::people::trees
Definition tree.h:54
pcl::gpu::people::trees::NUM_ATTRIBS
@ NUM_ATTRIBS
Definition tree.h:60
pcl::gpu::people::trees::readAttribLocs
void readAttribLocs(const std::string &filename, std::vector< AttribLocation > &alocs)
pcl::gpu::people::trees::writeThreshs
void writeThreshs(const std::string &filename, const std::vector< Attrib > &threshs)
pcl::gpu::people::trees::readThreshs
void readThreshs(const std::string &filename, std::vector< Attrib > &threshs)
pcl::gpu::people::trees::runThroughTree
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)
pcl::gpu::people::trees::writeAttribLocs
void writeAttribLocs(const std::string &filename, const std::vector< AttribLocation > &alocs)
pcl::gpu::people::trees::Depth
std::uint16_t Depth
Definition tree.h:75
pcl::gpu::people::trees::focal
constexpr double focal
Definition tree.h:56
pcl::gpu::people::trees::operator>>
std::istream & operator>>(std::istream &is, AttribLocation &aloc)
Definition tree.h:107
pcl::gpu::people::trees::NUM_LABELS
@ NUM_LABELS
Definition tree.h:61
pcl::gpu::people::trees::Label32
std::uint32_t Label32
Definition tree.h:74
pcl::gpu::people::trees::operator<<
std::ostream & operator<<(std::ostream &os, const AttribLocation &aloc)
Definition tree.h:106
pcl::gpu::people::trees::loadTree
int loadTree(std::istream &is, std::vector< Node > &tree, std::vector< Label > &leaves)
The stream points to ascii data that goes: ################## TreeHeight du1 dv1 du2 dv2 thresh du1 d...
pcl::gpu::people::trees::Attrib
std::int16_t Attrib
Definition tree.h:72
pcl::gpu::people::trees::Label
std::uint8_t Label
Definition tree.h:73
pcl::gpu::people
Definition bodyparts_detector.h:63
pcl::gpu::people::NUM_PARTS
@ NUM_PARTS
Definition label_common.h:60
pcl::gpu
Definition device_array.h:45
pcl
Definition convolution.h:46
pcl::gpu::people::trees::AttribLocation
Definition tree.h:78
pcl::gpu::people::trees::AttribLocation::dv2
std::int16_t dv2
Definition tree.h:86
pcl::gpu::people::trees::AttribLocation::AttribLocation
AttribLocation()
Definition tree.h:79
pcl::gpu::people::trees::AttribLocation::du1
std::int16_t du1
Definition tree.h:86
pcl::gpu::people::trees::AttribLocation::dv1
std::int16_t dv1
Definition tree.h:86
pcl::gpu::people::trees::AttribLocation::du2
std::int16_t du2
Definition tree.h:86
pcl::gpu::people::trees::AttribLocation::AttribLocation
AttribLocation(int u1, int v1, int u2, int v2)
Definition tree.h:80
pcl::gpu::people::trees::Histogram::Histogram
Histogram()
Definition tree_train.h:26
pcl::gpu::people::trees::Histogram::label_prob
float label_prob[NUM_PARTS]
Definition tree.h:101
pcl::gpu::people::trees::Node
Definition tree.h:92
pcl::gpu::people::trees::Node::loc
AttribLocation loc
Definition tree.h:95
pcl::gpu::people::trees::Node::thresh
Attrib thresh
Definition tree.h:96
pcl::gpu::people::trees::Node::Node
Node(const AttribLocation &l, const Attrib &t)
Definition tree.h:94
pcl::gpu::people::trees::Node::Node
Node()
Definition tree.h:93