-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0ac04f
commit 4b92ef0
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | ||
|
||
project(exampleRemoteGrabber LANGUAGES CXX) | ||
|
||
find_package(YARP 3.2 REQUIRED COMPONENTS os dev sig) | ||
|
||
add_executable(exampleRemoteGrabber exampleRemoteGrabber.cpp) | ||
|
||
target_link_libraries(exampleRemoteGrabber YARP::YARP_os | ||
YARP::YARP_init | ||
YARP::YARP_dev | ||
YARP::YARP_sig) | ||
|
||
include(GNUInstallDirs) | ||
|
||
install(TARGETS exampleRemoteGrabber | ||
DESTINATION ${CMAKE_INSTALL_BINDIR}) |
60 changes: 60 additions & 0 deletions
60
examples/cpp/exampleRemoteGrabber/exampleRemoteGrabber.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- | ||
|
||
/** | ||
* @ingroup vision_examples | ||
* @defgroup exampleRemoteGrabber exampleRemoteGrabber | ||
* @brief This example connects to a remote grabber (generally, RGB) device. | ||
*/ | ||
|
||
#include <cstdio> | ||
|
||
#include <yarp/os/Network.h> | ||
#include <yarp/os/Property.h> | ||
|
||
#include <yarp/dev/PolyDriver.h> | ||
#include <yarp/dev/FrameGrabberInterfaces.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
yarp::os::Network yarp; | ||
|
||
if (!yarp::os::Network::checkNetwork()) | ||
{ | ||
std::printf("Please start a yarp name server first\n"); | ||
return 1; | ||
} | ||
|
||
yarp::os::Property options; | ||
|
||
options.put("device","remote_grabber"); | ||
options.put("local","/exampleRemoteGrabber"); | ||
options.put("remote","/grabber"); | ||
|
||
yarp::dev::PolyDriver dd(options); | ||
|
||
if (!dd.isValid()) | ||
{ | ||
std::printf("Device not available.\n"); | ||
return 1; | ||
} | ||
|
||
yarp::dev::IFrameGrabberImage *iFrameGrabberImage; | ||
|
||
if (!dd.view(iFrameGrabberImage)) | ||
{ | ||
std::printf("[error] Problems acquiring interface\n"); | ||
return 1; | ||
} | ||
|
||
std::printf("[success] acquired interface\n"); | ||
|
||
// The following delay should avoid bad status | ||
yarp::os::Time::delay(1); | ||
|
||
std::printf("Width: %d\n", iFrameGrabberImage->width()); | ||
std::printf("Height: %d\n", iFrameGrabberImage->height()); | ||
|
||
dd.close(); | ||
|
||
return 0; | ||
} |