Skip to content

Commit

Permalink
First attemps on Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoJT88 committed Jan 15, 2015
1 parent b8ea9ce commit 6b61fc5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 34 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ IF (BUILD_RT_VISUALIZATION)

INCLUDE_DIRECTORIES($ENV{OPENNI2_INCLUDE})
LINK_DIRECTORIES($ENV{OPENNI2_LIB})
#SET(OpenNI_lib "/usr/lib/libOpenNI2.so")
SET(OpenNI_lib "C:/Users/Mariano/Programas/OpenNI2_32/Lib/OpenNI2.lib")
SET(OpenNI_lib "/usr/lib/libOpenNI2.so")
#SET(OpenNI_lib "C:/Users/Mariano/Programas/OpenNI2_32/Lib/OpenNI2.lib")

#message( "jajaj y esto vale ${OPENNI2_INCLUDE}" )

ADD_EXECUTABLE(Scene-Flow-Visualization
main_scene_flow_visualization.cpp
Expand Down
8 changes: 5 additions & 3 deletions main_scene_flow_impair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "scene_flow_impair.h"

using namespace std;
Expand All @@ -47,13 +48,14 @@ int main(int num_arg, char *argv[])
printf(" --help: Shows this menu... \n\n");
printf(" --rows r: Number of rows at the finest level of the pyramid. \n");
printf("\t Options: r=15, r=30, r=60, r=120, r=240, r=480 (if VGA)\n");
std::getchar();
std::getwchar(); //Windows -> getchar();
return 1;
}
else
{
if ( string(argv[1]) == "--rows")
rows = stof(string(argv[2]));
//Windows -> rows = stof(string(argv[2]));
rows = strtof(argv[2], NULL);
}

//==============================================================================
Expand All @@ -73,7 +75,7 @@ int main(int num_arg, char *argv[])
sceneflow.solveSceneFlowGPU();
sceneflow.showAndSaveResults();
sceneflow.freeGPUMemory();
printf("\nPush any key over the scene flow image to finish");
printf("\nPush any key over the scene flow image to finish\n");
}

return 0;
Expand Down
7 changes: 4 additions & 3 deletions main_scene_flow_visualization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "scene_flow_visualization.h"


Expand Down Expand Up @@ -57,13 +58,13 @@ int main(int num_arg, char *argv[])
for (int i=1; i<num_arg; i++)
{
if ( string(argv[i]) == "--cam_mode")
cam_mode = stof(string(argv[i+1]));
cam_mode = strtof(argv[i+1], NULL);

if ( string(argv[i]) == "--fps")
fps = stof(string(argv[i+1]));
fps = strtof(argv[i+1], NULL);

if ( string(argv[i]) == "--rows")
rows = stof(string(argv[i+1]));
rows = strtof(argv[i+1], NULL);
}
}

Expand Down
30 changes: 15 additions & 15 deletions scene_flow_impair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PD_flow_opencv::PD_flow_opencv(unsigned int rows_config)
{
rows = rows_config; //Maximum size of the coarse-to-fine scheme
cols = rows*320/240;
ctf_levels = unsigned int(log2(rows/15)) + 1;
ctf_levels = static_cast<unsigned int>(log2(rows/15)) + 1;
fovh = M_PI*62.5f/180.f;
fovv = M_PI*45.f/180.f;
len_disp = 0.022f;
Expand Down Expand Up @@ -68,7 +68,7 @@ void PD_flow_opencv::createImagePyramidGPU()
//Cuda copy object to device
csf_device = ObjectToDevice(&csf_host);

unsigned int pyr_levels = unsigned int(log2(width/cols)) + ctf_levels;
unsigned int pyr_levels = static_cast<unsigned int>(log2(width/cols)) + ctf_levels;
GaussianPyramidBridge(csf_device, pyr_levels, cam_mode);

//Cuda copy object back to host
Expand All @@ -89,7 +89,7 @@ void PD_flow_opencv::solveSceneFlowGPU()
s = pow(2.f,int(ctf_levels-(i+1)));
cols_i = cols/s;
rows_i = rows/s;
level_image = ctf_levels - i + unsigned int(log2(width/cols)) - 1;
level_image = ctf_levels - i + static_cast<unsigned int>(log2(width/cols)) - 1;

//=========================================================================
// Cuda - Begin
Expand Down Expand Up @@ -274,30 +274,30 @@ void PD_flow_opencv::showAndSaveResults()
//Save scene flow as an RGB image (one colour per direction)
cv::Mat sf_image(rows, cols, CV_8UC3);

//Compute the max-min values of the flow
//Compute the max values of the flow (of its norm)
float maxmodx = 0.f, maxmody = 0.f, maxmodz = 0.f;
for (unsigned int v=0; v<rows; v++)
for (unsigned int u=0; u<cols; u++)
{
if (abs(dxp[v + u*rows]) > maxmodx)
maxmodx = abs(dxp[v + u*rows]);
if (abs(dyp[v + u*rows]) > maxmody)
maxmody = abs(dyp[v + u*rows]);
if (abs(dzp[v + u*rows]) > maxmodz)
maxmodz = abs(dzp[v + u*rows]);
if (fabs(dxp[v + u*rows]) > maxmodx)
maxmodx = fabs(dxp[v + u*rows]);
if (fabs(dyp[v + u*rows]) > maxmody)
maxmody = fabs(dyp[v + u*rows]);
if (fabs(dzp[v + u*rows]) > maxmodz)
maxmodz = fabs(dzp[v + u*rows]);
}

for (unsigned int v=0; v<rows; v++)
for (unsigned int u=0; u<cols; u++)
{
sf_image.at<cv::Vec3b>(v,u)[0] = 255.f*abs(dxp[v + u*rows])/maxmodx; //Blue
sf_image.at<cv::Vec3b>(v,u)[1] = 255.f*abs(dyp[v + u*rows])/maxmody; //Green
sf_image.at<cv::Vec3b>(v,u)[2] = 255.f*abs(dzp[v + u*rows])/maxmodz; //Red
sf_image.at<cv::Vec3b>(v,u)[0] = static_cast<unsigned char>(255.f*fabs(dxp[v + u*rows])/maxmodx); //Blue
sf_image.at<cv::Vec3b>(v,u)[1] = static_cast<unsigned char>(255.f*fabs(dyp[v + u*rows])/maxmody); //Green
sf_image.at<cv::Vec3b>(v,u)[2] = static_cast<unsigned char>(255.f*fabs(dzp[v + u*rows])/maxmodz); //Red
}

//Show the scene flow as an RGB image
cv::namedWindow("SceneFlow", cv::WINDOW_NORMAL);
cv::moveWindow("SceneFlow",10,10);
cv::moveWindow("SceneFlow",width - cols/2,height - rows/2);
cv::imshow("SceneFlow", sf_image);
cv::waitKey(100000);

Expand Down Expand Up @@ -334,4 +334,4 @@ void PD_flow_opencv::showAndSaveResults()
//sprintf(name, "pdflow_representation%02u.png", nFichero);
//printf("Saving the visual representation to file: %s \n", name);
//cv::imwrite(name, sf_image);
}
}
17 changes: 10 additions & 7 deletions scene_flow_impair.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@
** **
*****************************************************************************/

#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
//Windows -> #include <opencv2/core.hpp>
#include <opencv2/core/core.hpp>
//Windows -> #include <opencv2/highgui.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "pdflow_cudalib.h"
#include "legend_pdflow.xpm"
#include <ostream>

#define M_PI 3.14159265f
#define M_LOG2E 1.44269504088896340736f //log2(e)
//Windows -> #define M_PI 3.14159265f
//Windows -> #define M_LOG2E 1.44269504088896340736f //log2(e)

inline float log2(const float x){
return log(x) * M_LOG2E;
}
//Windows
//inline float log2(const float x){
// return log(x) * M_LOG2E;
//}


class PD_flow_opencv {
Expand Down
9 changes: 5 additions & 4 deletions scene_flow_visualization.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
#include <mrpt/system.h>
#include <mrpt/gui/CDisplayWindow3D.h>
#include <mrpt/opengl.h>
#include <OpenNI.h> //<openni2/OpenNI.h>
//Windows #include <OpenNI.h>
#include <openni2/OpenNI.h>
#include <Eigen/src/Core/Matrix.h>
#include "pdflow_cudalib.h"
#include "legend_pdflow.xpm"

//#define M_LOG2E 1.44269504088896340736f //log2(e)

inline float log2(const float x){
return log(x) * M_LOG2E;
}
//inline float log2(const float x){
// return log(x) * M_LOG2E;
//}


using namespace mrpt;
Expand Down

0 comments on commit 6b61fc5

Please sign in to comment.