RobotsIO
Loading...
Searching...
No Matches
ImageFileProbe.cpp
1/*
2 * Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#include <RobotsIO/Utils/ImageFileProbe.h>
9
10#include <opencv2/opencv.hpp>
11
12using namespace RobotsIO::Utils;
13
14
15ImageFileProbe::ImageFileProbe(const std::string& output_path, const std::string& prefix, const std::string& output_format) :
16 output_prefix_(output_path),
17 output_format_(output_format)
18{
19 if (output_prefix_.back() != '/')
20 output_prefix_ += '/';
21
22 if (!prefix.empty())
23 output_prefix_ += (prefix + "_");
24}
25
26
27ImageFileProbe::~ImageFileProbe()
28{}
29
30
31void ImageFileProbe::on_new_data()
32{
33 data_cv_ = RobotsIO::Utils::any_cast<cv::Mat>(get_data());
34
35 cv::imwrite(output_prefix_ + std::to_string(frame_counter_) + "." + output_format_, data_cv_);
36
37 frame_counter_++;
38}