Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
Last active December 11, 2016 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnaNancyOwen/005022ca02abd9112d140ae04d2516e1 to your computer and use it in GitHub Desktop.
Save UnaNancyOwen/005022ca02abd9112d140ae04d2516e1 to your computer and use it in GitHub Desktop.
OpenCV Build Information Parser
/*
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment