DetectedFace.cpp
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2010, Ulrich Klank, Dejan Pangercic
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 /*
00031  * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de>
00032  *
00033  * This program is free software; you can redistribute it and/or modify
00034  * it under the terms of the GNU General Public License as published by
00035  * the Free Software Foundation; either version 3 of the License, or
00036  * (at your option) any later version.
00037  *
00038  * This program is distributed in the hope that it will be useful,
00039  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00040  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00041  * GNU General Public License for more details.
00042  *
00043  * You should have received a copy of the GNU General Public License
00044  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00045  */
00046 
00047 
00048 /************************************************************************
00049 DetectedFaces.cpp
00050 **************************************************************************/
00051 
00052 
00053 #include "DetectedFace.h"
00054 #include "IplImageReading.h"
00055 #include "ImageSubscription.h"
00056 
00057 
00058 #include "cv.h"
00059 #include "highgui.h"
00060 
00061 using namespace cop;
00062 
00063 #define XML_NODE_LASTMATCHEDFACES "LastMatchedFaces"
00064 
00065 void DetectedFace::Show(RelPose* pose, Sensor* camin)
00066 {
00067   const static cv::Scalar colors[] =  { CV_RGB(0,0,255),
00068                                   CV_RGB(0,128,255),
00069                                   CV_RGB(0,255,255),
00070                                   CV_RGB(0,255,0),
00071                                   CV_RGB(255,128,0),
00072                                   CV_RGB(255,255,0),
00073                                   CV_RGB(255,0,0),
00074                                   CV_RGB(255,0,255)} ;
00075   if(camin != NULL && camin->GetName().compare("ImageSubscription") == 0)
00076   {
00077     IplImageReading *reading = (IplImageReading*)(camin->GetReading(-1));
00078     cv::Mat &img = reading->m_image;
00079     RelPose* pose = GetLastMatchedPose();
00080     if(m_lastlyDetectedFaces.find(pose->m_uniqueID) != m_lastlyDetectedFaces.end())
00081     {
00082       std::vector<double> &vec = m_lastlyDetectedFaces[pose->m_uniqueID];
00083       if(vec.size() > 3)
00084       {
00085         circle( img, cv::Point2f(vec[0], vec[1]), vec[2], colors[pose->m_uniqueID % 8], 3, 8, 0 );
00086       }
00087     }
00088     //cv::imshow(((ImageSubscription*)camin)->GetWindowName().c_str() , img);
00089   }
00090   else
00091   {
00092     printf("No camera available\n");
00093   }
00094 }
00095 
00096 void DetectedFace::SaveTo(XMLTag* tag)
00097 {
00098 
00099   Descriptor::SaveTo(tag);
00100 
00101   tag->AddChild(XMLTag::Tag(m_lastlyDetectedFaces, XML_NODE_LASTMATCHEDFACES));
00102 
00103 }
00104 
00105 void DetectedFace::SetData(XMLTag* tag)
00106 {
00107   Descriptor::SetData(tag);
00108   XMLTag* lastly_faces_node = tag->GetChild(XML_NODE_LASTMATCHEDFACES);
00109   m_lastlyDetectedFaces = XMLTag::Load(lastly_faces_node, &m_lastlyDetectedFaces);
00110 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


cop_ros_plugins
Author(s): U. Klank, Dejan Pangercic
autogenerated on Thu May 23 2013 12:29:47