[Jderobot-admin] jderobot-r1169 - in trunk: Deps/nite2 src/stable/components/openni1Server src/stable/components/openniServer
frivas en jderobot.org
frivas en jderobot.org
Mie Feb 19 17:11:56 CET 2014
Author: frivas
Date: 2014-02-19 17:11:56 +0100 (Wed, 19 Feb 2014)
New Revision: 1169
Modified:
trunk/Deps/nite2/CMakeLists.txt
trunk/src/stable/components/openni1Server/CMakeLists.txt
trunk/src/stable/components/openni1Server/openni1Server.cpp
trunk/src/stable/components/openniServer/CMakeLists.txt
Log:
#175 Openni1Server now can be used only with nite (with preprocesor directives)
Modified: trunk/Deps/nite2/CMakeLists.txt
===================================================================
--- trunk/Deps/nite2/CMakeLists.txt 2014-02-18 15:08:06 UTC (rev 1168)
+++ trunk/Deps/nite2/CMakeLists.txt 2014-02-19 16:11:56 UTC (rev 1169)
@@ -4,9 +4,6 @@
if (NITE2_INC AND NITE2_LIB)
message(STATUS "NITE found at ${NITE2_LIB}")
- set_property(
- SOURCE openniServer.cpp
- PROPERTY COMPILE_DEFINITIONS WITH_NITE2=1
include_directories(${NITE2_INC})
link_directories(${NITE2_LIB}/libNiTE2.so)
if (NOT IS_DIRECTORY ./NiTE2)
@@ -14,8 +11,6 @@
file (COPY ${NITE2_LIB}/libNiTE2.so DESTINATION .)
file (COPY ${NITE2_LIB}/NiTE2 DESTINATION .)
endif()
-
- )
else()
message("NITE2 library not found")
endif()
Modified: trunk/src/stable/components/openni1Server/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/openni1Server/CMakeLists.txt 2014-02-18 15:08:06 UTC (rev 1168)
+++ trunk/src/stable/components/openni1Server/CMakeLists.txt 2014-02-19 16:11:56 UTC (rev 1169)
@@ -1,5 +1,5 @@
IF(openni_LIBRARIES)
- IF(nite_LIBRARIES)
+
SET( SOURCE_FILES openni1Server.cpp myprogeo.cpp )
add_definitions(-DGLADE_DIR="${gladedir}")
@@ -10,26 +10,48 @@
${LIBS_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cameras
- ${nite_INCLUDE_DIR}
- ${ni_INCLUDE_DIR}
+ ${openni_INCLUDE_DIR}
${LIBUSB_INCLUDE_DIRS}
)
add_executable (openni1Server ${SOURCE_FILES})
- TARGET_LINK_LIBRARIES(openni1Server
- progeo
- colorspacesmm
- JderobotInterfaces
- ${ZeroCIce_LIBRARIES}
- ${openni_LIBRARIES}
- ${nite_LIBRARIES}
- ${opencv_LIBRARIES}
- ${gsl_LIBRARIES}
- ${Boost_LIBRARIES}
- ${LIBUSB_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- ${LIBUSB_LIBRARY_DIRS}
- )
- ENDIF()
+
+
+ IF( nite_LIBRARIES)
+
+ set_property(
+ SOURCE openni1Server.cpp
+ PROPERTY COMPILE_DEFINITIONS WITH_NITE=1
+ )
+ include_directories(
+ ${nite_INCLUDE_DIR}
+ )
+
+ TARGET_LINK_LIBRARIES(openni1Server
+ ${OpenCV_LIBRARIES}
+ ${OpenCVGUI_LIBRARIES}
+ ${gsl_LIBRARIES}
+ ${ZeroCIce_LIBRARIES}
+ ${openni_LIBRARIES}
+ ${nite_LIBRARIES}
+ colorspacesmm
+ JderobotInterfaces
+ jderobotutil
+ progeo
+ )
+ ELSE()
+ TARGET_LINK_LIBRARIES(openni1Server
+ ${OpenCV_LIBRARIES}
+ ${OpenCVGUI_LIBRARIES}
+ ${gsl_LIBRARIES}
+ ${ZeroCIce_LIBRARIES}
+ ${openni_LIBRARIES}
+ colorspacesmm
+ colorspacesmm
+ JderobotInterfaces
+ jderobotutil
+ progeo
+ )
+ ENDIF()
ENDIF()
Modified: trunk/src/stable/components/openni1Server/openni1Server.cpp
===================================================================
--- trunk/src/stable/components/openni1Server/openni1Server.cpp 2014-02-18 15:08:06 UTC (rev 1168)
+++ trunk/src/stable/components/openni1Server/openni1Server.cpp 2014-02-19 16:11:56 UTC (rev 1169)
@@ -44,7 +44,6 @@
#include <XnPropNames.h>
#include <XnUSB.h>
#include <XnLog.h>
-#include <XnVCircleDetector.h>
#include <XnFPSCalculator.h>
#include <boost/thread/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -53,7 +52,11 @@
#include <iostream>
#include <fstream>
+#ifdef WITH_NITE
+ #include <XnVCircleDetector.h>
+#endif
+
#define VID_MICROSOFT 0x45e
#define PID_NUI_MOTOR 0x02b0
#define NUM_THREADS 5
@@ -80,7 +83,8 @@
/*OJO solo funciona con imágenes de 640x480, no con imágenes redimensionadas, si valdría con tamaños fijados con configuración openni, pero no hemos conseguido que funcione variar la resolución por configuración*/
std::vector<int> pixelsID;
//int pixelsID[640*480];
-int userGeneratorActive=1;
+int userGeneratorActive=0;
+int localDebug;
struct KinectDevice
@@ -150,9 +154,11 @@
{
sensor.depth.GetMetaData(sensor.depthMD);
}
+ #ifdef WITH_NITE
if(sensor.g_UserGenerator.IsValid()){
sensor.g_UserGenerator.GetUserPixels(0,sensor.sceneMD);
}
+ #endif
if (sensor.image.IsValid())
{
sensor.image.GetMetaData(sensor.imageMD);
@@ -409,14 +415,14 @@
std::cout << "Should be made anything to stop camera streaming: " + cameraDescription->name << std::endl;
}
- virtual void reset(const Ice::Current&)
- {
- }
-
virtual Ice::Int setCameraDescription(const jderobot::CameraDescriptionPtr&, const Ice::Current&){
return 0;
}
+ virtual void reset(const Ice::Current&){
+
+ }
+
private:
class ReplyTask: public IceUtil::Thread{
public:
@@ -458,9 +464,10 @@
long totalpre=0;
long diff;
- std::cout << "FPS: " << fps << std::endl;
+ std::cout << "RGB FPS: " << fps << std::endl;
cycle=(float)(1/(float)fps)*1000000;
+
while(!(_done)){
gettimeofday(&a,NULL);
@@ -470,10 +477,14 @@
reply->timeStamp.seconds = (long)t.toSeconds();
reply->timeStamp.useconds = (long)t.toMicroSeconds() - reply->timeStamp.seconds*1000000;
const XnRGB24Pixel* pImageRow = sensors[SELCAM].imageMD.RGB24Data();
- const XnLabel* pLabels = sensors[SELCAM].sceneMD.Data();
+ const XnLabel* pLabels;
+ #ifdef WITH_NITE
+ pLabels= sensors[SELCAM].sceneMD.Data();
+ #endif
XnRGB24Pixel* pTexRow = g_pTexMap;
-
+ /*std::cout << "antes" << std::endl;
+ std::cout << "seg: " << segmentation << std::endl;*/
for (XnUInt y = 0; y < sensors[SELCAM].imageMD.YRes(); ++y)
{
@@ -482,7 +493,7 @@
for (XnUInt x = 0; x < sensors[SELCAM].imageMD.XRes(); ++x, ++pImage, ++pTex)
{
- //std::cout << segmentation << std::endl;
+
if (segmentation){
pixelsID[(y*sensors[SELCAM].imageMD.XRes() + x)]= *pLabels;
if (*pLabels!=0)
@@ -518,7 +529,7 @@
}
//test
- CalculateJoints();
+ //CalculateJoints();
//cvFlip(srcRGB, NULL, 1);
@@ -542,7 +553,8 @@
pthread_mutex_unlock(&mutex);
if (totalpre !=0){
if ((totala - totalpre) > cycle ){
- std::cout<<"-------- openni1Server: WARNING- RGB timeout-" << std::endl;
+ if (localDebug)
+ std::cout<<"-------- openni1Server: WARNING- RGB timeout-" << std::endl;
}
else{
usleep(cycle - (totala - totalpre));
@@ -654,14 +666,14 @@
std::cout << "Should be made anything to stop camera streaming: " + cameraDescription->name << std::endl;
}
- virtual void reset(const Ice::Current&)
- {
- }
-
virtual Ice::Int setCameraDescription(const jderobot::CameraDescriptionPtr&, const Ice::Current&){
return 0;
}
+ virtual void reset(const Ice::Current&){
+
+ }
+
private:
class ReplyTask: public IceUtil::Thread{
public:
@@ -723,7 +735,7 @@
{
test= *pDepth;
- if ((*pLabels!=0)||(!segmentation)){
+ if ((!segmentation)||(*pLabels!=0)){
distances[(y*sensors[SELCAM].depthMD.XRes() + x)] = *pDepth;
if (*pDepth != 0)
{
@@ -741,7 +753,9 @@
else{
distances[(y*sensors[SELCAM].depthMD.XRes() + x)] = 0;
}
+ #ifdef WITH_NITE
++pLabels;
+ #endif
}
pDepthRow += sensors[SELCAM].depthMD.XRes();
@@ -767,7 +781,8 @@
pthread_mutex_unlock(&mutex);
if (totalpre !=0){
if ((totala - totalpre) > cycle ){
- std::cout<<"-------- openni1Server: WARNING- DEPTH timeout-" << std::endl;
+ if (localDebug)
+ std::cout<<"-------- openni1Server: WARNING- DEPTH timeout-" << std::endl;
}
else{
usleep(cycle - (totala - totalpre));
@@ -970,7 +985,8 @@
pthread_mutex_unlock(&mutex);
if (totalpre !=0){
if ((totala - totalpre) > cycle ){
- std::cout<<"-------- openni1Server: WARNING- POINTCLOUD timeout-" << std::endl;
+ if (localDebug)
+ std::cout<<"-------- openni1Server: WARNING- POINTCLOUD timeout-" << std::endl;
}
else{
usleep(cycle - (totala - totalpre));
@@ -1246,10 +1262,15 @@
int pointCloud = prop->getPropertyAsIntWithDefault(componentPrefix + ".pointCloudActive",0);
int playerdetection = prop->getPropertyAsIntWithDefault(componentPrefix + ".PlayerDetection",0);
width=prop->getPropertyAsIntWithDefault("openni1Server.Width", 640);
+ localDebug=prop->getPropertyAsIntWithDefault("openni1Server.Debug", 0);
height=prop->getPropertyAsIntWithDefault("openni1Server.Height",480);
int fps=prop->getPropertyAsIntWithDefault("openni1Server.Fps",30);
+#ifndef WITH_NITE
+ playerdetection=0;
+#endif
+
SELCAM = prop->getPropertyAsIntWithDefault(componentPrefix + ".deviceId",0);
std::cout << "Selected device: " << SELCAM << std::endl;
int nCameras=0;
@@ -1413,8 +1434,8 @@
rc = g_context.CreateAnyProductionTree(XN_NODE_TYPE_DEPTH, &query, sensors[i].depth);
// depth configuration:
- /*XnUInt32 xNuma = sensors[i].depth.GetSupportedMapOutputModesCount();
- cout << "Support mode: " << xNuma << endl;
+ XnUInt32 xNuma = sensors[i].depth.GetSupportedMapOutputModesCount();
+ std::cout << "Support mode: " << xNuma << std::endl;
XnMapOutputMode* aModeD = new XnMapOutputMode[xNuma];
@@ -1423,7 +1444,7 @@
{
std::cout << aModeD[j].nXRes << " * " << aModeD[j].nYRes << " @" << aModeD[j].nFPS << "FPS" << std::endl;
}
- delete[] aModeD;*/
+ delete[] aModeD;
@@ -1432,35 +1453,41 @@
depth_mode.nXRes = width;
depth_mode.nYRes = height;
depth_mode.nFPS = 30;
- sensors[i].depth.SetMapOutputMode(depth_mode);
+
CHECK_RC(rc, "Create Depth");
// now create a image generator over this device
rc = g_context.CreateAnyProductionTree(XN_NODE_TYPE_IMAGE, &query, sensors[i].image);
CHECK_RC(rc, "Create Image");
- /*XnUInt32 xNumb = sensors[i].image.GetSupportedMapOutputModesCount();
- cout << "Support mode: " << xNumb << endl;
+ XnUInt32 xNumb = sensors[i].image.GetSupportedMapOutputModesCount();
+ std::cout << "Support mode: " << xNumb << std::endl;
XnMapOutputMode* aModeR = new XnMapOutputMode[xNumb];
sensors[i].image.GetSupportedMapOutputModes( aModeR, xNumb );
for( unsigned int j = 0; j < xNumb; j++ )
{
std::cout << aModeR[j].nXRes << " * " << aModeR[j].nYRes << " @" << aModeR[j].nFPS << "FPS" << std::endl;
}
- delete[] aModeD;*/
+ delete[] aModeD;
+ sensors[i].depth.SetMapOutputMode(aModeR[4]);
+
+ #ifdef WITH_NITE
rc = g_context.CreateAnyProductionTree(XN_NODE_TYPE_USER, &query, sensors[i].g_UserGenerator);
CHECK_RC(rc, "Find user generator");
+ #endif
XnMapOutputMode rgb_mode;
rgb_mode.nXRes = width;
rgb_mode.nYRes = height;
rgb_mode.nFPS = fps;
- sensors[i].image.SetMapOutputMode(rgb_mode);
+ sensors[i].image.SetMapOutputMode(aModeD[4]);
+
sensors[i].depth.GetAlternativeViewPointCap().SetViewPoint(sensors[i].image);
- XnCallbackHandle hUserCallbacks, hCalibrationStart, hCalibrationComplete, hPoseDetected, hCalibrationInProgress, hPoseInProgress;
if (playerdetection){
+ XnCallbackHandle hUserCallbacks, hCalibrationStart, hCalibrationComplete, hPoseDetected, hCalibrationInProgress, hPoseInProgress;
+
/*init player id array*/
pixelsID.resize(width*height);
if (!sensors[i].g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON))
Modified: trunk/src/stable/components/openniServer/CMakeLists.txt
===================================================================
--- trunk/src/stable/components/openniServer/CMakeLists.txt 2014-02-18 15:08:06 UTC (rev 1168)
+++ trunk/src/stable/components/openniServer/CMakeLists.txt 2014-02-19 16:11:56 UTC (rev 1169)
@@ -17,7 +17,7 @@
${LIBS_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cameras
- ${NITE2_INC}
+ ${NITE2_INC}
)
More information about the Jderobot-admin
mailing list