Skip to content
Snippets Groups Projects
Commit b1770e53 authored by Sebastian Gomez-Gonzalez's avatar Sebastian Gomez-Gonzalez
Browse files

Getting average processing time for the CPU and GPU examples

parent 6ebfd8b7
Branches sebas_dev
No related tags found
No related merge requests found
......@@ -9,12 +9,35 @@
#include <boost/program_options.hpp>
#include <json.hpp>
#include <chrono>
#include <cmath>
using namespace cv;
using namespace std;
using namespace ball_tracking;
using json = nlohmann::json;
struct TimeStats {
double mean;
double std;
};
TimeStats comp_stats(const vector<double>& time) {
double sum_1 = 0.0, sum_sq = 0.0;
for (double t : time) {
sum_1 += t;
sum_sq += t*t;
}
int N = time.size();
double mu = sum_1 / N;
double var = (sum_sq/N) - mu*mu;
return {mu, sqrt(var)};
}
ostream& operator<<(ostream& a, const TimeStats& st) {
a << "{mean=" << st.mean << ", std=" << st.std << "}";
return a;
}
int main(int argc, char** argv) {
try {
namespace po = boost::program_options;
......@@ -136,6 +159,7 @@ int main(int argc, char** argv) {
<< " ms" << endl;
if (k==27) break;
}
cout << "llh: " << comp_stats(llh_time) << " us, bin: " << comp_stats(bin_time) << " us, blob: " << comp_stats(blob_time) << " us" << endl;
return 0;
} catch (std::exception& ex) {
cerr << "Exception: " << ex.what() << endl;
......
......@@ -7,12 +7,35 @@
#include <boost/program_options.hpp>
#include <json.hpp>
#include <chrono>
#include <cmath>
using namespace cv;
using namespace std;
using namespace ball_tracking;
using json = nlohmann::json;
struct TimeStats {
double mean;
double std;
};
TimeStats comp_stats(const vector<double>& time) {
double sum_1 = 0.0, sum_sq = 0.0;
for (double t : time) {
sum_1 += t;
sum_sq += t*t;
}
int N = time.size();
double mu = sum_1 / N;
double var = (sum_sq/N) - mu*mu;
return {mu, sqrt(var)};
}
ostream& operator<<(ostream& a, const TimeStats& st) {
a << "{mean=" << st.mean << ", std=" << st.std << "}";
return a;
}
int main(int argc, char** argv) {
try {
namespace po = boost::program_options;
......@@ -127,6 +150,7 @@ int main(int argc, char** argv) {
<< " ms" << endl;
if (k==27) break;
}
cout << "llh: " << comp_stats(llh_time) << " us, bin: " << comp_stats(bin_time) << " us, blob: " << comp_stats(blob_time) << " us" << endl;
return 0;
} catch (std::exception& ex) {
cerr << "Exception: " << ex.what() << endl;
......
......@@ -4,6 +4,8 @@
#include <opencv2/opencv.hpp>
#include <json.hpp>
#include <string>
#include <vector>
#include <iostream>
namespace ball_tracking {
......@@ -24,6 +26,7 @@ namespace ball_tracking {
* @returns a JSON object
*/
nlohmann::json load_json(const std::string& file_name);
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment