From de8124faa678d32c5bd26a2777ea0f7c324ffa10 Mon Sep 17 00:00:00 2001 From: Francisco Perez Date: Mon, 13 Mar 2017 13:40:35 +0100 Subject: [PATCH] [issue #639] Made cameraview bilingual --- src/tools/cameraview/CMakeLists.txt | 10 +++-- src/tools/cameraview/cameraview.cfg | 6 ++- src/tools/cameraview/cameraview.cpp | 49 ++++++----------------- src/tools/cameraview/pioneer_left_cam.cfg | 1 - 4 files changed, 24 insertions(+), 42 deletions(-) delete mode 100644 src/tools/cameraview/pioneer_left_cam.cfg diff --git a/src/tools/cameraview/CMakeLists.txt b/src/tools/cameraview/CMakeLists.txt index ea40fd317..02232f6bc 100644 --- a/src/tools/cameraview/CMakeLists.txt +++ b/src/tools/cameraview/CMakeLists.txt @@ -14,10 +14,14 @@ include_directories( ${ZLIB_INCLUDE_DIRS} ${resourcelocator_INCLUDE_DIRS} ${easyiceconfig_INCLUDE_DIRS} + ${jderobottypes_INCLUDE_DIRS} + ${jderobotcomm_INCLUDE_DIRS} + ${roscpp_INCLUDE_DIRS} ) link_directories( ${resourcelocator_LIBRARY_DIRS} ${easyiceconfig_LIBRARY_DIRS} + ${jderobotcomm_LIBRARY_DIRS} ) add_executable (cameraview ${SOURCE_FILES}) @@ -29,11 +33,11 @@ TARGET_LINK_LIBRARIES(cameraview ${gtkmm_LIBRARIES} ${libglademm_LIBRARIES} colorspacesmm - JderobotInterfaces - parallelIce ${easyiceconfig_LIBRARIES} ${ZeroCIce_LIBRARIES} ${ZLIB_LIBRARIES} -${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_THREAD_LIBS_INIT} ${resourcelocator_LIBRARIES} + ${catkin_LIBRARIES} + ${jderobotcomm_LIBRARIES} ) diff --git a/src/tools/cameraview/cameraview.cfg b/src/tools/cameraview/cameraview.cfg index c998e04e1..3dbc09deb 100644 --- a/src/tools/cameraview/cameraview.cfg +++ b/src/tools/cameraview/cameraview.cfg @@ -1,2 +1,6 @@ -Cameraview.Camera.Proxy=cameraA:default -h 0.0.0.0 -p 9999 +# 0 -> Deactivate, 1 -> Ice , 2 -> ROS +Cameraview.Camera.Server=1 +Cameraview.Camera.Proxy=cameraA:tcp -h localhost -p 9999 Cameraview.Camera.Format=RGB8 +Cameraview.Camera.Topic=/camera/rgb/image_raw +Cameraview.Camera.Name=cameraA \ No newline at end of file diff --git a/src/tools/cameraview/cameraview.cpp b/src/tools/cameraview/cameraview.cpp index 241649c9c..cc681c6e1 100644 --- a/src/tools/cameraview/cameraview.cpp +++ b/src/tools/cameraview/cameraview.cpp @@ -22,58 +22,33 @@ #include #include -#include -#include #include #include "viewer.h" -#include "parallelIce/cameraClient.h" #include "easyiceconfig/EasyIce.h" +#include +#include int main(int argc, char** argv){ + int status; cameraview::Viewer viewer; Ice::CommunicatorPtr ic; - jderobot::cameraClient* camRGB; - - try{ - ic = EasyIce::initialize(argc,argv); - Ice::ObjectPrx base = ic->propertyToProxy("Cameraview.Camera.Proxy"); - Ice::PropertiesPtr prop = ic->getProperties(); - - if (0==base) - throw "Could not create proxy"; + JdeRobotComm::CameraClient* camRGB; + ic = EasyIce::initialize(argc,argv); - camRGB = new jderobot::cameraClient(ic,"Cameraview.Camera."); + camRGB = JdeRobotComm::getCameraClient(ic, "Cameraview.Camera"); - if (camRGB == NULL){ - throw "Invalid proxy"; - } - camRGB->start(); + JdeRobotTypes::Image rgb; - cv::Mat rgb; + while(viewer.isVisible()){ + //jderobot::ImageDataPtr data = camRGB->getImageData(format); - while(viewer.isVisible()){ - //jderobot::ImageDataPtr data = camRGB->getImageData(format); - - camRGB->getImage(rgb); - viewer.display(rgb); - viewer.displayFrameRate(camRGB->getRefreshRate()); - } - }catch (const Ice::Exception& ex) { - std::cerr << ex << std::endl; - status = 1; - } catch (const char* msg) { - std::cerr << msg << std::endl; - status = 1; + rgb = camRGB->getImage(); + viewer.display(rgb.data); + viewer.displayFrameRate(0); } - if (ic) - ic->destroy(); - - camRGB->stop_thread(); - delete(camRGB); - return status; } diff --git a/src/tools/cameraview/pioneer_left_cam.cfg b/src/tools/cameraview/pioneer_left_cam.cfg deleted file mode 100644 index e70db362f..000000000 --- a/src/tools/cameraview/pioneer_left_cam.cfg +++ /dev/null @@ -1 +0,0 @@ -Cameraview.Camera.Proxy=cam_sensor_left:tcp -h localhost -p 9995