Last active
December 11, 2016 10:31
-
-
Save UnaNancyOwen/005022ca02abd9112d140ae04d2516e1 to your computer and use it in GitHub Desktop.
OpenCV Build Information Parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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