YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
dev/grabber_crop/grabber_crop.cpp

How to grab cropped images from a remote source using the yarp::dev::IFrameGrabberImage interface.

How to grab cropped images from a remote source using the yarp::dev::IFrameGrabberImage interface.

See also
yarp::dev::IFrameGrabberImage::getImageCrop
/*
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <yarp/sig/Image.h>
int main(int argc, char* argv[])
{
YARP_UNUSED(argc);
YARP_UNUSED(argv);
out.open("/test_yarp_crop");
p.put("device", "fakeFrameGrabber");
p.put("mode", "grid");
dd.open(p);
yarp::dev::IFrameGrabberImage *grabber = nullptr;
dd.view(grabber);
const yarp::sig::VectorOf<std::pair< int, int>> vertices {{50,50}, {149, 149}};
while (true) {
auto& crop = out.prepare();
grabber->getImageCrop(YARP_CROP_RECT, vertices, crop);
out.write();
}
return 0;
}
@ YARP_CROP_RECT
bool view(T *&x)
Get an interface to the device driver.
virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, ImageType &image)
Get a crop of the image from the frame grabber.
A container for a device driver.
Definition PolyDriver.h:23
bool open(const std::string &txt)
Construct and configure a device by its common name.
A mini-server for performing network communication in the background.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
A class for storing options and configuration information.
Definition Property.h:33
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition Property.cpp:987
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_UNUSED(var)
Definition api.h:162