[Jderobot-admin] jderobot-r917 - in trunk: . src/libs src/libs/paralellIce
frivas en jderobot.org
frivas en jderobot.org
Lun Mayo 27 15:15:44 CEST 2013
Author: frivas
Date: 2013-05-27 15:14:44 +0200 (Mon, 27 May 2013)
New Revision: 917
Added:
trunk/src/libs/paralellIce/
trunk/src/libs/paralellIce/CMakeLists.txt
trunk/src/libs/paralellIce/cameraClient.cpp
trunk/src/libs/paralellIce/cameraClient.h
trunk/src/libs/paralellIce/pointcloudClient.cpp
trunk/src/libs/paralellIce/pointcloudClient.h
Modified:
trunk/CMakeLists.txt
Log:
a?\195?\177adida libreria para acceso paralalo a los interfaces ICE
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2013-05-13 00:35:04 UTC (rev 916)
+++ trunk/CMakeLists.txt 2013-05-27 13:14:44 UTC (rev 917)
@@ -8,7 +8,7 @@
SET( INTERFACES_CPP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/interfaces/cpp) # Directorio con las interfaces ICE en C++
SET( LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/libs) # Directorio donde se encuentran las librerias propias de jderobot
SET( SLICE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/interfaces/slice) # Directorio donde se encuentran las interfaces ICE
-SET( LIBS_NEEDED bgfgsegmentation jderobotice colorspaces jderobotutil progeo pioneer fuzzylib visionlib ) # Librerias de las que depende el componente
+SET( LIBS_NEEDED bgfgsegmentation jderobotice colorspaces jderobotutil progeo pioneer fuzzylib visionlib paralellIce ) # Librerias de las que depende el componente
SET( DEPS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Deps) # Directorio donde se encuentran las dependencias
SET( COMPONENTS calibrator calibratorKinect openniServer-kinect naooperator basic_component
Added: trunk/src/libs/paralellIce/CMakeLists.txt
===================================================================
--- trunk/src/libs/paralellIce/CMakeLists.txt (rev 0)
+++ trunk/src/libs/paralellIce/CMakeLists.txt 2013-05-27 13:14:44 UTC (rev 917)
@@ -0,0 +1,24 @@
+include_directories(
+ ${INTERFACES_CPP_DIR}
+ ${LIBS_DIR}/
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/cameras
+)
+
+add_library (paralellIce STATIC cameraClient.cpp cameraClient.h pointcloudClient.cpp pointcloudClient.h)
+TARGET_LINK_LIBRARIES(paralellIce
+ ${OpenCV_LIBRARIES}
+ ${LIBS_DIR}/colorspaces/libcolorspacesmm.so
+ ${ZeroCIce_LIBRARIES}
+)
+
+add_library (paralellIceshare SHARED cameraClient.cpp cameraClient.h pointcloudClient.cpp pointcloudClient.h)
+TARGET_LINK_LIBRARIES(paralellIceshare
+ ${OpenCV_LIBRARIES}
+ ${LIBS_DIR}/colorspaces/libcolorspacesmm.so
+ ${ZeroCIce_LIBRARIES}
+)
+
+
+set_target_properties(paralellIceshare PROPERTIES OUTPUT_NAME paralellIce)
+
Added: trunk/src/libs/paralellIce/cameraClient.cpp
===================================================================
--- trunk/src/libs/paralellIce/cameraClient.cpp (rev 0)
+++ trunk/src/libs/paralellIce/cameraClient.cpp 2013-05-27 13:14:44 UTC (rev 917)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 1997-2013 JDE Developers TeamkinectViewer.camRGB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+#include "cameraClient.h"
+
+
+namespace jderobot {
+
+cameraClient::cameraClient(Ice::CommunicatorPtr ic, std::string prefix) {
+ // TODO Auto-generated constructor stubcameraClient* client = new cameraClient;
+ Ice::PropertiesPtr prop;
+ prop = ic->getProperties();
+ Ice::ObjectPrx baseCamera;
+
+
+ int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10);
+ this->cycle=(float)(1/(float)fps)*1000000;
+ try{
+ baseCamera = ic->propertyToProxy(prefix+"Proxy");
+ if (0==baseCamera){
+ throw "kinectViewer: Could not create proxy with Camera";
+ }
+ else {
+ this->prx= jderobot::CameraPrx::checkedCast(baseCamera);
+ if (0==this->prx)
+ throw "Invalid " + prefix + ".Proxy";
+ }
+ }catch (const Ice::Exception& ex) {
+ std::cerr << ex << std::endl;
+ }
+ catch (const char* msg) {
+ std::cerr << msg << std::endl;
+ std::cout << "kinectViewer: Not camera provided" << std::endl;
+ }
+}
+
+cameraClient::~cameraClient() {
+ // TODO Auto-generated destructor stub
+}
+
+void
+cameraClient::run(){
+ jderobot::ImageDataPtr dataPtr;
+ colorspaces::Image::FormatPtr fmt;
+ struct timeval post;
+ long long int totalpre=0;
+ long long int totalpost=0;
+ while (this->isAlive()){
+ gettimeofday(&post,NULL);
+ totalpost=post.tv_sec*1000000+post.tv_usec;
+
+ dataPtr = this->prx->getImageData();
+ fmt = colorspaces::Image::Format::searchFormat(dataPtr->description->format);
+ if (!fmt)
+ throw "Format not supported";
+ colorspaces::Image imageRGB(dataPtr->description->width,dataPtr->description->height,fmt,&(dataPtr->pixelData[0]));
+ colorspaces::ImageRGB8 img_rgb888(imageRGB);//conversion will happen if needed
+ cv::Mat localDataPtr = cv::Mat(cvSize(img_rgb888.width,img_rgb888.height), CV_8UC3, img_rgb888.data);
+ cv::Mat localData;
+ localDataPtr.copyTo(localData);
+ this->controlMutex.lock();
+ this->data.release();
+ localData.copyTo(this->data);
+ this->controlMutex.unlock();
+
+ if (totalpre !=0){
+ if ((totalpost - totalpre) > this->cycle ){
+ std::cout<<"-------- kinectViewer: camera adquisition timeout-" << std::endl;
+ }
+ else{
+ usleep(this->cycle - (totalpost - totalpre));
+ }
+ }
+ totalpre=totalpost;
+ }
+}
+
+cv::Mat cameraClient::getImage(){
+ cv::Mat local;
+ this->controlMutex.lock();
+ this->data.copyTo(local);
+ this->controlMutex.unlock();
+ return local;
+
+}
+
+} /* namespace jderobot */
Added: trunk/src/libs/paralellIce/cameraClient.h
===================================================================
--- trunk/src/libs/paralellIce/cameraClient.h (rev 0)
+++ trunk/src/libs/paralellIce/cameraClient.h 2013-05-27 13:14:44 UTC (rev 917)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 1997-2013 JDE Developers TeamkinectViewer.camRGB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+#ifndef CAMERACLIENT_H_
+#define CAMERACLIENT_H_
+
+#include <IceUtil/IceUtil.h>
+#include <iostream>
+#include <Ice/Ice.h>
+#include <colorspaces/colorspacesmm.h>
+#include <jderobot/camera.h>
+#include <cv.h>
+#include <sstream>
+#include <fstream>
+
+
+namespace jderobot {
+
+class cameraClient: public IceUtil::Thread {
+public:
+ cameraClient(Ice::CommunicatorPtr ic, std::string prefix);
+ virtual ~cameraClient();
+ virtual void run();
+
+ //callbacks
+ cv::Mat getImage();
+private:
+ cv::Mat data;
+ jderobot::CameraPrx prx;
+ long long int cycle;
+ //int type; //0 color 1 depth
+ IceUtil::Mutex controlMutex;
+
+};
+
+} /* namespace jderobot */
+#endif /* CAMERACLIENT_H_ */
Added: trunk/src/libs/paralellIce/pointcloudClient.cpp
===================================================================
--- trunk/src/libs/paralellIce/pointcloudClient.cpp (rev 0)
+++ trunk/src/libs/paralellIce/pointcloudClient.cpp 2013-05-27 13:14:44 UTC (rev 917)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 1997-2013 JDE Developers TeamkinectViewer.camRGB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+#include "pointcloudClient.h"
+
+namespace jderobot {
+
+pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix) {
+ // TODO Auto-generated constructor stub
+
+ Ice::PropertiesPtr prop;
+ prop = ic->getProperties();
+
+ int fps=prop->getPropertyAsIntWithDefault("kinectViewer.pointCloud.Fps",10);
+ this->cycle=(float)(1/(float)fps)*1000000;
+ try{
+ Ice::ObjectPrx basePointCloud = ic->propertyToProxy("kinectViewer.pointCloud.Proxy");
+ if (0==basePointCloud){
+ throw "kinectViewer: Could not create proxy with Camera";
+ }
+ else {
+ this->prx = jderobot::pointCloudPrx::checkedCast(basePointCloud);
+ if (0==this->prx)
+ throw "Invalid proxy kinectViewer.pointCloud.Proxy";
+
+ }
+ }catch (const Ice::Exception& ex) {
+ std::cerr << ex << std::endl;
+ }
+ catch (const char* msg) {
+ std::cerr << msg << std::endl;
+ std::cout << "kinectViewer: Not camera provided" << std::endl;
+ }
+
+}
+
+pointcloudClient::~pointcloudClient() {
+ // TODO Auto-generated destructor stub
+}
+
+void pointcloudClient::run(){
+
+ struct timeval post;
+ long long int totalpre=0;
+ long long int totalpost=0;
+ while (1){
+ gettimeofday(&post,NULL);
+ totalpost=post.tv_sec*1000000+post.tv_usec;
+
+ jderobot::pointCloudDataPtr localCloud=this->prx->getCloudData();
+
+ this->controlMutex.lock();
+ this->data.resize(localCloud->p.size());
+ std::copy( localCloud->p.begin(), localCloud->p.end(), this->data.begin() );
+
+ this->controlMutex.unlock();
+ if (totalpre !=0){
+ if ((totalpost - totalpre) > this->cycle ){
+ std::cout<<"-------- kinectViewer: pointCloud adquisition timeout-" << std::endl;
+ }
+ else{
+ usleep(this->cycle - (totalpost - totalpre));
+ }
+ }
+ totalpre=totalpost;
+ }
+}
+
+std::vector<jderobot::RGBPoint> pointcloudClient::getData(){
+ std::vector<jderobot::RGBPoint> cloud;
+ this->controlMutex.lock();
+ cloud.resize(this->data.size());
+ std::copy( this->data.begin(), this->data.end(), cloud.begin() );
+ this->controlMutex.unlock();
+ return cloud;
+}
+
+} /* namespace jderobot */
Added: trunk/src/libs/paralellIce/pointcloudClient.h
===================================================================
--- trunk/src/libs/paralellIce/pointcloudClient.h (rev 0)
+++ trunk/src/libs/paralellIce/pointcloudClient.h 2013-05-27 13:14:44 UTC (rev 917)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 1997-2013 JDE Developers TeamkinectViewer.camRGB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * Author : Jose María Cañas <jmplaza en gsyc.es>
+ Francisco Miguel Rivas Montero <franciscomiguel.rivas en urjc.es>
+
+ */
+
+
+#ifndef POINTCLOUDCLIENT_H_
+#define POINTCLOUDCLIENT_H_
+
+#include <IceUtil/IceUtil.h>
+#include <iostream>
+#include <Ice/Ice.h>
+#include <jderobot/pointcloud.h>
+#include <cv.h>
+#include <sstream>
+#include <fstream>
+
+namespace jderobot {
+
+class pointcloudClient: public IceUtil::Thread {
+public:
+ pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix);
+ virtual ~pointcloudClient();
+ virtual void run();
+
+ std::vector<jderobot::RGBPoint> getData();
+
+
+private:
+ std::vector<jderobot::RGBPoint> data;
+ jderobot::pointCloudPrx prx;
+ long long int cycle;
+ IceUtil::Mutex controlMutex;
+
+};
+
+} /* namespace jderobot */
+#endif /* POINTCLOUDCLIENT_H_ */
More information about the Jderobot-admin
mailing list