$search
00001 /* 00002 * Software License Agreement (Modified BSD License) 00003 * 00004 * Copyright (c) 2012, PAL Robotics, S.L. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of PAL Robotics, S.L. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * @file gpugltracker.h 00035 * @author Bence Magyar 00036 * @date April 2012 00037 * @version 0.1 00038 * @brief The GpuGLTracker class encapsulates the Tracker module of BLORT. 00039 * It provides a C++ interface but uses ROS classes for data transfer at some places. 00040 * This class is a more civilized version of the mechanism that is in Projects/Learnsifts/main.cpp. 00041 */ 00042 00043 #ifndef GPUGLTRACKER_H 00044 #define GPUGLTRACKER_H 00045 00046 #include "trackerinterface.hpp" 00047 #include <blort_ros/TrackerConfidences.h> 00048 #include <blort_ros/TrackerCommand.h> 00049 #include <blort_ros/TrackerConfig.h> 00050 #include <geometry_msgs/Pose.h> 00051 #include <string> 00052 00053 #include <blort/Tracker/TextureTracker.h> 00054 #include <blort/TomGine/tgModel.h> 00055 #include <blort/TomGine/tgTimer.h> 00056 00057 namespace blort_ros 00058 { 00059 enum TrackerPublishMode 00060 { 00061 TRACKER_PUBLISH_GOOD = 0, 00062 TRACKER_PUBLISH_GOOD_AND_FAIR = 1, 00063 TRACKER_PUBLISH_ALL = 2 00064 }; 00065 00066 class GLTracker : public TrackerInterface 00067 { 00068 private: 00069 //config 00070 double conf_threshold; 00071 bool visualize_obj_pose; 00072 int publish_mode; 00073 00074 float recovery_conf_threshold; // threshold used in recovery mode to say OK to a pose proposal 00075 00076 // functionality 00077 TomGine::tgCamera::Parameter tgcam_params; 00078 TomGine::tgTimer timer; 00079 TomGine::tgPose cam_pose; 00080 Tracking::Tracker::Parameter track_params; 00081 00082 Tracking::TextureTracker tracker; // tracking module 00083 00084 //config files //FIXME 00085 std::string model_name, sift_file; // name of the current model 00086 std::string pose_cal; // filename with the pose calibration values 00087 00088 // Model for Tracker 00089 TomGine::tgPose trPose; // current pose of the object used by the tracker module 00090 int model_id; 00091 Tracking::movement_state movement; 00092 Tracking::quality_state quality; 00093 Tracking::confidence_state tracker_confidence; 00094 00095 // Initialise image 00096 IplImage *image; // iplimage object used be the former blort tracker module 00097 00098 // result variables 00099 TrackerConfidences tracker_confidences; 00100 geometry_msgs::Pose fixed_cam_pose; 00101 std::vector<geometry_msgs::Pose> result; 00102 00103 //reconf GUI hack 00104 bool last_reset; 00105 00106 public: 00107 GLTracker(const sensor_msgs::CameraInfo camera_info, 00108 const std::string& config_root, 00109 bool visualize_obj_pose = false); 00110 00112 virtual void recovery() {} 00113 00115 virtual void track(); 00116 00117 void reset(); 00118 00121 void reconfigure(blort_ros::TrackerConfig config); 00122 00127 void trackerControl(int code, int param = -1); 00128 00129 void resetWithPose(const geometry_msgs::Pose& new_pose); 00130 00132 TrackerConfidences getConfidences(){ return tracker_confidences; } 00133 00135 const std::vector<geometry_msgs::Pose>& getDetections(){ return result; } 00136 00138 const geometry_msgs::Pose getCameraReferencePose(){ return fixed_cam_pose; } 00139 00141 cv::Mat getImage(); 00142 00144 std::string getStatusString(); 00145 00146 void setVisualizeObjPose(bool enable){ visualize_obj_pose = enable; } 00147 00148 void setPublisMode(TrackerPublishMode mode){ publish_mode = mode; } 00149 00150 ~GLTracker(); 00151 00152 private: 00155 void update(); 00156 00159 void updatePoseResult(); 00160 }; 00161 } 00162 00163 #endif // GPUGLTRACKER_H