Skip to content

Instantly share code, notes, and snippets.

@illusion0001
Created March 15, 2023 02:53
Show Gist options
  • Save illusion0001/cdd0fd1cca023da120ad708039faeb76 to your computer and use it in GitHub Desktop.
Save illusion0001/cdd0fd1cca023da120ad708039faeb76 to your computer and use it in GitHub Desktop.
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include "rapidcsv.h"
#include <numeric>
int main()
{
std::string doc_file = "C:\\Users\\ME\\source\\repos\\opencv-test\\opencv-test\\test.csv";
rapidcsv::Document doc(doc_file);
std::vector<int> isDupeFrame = doc.GetColumn<int>("bDupeFrame");
std::cout << "Read " << isDupeFrame.size() << " values from " << doc_file << "\n";
std::vector<int> fps_list(60, 0);
std::vector<double> fps_graph(60, 0.0);
double fps = 0.0;
// https://github.com/AndrewKeYanzhe/frametime-analyser/blob/afe51142f6436c143e4767191c384e300d05bf4e/Frametime%20Analyser.py#L96
// for average calc based on dupe frames in vector [ 0, 0, 1, 1, 0 ,1 ,0 ]
for (int i = 0; i < isDupeFrame.size(); i++)
{
if (isDupeFrame[i])
{
fps_list.erase(fps_list.begin());
fps_list.push_back(0);
}
else
{
fps_list.erase(fps_list.begin());
fps_list.push_back(1);
}
fps = std::accumulate(fps_list.begin(), fps_list.end(), 0.0);
if (i < 60)
{
fps_graph[i] = fps;
}
else
{
std::rotate(fps_graph.begin(), fps_graph.begin() + 1, fps_graph.end());
fps_graph[59] = fps;
}
std::cout << fps << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment