Created
March 15, 2023 02:53
-
-
Save illusion0001/cdd0fd1cca023da120ad708039faeb76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#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