YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeFrameWriter.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#include "FakeFrameWriter.h"
7
8#include <string>
9
10#include <yarp/os/Log.h>
12#include <yarp/os/LogStream.h>
13
14#include <yarp/sig/Image.h>
15
18
21using yarp::os::Value;
22
24using yarp::sig::PixelRgb;
25
26using namespace yarp::os;
27using namespace yarp::sig;
28using namespace yarp::dev;
29
30
31namespace {
32YARP_LOG_COMPONENT(FAKEIMAGEWRITER, "yarp.device.fakeImageWriter")
33}
34
35
37{
38 if (!parseParams(config)) {
39 return false;
40 }
41
42 if (m_filename == "") {
43 yCError(FAKEIMAGEWRITER) << "Invalid filename null";
44 return false;
45 }
46
47 if (m_framerate == 0) {
48 yCError(FAKEIMAGEWRITER) << "Invalid framerate 0";
49 return false;
50 }
51
52 yCInfo(FAKEIMAGEWRITER, "FakeFrameWriter opened");
53 return true;
54}
55
57{
59 {
60 m_isInitialized = false;
61 }
62 return true;
63}
64
66{
67 if (image.width() == 0 || image.height() == 0) {
68 yCError(FAKEIMAGEWRITER) << "Received empty frame";
69 return false;
70 }
71
72 if (m_width == 0) {m_width = image.width();}
73 if (m_height == 0) {m_height = image.height();}
74
75 if (!m_isInitialized)
76 {
77 m_isInitialized = true;
78 }
79
80 if (m_width != image.width())
81 {
82 yCError(FAKEIMAGEWRITER) << "Received frame has a width different from the current configuration" << m_width << "<<" << image.width();
83 return false;
84 }
85 if (m_height != image.height()) {
86 yCError(FAKEIMAGEWRITER) << "Received frame has a height different from the current configuration: " << m_height << "<<" << image.height();
87 return false;
88 }
89
90 yCDebug(FAKEIMAGEWRITER) << "Frame received:" << image.width() << image.height();
91
92 return true;
93}
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool putImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Write an image to the device.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
Interface implemented by all device drivers.
Read a YARP-format image to a device.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:33
A base class for nested structures that can be searched.
Definition Searchable.h:31
A single value (typically within a Bottle).
Definition Value.h:43
Typed image class.
Definition Image.h:605
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.