void object_recognition_core::db::DummyDocument::set_attachment<cv::linemod::Detector>(const AttachmentName& attachment_name, const cv::linemod::Detector& value) { // First write the class to a file std::string file_name = temporary_yml_file_name(true); { cv::FileStorage fs(file_name, cv::FileStorage::WRITE); value.write(fs); std::vector < std::string > ids = value.classIds(); fs << "classes" << "["; for (int i = 0; i < (int) ids.size(); ++i) { fs << "{"; value.writeClass(ids[i], fs); fs << "}"; // current class } fs << "]"; // classes fs.release(); } // Read the file as a stream std::ifstream reader(file_name.c_str()); std::stringstream out; out << reader.rdbuf(); set_attachment_stream(attachment_name, out, MIME_TYPE); boost::filesystem::remove(file_name.c_str()); }
void object_recognition_core::db::DummyDocument::set_attachment<std::vector<float> >(const AttachmentName& attachment_name, const std::vector<float>& value) { std::stringstream out; for(std::vector<float>::const_iterator i=value.begin(); i != value.end(); ++i) out << *i; set_attachment_stream(attachment_name, out, MIME_TYPE); }
void object_recognition_core::db::Document::set_attachment<transpod::PoseEstimator>(const AttachmentName &attachment_name, const transpod::PoseEstimator &value) { // First write the class to a file std::string file_name = temporary_yml_file_name(true); { cv::FileStorage fs(file_name, cv::FileStorage::WRITE); value.write(fs); fs.release(); } // Read the file as a stream std::ifstream reader(file_name.c_str()); std::stringstream out; out << reader.rdbuf(); set_attachment_stream(attachment_name, out, MIME_TYPE); boost::filesystem::remove(file_name.c_str()); }
void object_recognition_core::db::DummyDocument::set_attachment<std::vector<cv::Mat> >(const AttachmentName& attachment_name, const std::vector<cv::Mat>& value) { // First write the class to a file std::string file_name = temporary_yml_file_name(false); { cv::FileStorage fs(file_name, cv::FileStorage::WRITE); fs << "matrices" << value; fs.release(); } // Read the file as a stream std::ifstream reader(file_name.c_str()); std::stringstream out; out << reader.rdbuf(); set_attachment_stream(attachment_name, out, MIME_TYPE); boost::filesystem::remove(file_name.c_str()); }