RobotsIO
Loading...
Searching...
No Matches
YarpImageOfProbe.hpp
1/*
2 * Copyright (C) 2019 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#ifndef ROBOTSIO_YARPIMAGEOFPROBE_H
9#define ROBOTSIO_YARPIMAGEOFPROBE_H
10
11#include <RobotsIO/Utils/Data.h>
12#include <RobotsIO/Utils/Probe.h>
13#include <RobotsIO/Utils/YarpBufferedPort.hpp>
14#include <RobotsIO/Utils/any.h>
15
16#include <string>
17
18#include <yarp/cv/Cv.h>
19#include <yarp/sig/Image.h>
20
21namespace RobotsIO {
22 namespace Utils {
23 template <class T>
24 class YarpImageOfProbe;
25 }
26}
27
28
29template <class T>
32{
33public:
34 YarpImageOfProbe(const std::string& port_name);
35
36 virtual ~YarpImageOfProbe();
37
38protected:
39 void on_new_data() override;
40
41private:
42 cv::Mat data_cv_;
43
44 yarp::sig::ImageOf<T> data_;
45
46 const std::string log_name_ = "YarpImageOfProbe";
47};
48
49
50template <class T>
52 YarpBufferedPort<yarp::sig::ImageOf<T>>(port_name)
53{}
54
55
56template <class T>
58{}
59
60
61template <class T>
63{
64 data_cv_ = RobotsIO::Utils::any_cast<cv::Mat>(get_data());
65
66 data_ = yarp::cv::fromCvMat<T>(data_cv_);
67
68 this->send_data(data_);
69}
70
71#endif /* ROBOTSIO_YARPIMAGEOFPROBE_H */