Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "yaml-cpp/yaml.h"
- #include <vector>
- #include <opencv2/core/core.hpp>
- int main()
- {
- YAML::Emitter camera;
- std::vector<int> a = { 1,2,3,4,5};
- std::vector<int> a1 = { 1,2,3,4,5};
- std::vector<int> a2 = { 6,7,8,9,50};
- std::vector<std::vector<int>> b = {a1, a2};
- camera << YAML::BeginMap
- << YAML::Key << "camera"
- << YAML::Value << YAML::BeginMap
- << YAML::Key << "name" << YAML::Value << "cam001"
- << YAML::Key << "active" << YAML::Value << true
- << YAML::Key << "height" << YAML::Value << 640
- << YAML::Key << "width" << YAML::Value << 480
- << YAML::Key << "D" << YAML::Value << YAML::Flow << a
- << YAML::Key << "K" << YAML::Value << YAML::Flow << b
- << YAML::EndMap
- << YAML::EndMap;
- YAML::Node node = YAML::Load(camera.c_str());
- cv::Mat qw;
- /* qw = cv::Mat_<float> */
- std::cout<< (bool)node["camera"]["active"];
- std::vector<int> row1 = node["camera"]["K"][1].as<std::vector<int>>();
- node["camera"]["K"][0] = a2;
- std::cout << node << '\n';
- std::cout << node["camera"]["K"][1] << '\n';
- /* std::cout << "Here's the output YAML:\n" << camera.c_str() << '\n'; // prints "Hello, World!" */
- /* std::string name="_qwq"; */
- /* std::cout<<"asasa "<<name.substr(0,0)<<'\n'; */
- return 0;
- }
- // g++ main.cpp -std=c++14 -lyaml-cpp && ./a.out
Add Comment
Please, Sign In to add comment