Skip to content

Commit

Permalink
[#51104] farshow-streamer-example: Added graceful stopping of the app…
Browse files Browse the repository at this point in the history
…lication

Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
  • Loading branch information
glatosinski committed Nov 7, 2023
1 parent 459ba0f commit 3804ef2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/farshow-streamer-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@
#include "grabthecam/frameconverters/bayer2bgrconverter.hpp"
#include "grabthecam/frameconverters/yuv2bgrconverter.hpp"
#include "grabthecam/pixelformatsinfo.hpp"
#include <csignal>
#include <opencv2/imgproc.hpp>
#include <thread>

#include "grabthecam/utils.hpp"

bool app_running = true;

void appStopHandler(int signum)
{
app_running = false;
std::signal(signum, SIG_DFL);
}

/**
* User's preferred configuration
*/
Expand Down Expand Up @@ -182,11 +191,13 @@ int main(int argc, char const *argv[])
}

auto f = [&streamer, conf](cv::Mat foo) { streamer.sendFrame(foo, conf.stream_name); };
std::signal(SIGINT, appStopHandler);

// CAPTURE FRAMES
if (camera.hasConverter())
{
cv::Mat processed_frame = camera.capture();
while (1)
while (app_running)
{
std::thread sender(f, processed_frame);
processed_frame = camera.capture();
Expand Down

0 comments on commit 3804ef2

Please sign in to comment.