32 throw std::runtime_error(
"Please specify parameter inference_algorithm when starting this node.");
36 throw std::runtime_error(
"Please specify parameter xml_output when starting this node.");
42 throw std::runtime_error(
"Please specify parameter xml_file_path when starting this node.");
46 throw std::runtime_error(
"Please specify parameter create_runtime_log when starting this node.");
48 std::string runtimeLogFileName =
"";
52 if(!nodeHandle.
getParam(
"log_file_name", runtimeLogFileName))
53 throw std::runtime_error(
"Please specify parameter log_file_name when starting this node.");
61 throw std::runtime_error(
"Please specify parameter visualize_inference when starting this node.");
65 throw std::runtime_error(
"Please specify parameter targeting_help when starting this node.");
69 throw std::runtime_error(
"Please specify parameter base_frame_id when starting this node.");
72 throw std::runtime_error(
"Please specify parameter scale_factor when starting this node.");
74 throw std::runtime_error(
"Please specify parameter sigma_multiplicator when starting this node.");
86 if (!pTopology)
throw std::runtime_error(
"In TopologyEvaluator::evaluate(): topology from argument is null pointer.");
88 if (pTopology->isEvaluated())
return false;
93 update(pTopology->getTree());
100 unsigned int falseNegatives = 0;
101 unsigned int falsePositives = 0;
102 double recognitionRuntimeSum = 0;
108 std::pair<double, double> recognitionResult =
recognize(valid, pFullyMeshed);
110 recognitionRuntimeSum += recognitionResult.second;
117 std::pair<double, double> recognitionResult =
recognize(invalid, pFullyMeshed);
120 recognitionRuntimeSum += recognitionResult.second;
126 ROS_INFO_STREAM(
"Evaluation result: " << falsePositives <<
" false positives, " << falseNegatives <<
" false negatives, " << avgRuntime <<
"s average recognition runtime.");
128 pTopology->setEvaluationResult(avgRuntime, falsePositives, falseNegatives);
135 struct timeval start;
138 gettimeofday(&start, NULL);
140 gettimeofday(&end, NULL);
142 double recognitionRuntime, seconds, useconds;
143 seconds = end.tv_sec - start.tv_sec;
144 useconds = end.tv_usec - start.tv_usec;
145 recognitionRuntime = seconds + useconds / 1000000;
148 pEvidence->setFullyMeshedTestResult(probability, recognitionRuntime);
150 return std::pair<double, double>(probability, recognitionRuntime);
155 std::vector<ISM::Object> evidence;
156 for (ISM::ObjectPtr objPtr: pEvidence->mObjectSet->objects)
157 evidence.push_back(*objPtr);
172 mModel = boost::property_tree::ptree();
192 mVisualizer.reset(
new Visualization::ProbabilisticSceneVisualization(sceneId));
205 boost::property_tree::ptree extendedModel;
208 mModel.add(
"<xmlattr>.topology_id", pTopology->mIdentifier);
210 extendedModel.add_child(
"partial_model",
mModel);
214 std::cout <<
"Partial model in TopologyEvaluator run " <<
mRunNumber <<
":" << std::endl;
215 write_xml(std::cout, extendedModel);
216 std::cout << std::endl;
220 std::string xmlFileName =
mXmlFilePath +
"partial_model_" + boost::lexical_cast<std::string>(
mRunNumber) +
".xml";
221 write_xml(xmlFileName, extendedModel);
223 else throw std::runtime_error(
"Parameter xml_output has invalid value " +
mXmlOutput);
std::vector< boost::shared_ptr< TestSet > > mInvalidTestSets
double mRecognitionThreshold
std::vector< boost::shared_ptr< SceneObjectLearner > > mLearners
double getSceneProbability()
ForegroundSceneContent mForegroundSceneContent
void xmlOutput(boost::shared_ptr< SceneModel::Topology > pTopology)
std::string mInferenceAlgorithm
std::pair< double, double > recognize(boost::shared_ptr< TestSet > pEvidence, bool pFullyMeshed=false)
std::vector< boost::shared_ptr< ISM::ObjectSet > > mExamplesList
std::vector< boost::shared_ptr< TestSet > > mValidTestSets
void load(boost::property_tree::ptree &pPt)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticSceneVisualization > mSuperior)
double getProbability(boost::shared_ptr< TestSet > pEvidence)
bool evaluate(boost::shared_ptr< SceneModel::Topology > pTopology, bool pFullyMeshed=false)
void initializeInferenceAlgorithms(std::string pAlgorithm)
boost::property_tree::ptree mModel
boost::shared_ptr< Visualization::ProbabilisticSceneVisualization > mVisualizer
void update(std::vector< ISM::Object > pEvidenceList, std::ofstream &pRuntimeLogger)
std::ofstream mRuntimeLogger
#define ROS_INFO_STREAM(args)
void update(boost::shared_ptr< SceneModel::TreeNode > pTree)
bool getParam(const std::string &key, std::string &s) const
TopologyEvaluator(std::vector< boost::shared_ptr< ISM::ObjectSet >> pExamplesList, std::vector< boost::shared_ptr< SceneObjectLearner >> pLearners, double pRecognitionThreshold)