Skip to content

Instantly share code, notes, and snippets.

@roman-smirnov
Created October 25, 2019 10:30
Show Gist options
  • Save roman-smirnov/a46f6096787987a96927e05352363cc7 to your computer and use it in GitHub Desktop.
Save roman-smirnov/a46f6096787987a96927e05352363cc7 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cstdlib>
struct perfStats {
std::string detectorType;
std::string descriptorType;
std::string matchingType;
std::string selectorType;
int numKeyPointsPerframe[10];
int numKeyPointsPerROI[10];
int numMatchedKeyPoints[10];
double detectorTime[10];
double descriptorTime[10];
double MatcherTime[10];
};
// please see https://en.cppreference.com/w/cpp/io/basic_istream
int main(int argc, char *argv[]) {
// init det/des combinations container, then fill it
std::vector<perfStats> combinations;
/// TODO: fill combinations...
std::string filename = "../data.csv";
std::ofstream output_stream(filename, std::ios::binary);
if (!output_stream.is_open()) {
std::cerr << "failed to open file: " << filename << std::endl;
return EXIT_FAILURE;
}
// write CSV header row
output_stream << "Detector Type" << ","
<< "Descriptor Type" << ","
<< "Frame#" << ","
<< "#KeyPointsPerFrame" << ","
<< "#KeyPointsPerROI" << ","
<< "DetectorTime(ms)" << ","
<< "DescriptorTime(ms)" << ","
<< "#MatchedPoints" << "," << "MatchingTime(ms))" << std::endl;
// write det/des performance data to .csv output file line by line
for (const auto &combo : combinations) {
for (int i = 0; i < 10; i++) {
output_stream << combo.detectorType
<< "," << combo.descriptorType
<< "," << i
<< "," << combo.numKeyPointsPerframe[i]
<< "," << combo.numKeyPointsPerROI[i]
<< "," << std::fixed << std::setprecision(8) << combo.detectorTime[i]
<< "," << std::fixed << std::setprecision(8) << combo.descriptorTime[i]
<< "," << combo.numMatchedKeyPoints[i]
<< "," << std::fixed << std::setprecision(8) << combo.MatcherTime[i] << std::endl;
}
output_stream << std::endl;
}
output_stream.close();
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment