c_cpp OpenCV构建信息解析器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp OpenCV构建信息解析器相关的知识,希望对你有一定的参考价值。

/*
BuildInformation info;
std::string value = info.getValue( "JPEG" );
std::cout << value << std::endl; // build (ver 90)
*/

#ifndef __BUILD_INFORMATION__
#define __BUILD_INFORMATION__

#include <string>
#include <sstream>
#include <opencv2/opencv.hpp>

class BuildInformation
{
    private:
    std::stringstream stream;

    public:
    BuildInformation() : stream( cv::getBuildInformation() )
    {}

    ~BuildInformation()
    {
        stream.str( "" );
    }

    std::string getValue( const std::string& key )
    {
        std::string buffer;
        while( std::getline( stream, buffer ) ){
            std::string::size_type position;
            position = buffer.find( key + ":" );
            if( position == std::string::npos ){ continue; }
            position = buffer.find_first_not_of( " ", position + key.length() + 1 );
            if( position == std::string::npos ){ continue; }
            return buffer.substr( position );
        }
        return "";
    }
};

#endif

以上是关于c_cpp OpenCV构建信息解析器的主要内容,如果未能解决你的问题,请参考以下文章