00001 /*!@file RCBot/FindLandmark.C find the landmark position from SceneRec */ 00002 // //////////////////////////////////////////////////////////////////// // 00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00004 // University of Southern California (USC) and the iLab at USC. // 00005 // See http://iLab.usc.edu for information about this project. // 00006 // //////////////////////////////////////////////////////////////////// // 00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00009 // in Visual Environments, and Applications'' by Christof Koch and // 00010 // Laurent Itti, California Institute of Technology, 2001 (patent // 00011 // pending; application number 09/912,225 filed July 23, 2001; see // 00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00013 // //////////////////////////////////////////////////////////////////// // 00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00015 // // 00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00017 // redistribute it and/or modify it under the terms of the GNU General // 00018 // Public License as published by the Free Software Foundation; either // 00019 // version 2 of the License, or (at your option) any later version. // 00020 // // 00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00024 // PURPOSE. See the GNU General Public License for more details. // 00025 // // 00026 // You should have received a copy of the GNU General Public License // 00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00029 // Boston, MA 02111-1307 USA. // 00030 // //////////////////////////////////////////////////////////////////// // 00031 // 00032 // Primary maintainer for this file: Lior Elazary <lelazary@yahoo.com> 00033 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/RCBot/FindLandmark.C $ 00034 // $Id: FindLandmark.C 9412 2008-03-10 23:10:15Z farhan $ 00035 // 00036 00037 #include "RCBot/FindLandmark.H" 00038 00039 // ###################################################################### 00040 FindLandmark::FindLandmark(SceneRecServer_var inSceneRec): 00041 sceneRec(inSceneRec), thLandmarkLoc(-1,-1), currentLeg(0) 00042 { 00043 // start the thread 00044 start(); 00045 } 00046 00047 // ###################################################################### 00048 FindLandmark::~FindLandmark(){ } 00049 00050 // ###################################################################### 00051 void FindLandmark::run(void *ptr) 00052 { 00053 while(1) 00054 { 00055 findLandmarkMutex.lock(); 00056 00057 LINFO("Waiting for image"); 00058 findLandmarkCond.wait(); 00059 findLandmarkMutex.unlock(); 00060 LINFO("Got image"); 00061 00062 if (sceneRec->outputReady()) 00063 { 00064 landmarkImgMutex.lock(); 00065 Image<PixRGB<byte> > ima = img; 00066 landmarkImgMutex.unlock(); 00067 00068 Point2DOrb landLocOrb; 00069 int retLeg = sceneRec->getLandmarkLoc(landLocOrb); 00070 00071 sceneRec->newInput(*image2Orb(ima)); //TODO: could use imgOrb 00072 00073 thLandmarkInfoMutex.lock(); 00074 currentLeg = retLeg; 00075 thLandmarkLoc.i = landLocOrb.i; 00076 thLandmarkLoc.j = landLocOrb.j; 00077 thLandmarkInfoMutex.unlock(); 00078 } 00079 } 00080 } 00081 00082 // ###################################################################### 00083 int FindLandmark::getLandmark(Point2D<int> &landmarkLoc) 00084 { 00085 int retLeg; 00086 00087 LINFO("Getting lock"); 00088 thLandmarkInfoMutex.lock(); 00089 retLeg = currentLeg; 00090 landmarkLoc = thLandmarkLoc; 00091 thLandmarkInfoMutex.unlock(); 00092 LINFO("Releasing lock"); 00093 00094 return retLeg; 00095 } 00096 00097 // ###################################################################### 00098 void FindLandmark::setImg(Image<PixRGB<byte> > &inImg) 00099 { 00100 landmarkImgMutex.lock(); 00101 img = inImg; 00102 landmarkImgMutex.unlock(); 00103 00104 findLandmarkCond.signal(); 00105 } 00106 00107 // ###################################################################### 00108 /* So things look consistent in everyone's emacs... */ 00109 /* Local Variables: */ 00110 /* indent-tabs-mode: nil */ 00111 /* End: */