#include "lfr.h" #include int main(void) { //Disable opencv logging messages //cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING); const int thresholdBinary = 140; const int videoHeight = 720; const int videoWidth = 1280; const int gaussKernelSize = 11; std::mutex mutex; LFR lfr(videoHeight, videoWidth, thresholdBinary, gaussKernelSize, [&](std::exception const &ex) { std::unique_lock lock(mutex); std::cerr<<"camera exception:"<(std::chrono::system_clock::now().time_since_epoch()); std::chrono::milliseconds now = duration_cast(std::chrono::system_clock::now().time_since_epoch()); cv::Mat img; lfr.addListener([&](LFR_Result result) { std::unique_lock lock(mutex); if (!result.rawImage.empty()) { cv::resize(result.rawImage, img, cv::Size(128, 64+32)); //Calculate frame rate now = duration_cast(std::chrono::system_clock::now().time_since_epoch()); unsigned int deltaMs = (now-last).count(); float delta = static_cast(deltaMs) / 1000.0; float frameRate = 1.0 / static_cast(delta); //std::cout << "Frame rate: " << frameRate << std::endl; last = now; } }, &mutex); lfr.startLoop(); for(int finished = false; finished != 'q';){ finished = std::tolower(cv::waitKey(66)); std::unique_lock lock(mutex); if(!img.empty()){ cv::imshow("frame", img); } } }