Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SkeletonData.cc

Go to the documentation of this file.
00001 #include "Shared/Config.h"
00002 
00003 //#include "ShapeFuns.h"
00004 #include "SkeletonData.h"
00005 #include "ShapeSkeleton.h"
00006 #include "VRmixin.h"
00007 
00008 namespace DualCoding {
00009 
00010 SkeletonData:: SkeletonData(ShapeSpace& _space, const Skeleton& _skeleton)
00011   : BaseData(_space, getStaticType()), skeleton(_skeleton),
00012     center(Point()) {}
00013 
00014 SkeletonData::SkeletonData(ShapeSpace& _space, const Point &_center, const Skeleton& _skeleton)
00015   : BaseData(_space, getStaticType()), skeleton(_skeleton), center(_center) {}
00016 
00017 SkeletonData::SkeletonData(const SkeletonData &other)
00018   : BaseData(other), skeleton(other.skeleton), center(other.center) {}
00019   
00020 BoundingBox2D SkeletonData::getBoundingBox() const {
00021   return BoundingBox2D(center.coords); // *** incomplete ***
00022 }
00023 
00024 bool SkeletonData::isMatchFor(const ShapeRoot& other) const {
00025   if ( ! isSameTypeAs(other) ) return false;
00026   const Shape<SkeletonData>& other_Skeleton = ShapeRootTypeConst(other,SkeletonData);
00027   const float distance = getCentroid().distanceFrom(other_Skeleton->getCentroid());
00028   bool result = (distance < 200);
00029   return result;
00030 }
00031 
00032 bool SkeletonData::updateParams(const ShapeRoot& other, bool force) {
00033   // std::cout << "Merging Skeletons " << getId() << " and " << other->getId() << std::endl;
00034   center = (center + other->getCentroid()) / 2;
00035   return true;
00036 }
00037 
00038 void SkeletonData::printParams() const {
00039   std::cout << "Type = " << getTypeName() << "  ID=" << getId() << "  ParentID=" << getParentId() << std::endl;
00040 }
00041 
00042 void SkeletonData::applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref) {
00043   center.applyTransform(Tmat,newref);
00044 }
00045 
00046 void SkeletonData::projectToGround(const fmat::Transform& camToBase,
00047            const PlaneEquation& groundplane) {
00048   // Transform into local coordinates using known distance from the
00049   // camera, which was computed earlier based on known height of the
00050   // marker.
00051   const float xres = VRmixin::camSkS.getWidth();
00052   const float yres = VRmixin::camSkS.getHeight();
00053   const float maxres = std::max(xres,yres);
00054   const float normX = float(2*center.coordX() - xres) / maxres;
00055   const float normY = float(2*center.coordY() - yres) / maxres;
00056   fmat::Column<3> camera_vector;
00057   config->vision.computeRay(normX, normY,
00058           camera_vector[0],camera_vector[1],camera_vector[2]);
00059   //  cout << "center=" << center << "  camera_vector=" << camera_vector << "  norm=" << camera_vector.norm() << endl;
00060 
00061   // normalize and multiply by distance from camera to get actual point in space
00062   fmat::Column<3> camera_point = camera_vector * (center.coordZ() / camera_vector.norm());
00063 
00064   // transform to base (ground) frame
00065   center.coords = camera_point;
00066   center.applyTransform(camToBase, egocentric);
00067   // cout << " camera_point=" << camera_point << "   new center=" << center << "  camToBase=" << camToBase << endl;
00068 }
00069 
00070 Sketch<bool>* SkeletonData::render() const {
00071   SketchSpace &SkS = space->getDualSpace();
00072   Sketch<bool> result(SkS, "render("+getName()+")");
00073   result = 0;   // *** incomplete rendering ***
00074   return new Sketch<bool>(result);
00075 }
00076   
00077 DATASTUFF_CC(SkeletonData);
00078 
00079 } // namespace

DualCoding 5.1CVS
Generated Mon May 9 04:56:27 2016 by Doxygen 1.6.3