30 bool ok = command.
read(connection);
40 reply.
addString(
"set_image <file_name>/off");
41 reply.
addString(
"available modes: ball, line, grid, size, rand, none, time");
93 reply.
addString(
"Unknown command. Type 'help'.");
124 m_intrinsic.
put(
"rectificationMatrix",val);
136 conf1.framerate=60.0;
138 configurations.push_back(
conf1);
143 conf2.framerate=30.0;
145 configurations.push_back(
conf2);
150 conf3.framerate=15.0;
152 configurations.push_back(
conf3);
175 if (background.
width()>0)
191 "Test grabber period %g / freq %g , mode %s",
199 for (
auto& buff : buffs) {
208 yCError(
FAKEFRAMEGRABBER,
"If yes, use the `fakeFrameGrabber_rpc_port` parameter to set a different name for each of them");
237 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
243 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
250 for (
size_t i = 0; i < 2 && !
isStopping(); ++i) {
252 std::unique_lock<std::mutex>
lk(mutex[i]);
253 createTestImage(buffs[i], buff_ts[i]);
257 curr_buff_mutex.lock();
259 curr_buff_mutex.unlock();
260 std::this_thread::yield();
262 std::unique_lock<std::mutex>
lk(mutex[i]);
263 img_consumed_cv[i].wait(
lk, [&]{
if (img_ready[i]) {img_ready_cv[i].notify_one();}
return (
isStopping() || img_consumed[i]);});
267 img_ready[i] =
false;
268 img_consumed[i] =
false;
269 createTestImage(buffs[i], buff_ts[i]);
271 img_ready_cv[i].notify_all();
281 for (
size_t i = 0; i < 2; ++i) {
282 std::unique_lock<std::mutex>
lk(mutex[i]);
283 img_consumed[i] =
true;
284 img_consumed_cv[i].notify_all();
286 img_ready_cv[i].notify_all();
295 return ReturnValue::return_code::return_value_error_not_ready;
299 curr_buff_mutex.lock();
300 size_t cb = curr_buff;
301 std::unique_lock<std::mutex>
lk(mutex[
cb]);
304 curr_buff_mutex.unlock();
308 curr_buff_mutex.lock();
310 size_t cb = curr_buff;
311 std::unique_lock<std::mutex>
lk(mutex[
cb]);
312 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
314 return ReturnValue::return_code::return_value_error_not_ready;
319 img_consumed[
cb] =
true;
320 img_consumed_cv[
cb].notify_one();
322 curr_buff = (
cb + 1) % 2;
323 curr_buff_mutex.unlock();
332 return ReturnValue::return_code::return_value_error_not_ready;
336 curr_buff_mutex.lock();
337 size_t cb = curr_buff;
338 std::unique_lock<std::mutex>
lk(mutex[
cb]);
339 curr_buff_mutex.unlock();
341 makeSimpleBayer(buffs[
cb],
image);
347 curr_buff_mutex.lock();
349 size_t cb = curr_buff;
350 std::unique_lock<std::mutex>
lk(mutex[
cb]);
351 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
353 return ReturnValue::return_code::return_value_error_not_ready;
356 makeSimpleBayer(buffs[
cb],
image);
361 img_consumed[
cb] =
true;
362 img_consumed_cv[
cb].notify_one();
364 curr_buff = (
cb + 1) % 2;
365 curr_buff_mutex.unlock();
372 std::vector<yarp::dev::vertex_t> vertices,
380 std::vector<yarp::dev::vertex_t> vertices,
389 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
std::string m_fakeFrameGrabber_rpc_port
std::string m_distortionModel
std::vector< double > m_rectificationMatrix
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
int width() const override
Return the width of each frame.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
int height() const override
Return the height of each frame.
bool open(yarp::os::Searchable &config) override
yarp::dev::ReturnValue getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an image from the frame grabber.
yarp::dev::ReturnValue getImageCrop(yarp::dev::cropType_id_t cropType, std::vector< yarp::dev::vertex_t > vertices, yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get a crop of the image from the frame grabber.
void run() override
Main body of the new thread.
void onStop() override
Call-back, called while halting the thread (before join).
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool close() override
Close the DeviceDriver.
Struct describing a possible camera configuration.
Read a YARP-format image (of a specific type) from a device.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a 32 bit vocabulary item in the bottle, at the end of the list.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
void setReader(PortReader &reader) override
Set an external reader for port data.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
bool stop()
Stop the thread.
bool isStopping()
Returns true if the thread is stopping (Thread::stop has been called).
bool isRunning()
Returns true if the thread is running (Thread::start has been called successfully and the thread has ...
bool start()
Start the new thread running.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
static Value * makeList()
Create a list Value.
virtual Bottle * asList() const
Get list value.
virtual std::string asString() const
Get string value.
size_t width() const
Gets width of image in pixels.
size_t height() const
Gets height of image in pixels.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebugThrottle(component, period,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
For streams capable of holding different kinds of content, check what they actually have.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)