【发布时间】:2017-09-18 14:47:40
【问题描述】:
首先:我正在使用 OpenCV C++ 进行图像处理。在 C++ 程序中加载 Mat 图像后,我使用 GNUPLOT 绘制了图像的图形。
现在,要求是记录 Mat 图像的图形数据。
为此,我通过包含所有 BOOST 库创建了一个 BOOST C++ 记录器。 BOOST 也是一个用于测试和记录数据的优秀库,但是它的 Log 的问题是它只能记录文本消息。如果我错了纠正我。
以下是我在 OpenCV 中使用 GNUPlot 绘制图形的代码:
try
{
Gnuplot g1("lines");
std::vector<double> rowVector;
std::vector<double> rowVectorExp;
for (int i = 0; i < 50; i++)
{
rowVector.push_back((double)i);
rowVectorExp.push_back((double)exp((float)i/10.0));
}
cout << "*** user-defined lists of doubles" << endl;
g1 << "set term png";
g1 << "set output \"test.png\"";
//type of plot pattern
g1.set_grid().set_style("lines");
g1.plot_xy(rowVector, rowVectorExp, "user-defined points 2d");
waitKey(0);
}
catch (GnuplotException ge)
{
cout << ge.what() << endl;
}
cout << endl << "*** end of gnuplot example" << endl;
这是我的 BOOST 日志代码:
namespace logging = boost::log;
void PlainGetEdgeVector::init()
{
logging::add_file_log("sample%3N.log");
}
BOOST_LOG_TRIVIAL(info) << "This is my first Log line";
好消息是,我的 BOOST Logger 成功记录了短信。如果它也可以记录我的图形数据,那就太好了。
有什么建议吗?如果有人知道如何使用 BOOST 实现相同的功能,我将非常感激,或者如果有任何替代方案,也很高兴知道这一点。
【问题讨论】:
标签: c++ opencv logging boost boost-log