diff --git a/sim_fpga/tutorial/tut05/imgs/sobel_horizontal_160x120.jpg b/sim_fpga/tutorial/tut05/imgs/sobel_horizontal_160x120.jpg new file mode 100644 index 0000000..9df8283 Binary files /dev/null and b/sim_fpga/tutorial/tut05/imgs/sobel_horizontal_160x120.jpg differ diff --git a/sim_fpga/tutorial/tut05/imgs/sobel_vertical_160x120.jpg b/sim_fpga/tutorial/tut05/imgs/sobel_vertical_160x120.jpg new file mode 100644 index 0000000..b6ffd21 Binary files /dev/null and b/sim_fpga/tutorial/tut05/imgs/sobel_vertical_160x120.jpg differ diff --git a/sim_fpga/tutorial/tut05/src/main.cpp b/sim_fpga/tutorial/tut05/src/main.cpp index 2c050fe..c18589b 100644 --- a/sim_fpga/tutorial/tut05/src/main.cpp +++ b/sim_fpga/tutorial/tut05/src/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include // to measure fps #include #include @@ -342,11 +343,18 @@ int main(int argc, char **argv) { cv::Mat grayrgb_input_feed; // grayscale resized image, but with 3 channels for the texture cv::VideoCapture cap(0); + double timed_fps; + unsigned int millis_elapsed = 0; + + // get opencv frame per seconds (FPS) + double cam_fps = cap.get(cv::CAP_PROP_FPS); if (!cap.isOpened()) { std::cout << "cannot open camera"; } + auto time_capture = std::chrono::high_resolution_clock::now(); + auto old_time_capture = std::chrono::high_resolution_clock::now(); cap >> input_feed; cv::resize(input_feed,resized_input_feed,cv::Size(IMG_COLS,IMG_ROWS),cv::INTER_LINEAR); cv::cvtColor(resized_input_feed, gray_input_feed, cv::COLOR_BGR2GRAY); @@ -438,6 +446,8 @@ int main(int argc, char **argv) { GRIP_LINES_VERTICAL_ICON " Set Vertical"); } + old_time_capture = time_capture; // save old capture + time_capture = std::chrono::high_resolution_clock::now(); // new time capture cap >> input_feed; cv::resize(input_feed,resized_input_feed,cv::Size(IMG_COLS,IMG_ROWS),cv::INTER_LINEAR); cv::cvtColor(resized_input_feed, gray_input_feed, cv::COLOR_BGR2GRAY); @@ -463,8 +473,15 @@ int main(int argc, char **argv) { //ImGui::SameLine(); + // the 1st capture will be wrong, but just only the first + auto elapsed = std::chrono::duration_cast( + time_capture - old_time_capture); + millis_elapsed = elapsed.count(); + timed_fps = 1000.0 / millis_elapsed; + ImGui::Text("Timed %i ms (%.1f FPS)", millis_elapsed, timed_fps); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + ImGui::Text("Maximum camera fps %.1f", cam_fps); ImGui::End(); }