有没有办法将OpenCv图像的直方图存储到磁盘上,这样就可以直接加载而不必强制重新加载图像并从中计算直方图?谢谢。
// save file
cv::Mat my_histogram;
cv::FileStorage fs("my_histogram_file.yml", cv::FileStorage::WRITE);
if (!fs.isOpened()) {std::cout << "unable to open file storage!" << std::endl; return;}
fs << "my_histogram" << my_histogram;
fs.release();
// load file
cv::Mat my_histogram;
cv::FileStorage fs("my_histogram_file.yml", cv::FileStorage::READ);
if (!fs.isOpened()) {std::cout << "unable to open file storage!" << std::endl; return;}
fs >> "my_histogram" >> my_histogram;
fs.release();
fs >> "my_histogram" >> my_histogram;
读取时出现错误,所以我不得不改成fs["my_histogram"] >> my_histogram;
。参考:http://docs.opencv.org/modules/core/doc/xml_yaml_persistence.html。 - rdasxy