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/os/Network.h
>
#include <
yarp/os/BufferedPort.h
>
#include <
yarp/os/Property.h
>
#include <
yarp/sig/Image.h
>
#include <
yarp/dev/PolyDriver.h
>
#include <
yarp/dev/IFrameGrabberImage.h
>
int
main
(
int
argc,
char
* argv[])
{
YARP_UNUSED
(argc);
YARP_UNUSED
(argv);
using
ImageType
=
yarp::sig::ImageOf<yarp::sig::PixelRgb>
;
yarp::os::Network
yarp
;
yarp::os::BufferedPort<ImageType>
out;
out.
open
(
"/test_yarp_crop"
);
yarp::dev::PolyDriver
dd;
yarp::os::Property
p;
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;
}
BufferedPort.h
IFrameGrabberImage.h
YARP_CROP_RECT
@ YARP_CROP_RECT
Definition
IFrameGrabberImage.h:15
Image.h
Network.h
PolyDriver.h
Property.h
yarp::dev::DeviceDriver::view
bool view(T *&x)
Get an interface to the device driver.
Definition
DeviceDriver.h:87
yarp::dev::IFrameGrabberOf< yarp::sig::ImageOf< yarp::sig::PixelRgb > >
yarp::dev::IFrameGrabberOf::getImageCrop
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.
Definition
IFrameGrabberImage-inl.h:18
yarp::dev::PolyDriver
A container for a device driver.
Definition
PolyDriver.h:23
yarp::dev::PolyDriver::open
bool open(const std::string &txt)
Construct and configure a device by its common name.
Definition
PolyDriver.cpp:77
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition
BufferedPort.h:60
yarp::os::BufferedPort::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition
BufferedPort-inl.h:38
yarp::os::BufferedPort::write
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
Definition
BufferedPort-inl.h:123
yarp::os::BufferedPort::prepare
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
Definition
BufferedPort-inl.h:111
yarp::os::Network
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition
Network.h:706
yarp::os::Property
A class for storing options and configuration information.
Definition
Property.h:33
yarp::os::Property::put
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition
Property.cpp:987
yarp::sig::ImageOf< yarp::sig::PixelRgb >
yarp::sig::VectorOf
Provides:
Definition
Vector.h:117
main
int main(int argc, char *argv[])
Definition
main.cpp:121
yarp
The main, catch-all namespace for YARP.
Definition
dirs.h:16
YARP_UNUSED
#define YARP_UNUSED(var)
Definition
api.h:162
YARP
3.11.100+20250603.4+gitaa77f8b5c
Generated on Wed Jun 4 2025 02:39:55 for YARP by
1.9.8