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);
180 if (background.
width()>0)
196 "Test grabber period %g / freq %g , mode %s",
204 for (
auto& buff : buffs) {
213 yCError(
FAKEFRAMEGRABBER,
"If yes, use the `fakeFrameGrabber_rpc_port` parameter to set a different name for each of them");
242 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
248 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
255 for (
size_t i = 0; i < 2 && !
isStopping(); ++i) {
257 std::unique_lock<std::mutex>
lk(mutex[i]);
258 createTestImage(buffs[i], buff_ts[i]);
262 curr_buff_mutex.lock();
264 curr_buff_mutex.unlock();
265 std::this_thread::yield();
267 std::unique_lock<std::mutex>
lk(mutex[i]);
268 img_consumed_cv[i].wait(
lk, [&]{
if (img_ready[i]) {img_ready_cv[i].notify_one();}
return (
isStopping() || img_consumed[i]);});
272 img_ready[i] =
false;
273 img_consumed[i] =
false;
274 createTestImage(buffs[i], buff_ts[i]);
276 img_ready_cv[i].notify_all();
286 for (
size_t i = 0; i < 2; ++i) {
287 std::unique_lock<std::mutex>
lk(mutex[i]);
288 img_consumed[i] =
true;
289 img_consumed_cv[i].notify_all();
291 img_ready_cv[i].notify_all();
300 return ReturnValue::return_code::return_value_error_not_ready;
304 curr_buff_mutex.lock();
305 size_t cb = curr_buff;
306 std::unique_lock<std::mutex>
lk(mutex[
cb]);
309 curr_buff_mutex.unlock();
313 curr_buff_mutex.lock();
315 size_t cb = curr_buff;
316 std::unique_lock<std::mutex>
lk(mutex[
cb]);
317 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
319 return ReturnValue::return_code::return_value_error_not_ready;
324 img_consumed[
cb] =
true;
325 img_consumed_cv[
cb].notify_one();
327 curr_buff = (
cb + 1) % 2;
328 curr_buff_mutex.unlock();
337 return ReturnValue::return_code::return_value_error_not_ready;
341 curr_buff_mutex.lock();
342 size_t cb = curr_buff;
343 std::unique_lock<std::mutex>
lk(mutex[
cb]);
344 curr_buff_mutex.unlock();
346 makeSimpleBayer(buffs[
cb],
image);
352 curr_buff_mutex.lock();
354 size_t cb = curr_buff;
355 std::unique_lock<std::mutex>
lk(mutex[
cb]);
356 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
358 return ReturnValue::return_code::return_value_error_not_ready;
361 makeSimpleBayer(buffs[
cb],
image);
366 img_consumed[
cb] =
true;
367 img_consumed_cv[
cb].notify_one();
369 curr_buff = (
cb + 1) % 2;
370 curr_buff_mutex.unlock();
377 std::vector<yarp::dev::vertex_t> vertices,
385 std::vector<yarp::dev::vertex_t> vertices,
394 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)