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'.");
140 conf1.framerate=60.0;
142 configurations.push_back(
conf1);
147 conf2.framerate=30.0;
149 configurations.push_back(
conf2);
154 conf3.framerate=15.0;
156 configurations.push_back(
conf3);
184 if (background.
width()>0)
200 "Test grabber period %g / freq %g , mode %s",
208 for (
auto& buff : buffs) {
217 yCError(
FAKEFRAMEGRABBER,
"If yes, use the `fakeFrameGrabber_rpc_port` parameter to set a different name for each of them");
246 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
252 std::lock_guard<std::mutex> lock(rpc_methods_mutex);
259 for (
size_t i = 0; i < 2 && !
isStopping(); ++i) {
261 std::unique_lock<std::mutex>
lk(mutex[i]);
262 createTestImage(buffs[i], buff_ts[i]);
266 curr_buff_mutex.lock();
268 curr_buff_mutex.unlock();
269 std::this_thread::yield();
271 std::unique_lock<std::mutex>
lk(mutex[i]);
272 img_consumed_cv[i].wait(
lk, [&]{
if (img_ready[i]) {img_ready_cv[i].notify_one();}
return (
isStopping() || img_consumed[i]);});
276 img_ready[i] =
false;
277 img_consumed[i] =
false;
278 createTestImage(buffs[i], buff_ts[i]);
280 img_ready_cv[i].notify_all();
290 for (
size_t i = 0; i < 2; ++i) {
291 std::unique_lock<std::mutex>
lk(mutex[i]);
292 img_consumed[i] =
true;
293 img_consumed_cv[i].notify_all();
295 img_ready_cv[i].notify_all();
304 return ReturnValue::return_code::return_value_error_not_ready;
308 curr_buff_mutex.lock();
309 size_t cb = curr_buff;
310 std::unique_lock<std::mutex>
lk(mutex[
cb]);
313 curr_buff_mutex.unlock();
317 curr_buff_mutex.lock();
319 size_t cb = curr_buff;
320 std::unique_lock<std::mutex>
lk(mutex[
cb]);
321 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
323 return ReturnValue::return_code::return_value_error_not_ready;
328 img_consumed[
cb] =
true;
329 img_consumed_cv[
cb].notify_one();
331 curr_buff = (
cb + 1) % 2;
332 curr_buff_mutex.unlock();
341 return ReturnValue::return_code::return_value_error_not_ready;
345 curr_buff_mutex.lock();
346 size_t cb = curr_buff;
347 std::unique_lock<std::mutex>
lk(mutex[
cb]);
348 curr_buff_mutex.unlock();
350 makeSimpleBayer(buffs[
cb],
image);
356 curr_buff_mutex.lock();
358 size_t cb = curr_buff;
359 std::unique_lock<std::mutex>
lk(mutex[
cb]);
360 img_ready_cv[
cb].wait(
lk, [&]{
return (!
isRunning() || img_ready[
cb]);});
362 return ReturnValue::return_code::return_value_error_not_ready;
365 makeSimpleBayer(buffs[
cb],
image);
370 img_consumed[
cb] =
true;
371 img_consumed_cv[
cb].notify_one();
373 curr_buff = (
cb + 1) % 2;
374 curr_buff_mutex.unlock();
381 std::vector<yarp::dev::VertexData> vertices,
389 std::vector<yarp::dev::VertexData> vertices,
398 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::VertexData > 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.
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.
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.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::string asString() const
Get string value.
static int32_t fromString(const std::string &input)
CameraDistortionType type
size_t width() const
Gets width of image in pixels.
size_t height() const
Gets height of image in pixels.
yarp::sig::DistortionModelData distortionModel
yarp::sig::Vector rectificationMatrix3X3
#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)