Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows build, add exit from app menu #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ endif()

project(QtKittiVisualizer)




if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DBOOST_ALL_NO_LIB -DBOOST_ALL_DYN_LINK -DBOOST_LOG_DYN_LINK)
endif()

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

Expand All @@ -29,7 +36,7 @@ set(PROJECT_BINARY_NAME qt-kitti-visualizer)

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})

find_package(Boost 1.54 COMPONENTS program_options filesystem REQUIRED)
find_package(Boost 1.54 COMPONENTS program_options filesystem serialization REQUIRED)
set(Boost_COMPONENTS_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
set(Boost_COMPONENTS_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
set(Boost_COMPONENTS_LIBRARIES ${Boost_LIBRARIES})
Expand All @@ -45,6 +52,7 @@ add_definitions(${PCL_DEFINITIONS})
set(CPP_FILES
KittiConfig.cpp
KittiDataset.cpp
KittiImage.cpp
main.cpp
QtKittiVisualizer.cpp
)
Expand Down
27 changes: 24 additions & 3 deletions KittiConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ limitations under the License.
#include <boost/filesystem/path.hpp>
#include <boost/format.hpp>

std::string KittiConfig::data_directory = "../KittiData";
std::string KittiConfig::raw_data_directory = "raw";
//std::string KittiConfig::data_directory = "../KittiData";
std::string KittiConfig::data_directory = "D:\\KITTI\\2011_09_26";
std::string KittiConfig::raw_data_directory = "";
std::string KittiConfig::dataset_folder_template = "%|04|_sync";
std::string KittiConfig::point_cloud_directory = "velodyne_points/data";
std::string KittiConfig::point_cloud_directory = "velodyne_points\\data";
std::string KittiConfig::point_cloud_file_template = "%|010|.bin";
std::string KittiConfig::image_directory = "image_02\\data";
std::string KittiConfig::image_file_template = "%|010|.png";
std::string KittiConfig::tracklets_directory = ".";
std::string KittiConfig::tracklets_file_name = "tracklet_labels.xml";

Expand Down Expand Up @@ -61,6 +64,24 @@ boost::filesystem::path KittiConfig::getTrackletsPath(int dataset)
;
}

boost::filesystem::path KittiConfig::getImagePath(int dataset)
{

return boost::filesystem::path(data_directory)
/ raw_data_directory
/ (boost::format(dataset_folder_template) % dataset).str()
/ image_directory
;
}
boost::filesystem::path KittiConfig::getImagePath(int dataset, int frameId)
{

return getImagePath(dataset)
/ (boost::format(image_file_template) % frameId).str()
;
}


int KittiConfig::getDatasetNumber(int index)
{
if (index >= 0 && index < availableDatasets.size())
Expand Down
4 changes: 4 additions & 0 deletions KittiConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class KittiConfig
static boost::filesystem::path getPointCloudPath(int dataset);
static boost::filesystem::path getPointCloudPath(int dataset,int frameId);
static boost::filesystem::path getTrackletsPath(int dataset);
static boost::filesystem::path getImagePath(int dataset);
static boost::filesystem::path getImagePath(int dataset, int frameId);

/** Contains the numbers of data sets available from your data set folder */
static const std::vector<int> availableDatasets;
Expand All @@ -67,6 +69,8 @@ class KittiConfig
static std::string dataset_folder_template;
static std::string point_cloud_directory;
static std::string point_cloud_file_template;
static std::string image_directory;
static std::string image_file_template;
static std::string tracklets_directory;
static std::string tracklets_file_name;

Expand Down
5 changes: 5 additions & 0 deletions KittiDataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ KittiPointCloud::Ptr KittiDataset::getPointCloud(int frameId)
return cloud;
}

std::string KittiDataset::getImageFileName(int frameId)
{
return std::string(KittiConfig::getImagePath(_dataset, frameId).string());
}

KittiPointCloud::Ptr KittiDataset::getTrackletPointCloud(KittiPointCloud::Ptr& pointCloud, const KittiTracklet& tracklet, int frameId)
{
int pose_number = frameId - tracklet.first_frame;
Expand Down
1 change: 1 addition & 0 deletions KittiDataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class KittiDataset
KittiDataset(int dataset);
int getNumberOfFrames();
KittiPointCloud::Ptr getPointCloud(int frameId);
std::string getImageFileName(int frameId);
KittiPointCloud::Ptr getTrackletPointCloud(KittiPointCloud::Ptr& pointCloud, const KittiTracklet& tracklet, int frameId);
Tracklets& getTracklets();

Expand Down
125 changes: 121 additions & 4 deletions QtKittiVisualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,28 @@ limitations under the License.

typedef pcl::visualization::PointCloudColorHandlerCustom<KittiPoint> KittiPointCloudColorHandlerCustom;

KittiVisualizerQt::KittiVisualizerQt(QWidget *parent, int argc, char** argv) :

// enum for the camera angles
enum CameraView { front, eye_level, birds_eye, left_pers, right_pers, top };
static const QString CAMVIEWSTR[] = { "Front", "Eye Level", "Birds Eye", "Left Perspective", "Right Perspective", "Top" };



void usleep(unsigned int usec)
{
HANDLE timer;
LARGE_INTEGER ft;

ft.QuadPart = -(10 * (__int64)usec);

timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
}


KittiVisualizerQt::KittiVisualizerQt(QWidget* parent, int argc, char** argv) :
QMainWindow(parent),
ui(new Ui::KittiVisualizerQt),
dataset_index(0),
Expand All @@ -66,10 +87,17 @@ KittiVisualizerQt::KittiVisualizerQt(QWidget *parent, int argc, char** argv) :

// Set up user interface
ui->setupUi(this);
for (int i = CameraView::front; i <= CameraView::top; i++) {
ui->viewComboBox->addItem(CAMVIEWSTR[i]);
}

ui->toolBar->addWidget(ui->viewComboBox);
ui->qvtkWidget_pclViewer->SetRenderWindow(pclVisualizer->getRenderWindow());
pclVisualizer->initCameraParameters();
pclVisualizer->setupInteractor(ui->qvtkWidget_pclViewer->GetInteractor(), ui->qvtkWidget_pclViewer->GetRenderWindow());
pclVisualizer->setBackgroundColor(0, 0, 0);
pclVisualizer->addCoordinateSystem(1.0);

pclVisualizer->registerKeyboardCallback(&KittiVisualizerQt::keyboardEventOccurred, *this, 0);
this->setWindowTitle("Qt KITTI Visualizer");
ui->qvtkWidget_pclViewer->update();
Expand All @@ -79,6 +107,9 @@ KittiVisualizerQt::KittiVisualizerQt(QWidget *parent, int argc, char** argv) :
loadPointCloud();
if (pointCloudVisible)
showPointCloud();

loadImageFile();

loadAvailableTracklets();
if (trackletBoundingBoxesVisible)
showTrackletBoxes();
Expand Down Expand Up @@ -110,6 +141,11 @@ KittiVisualizerQt::KittiVisualizerQt(QWidget *parent, int argc, char** argv) :
connect(ui->checkBox_showTrackletBoundingBoxes, SIGNAL (toggled(bool)), this, SLOT (showTrackletBoundingBoxesToggled(bool)));
connect(ui->checkBox_showTrackletPointClouds, SIGNAL (toggled(bool)), this, SLOT (showTrackletPointCloudsToggled(bool)));
connect(ui->checkBox_showTrackletInCenter, SIGNAL (toggled(bool)), this, SLOT (showTrackletInCenterToggled(bool)));
connect(ui->actionExit, SIGNAL (triggered()), this, SLOT (exitApplication()));
connect(ui->viewComboBox, SIGNAL (activated(int)),this, SLOT (camViewChanged(int)));

ui->viewComboBox->setCurrentIndex(CameraView::birds_eye);
camViewChanged(CameraView::birds_eye);
}

KittiVisualizerQt::~KittiVisualizerQt()
Expand Down Expand Up @@ -151,11 +187,13 @@ int KittiVisualizerQt::parseCommandLineOptions(int argc, char** argv)
bool KittiVisualizerQt::loadNextFrame()
{
newFrameRequested(frame_index + 1);
return true;
}

bool KittiVisualizerQt::loadPreviousFrame()
{
newFrameRequested(frame_index - 1);
return true;
}

void KittiVisualizerQt::getTrackletColor(const KittiTracklet& tracklet, int &r, int& g, int& b)
Expand Down Expand Up @@ -208,6 +246,7 @@ void KittiVisualizerQt::newDatasetRequested(int value)
loadPointCloud();
if (pointCloudVisible)
showPointCloud();
loadImageFile();
loadAvailableTracklets();
if (trackletBoundingBoxesVisible)
showTrackletBoxes();
Expand All @@ -233,6 +272,7 @@ void KittiVisualizerQt::newDatasetRequested(int value)
updateFrameLabel();
updateTrackletLabel();
ui->qvtkWidget_pclViewer->update();
ui->imageWidget->update();
}

void KittiVisualizerQt::newFrameRequested(int value)
Expand Down Expand Up @@ -260,6 +300,7 @@ void KittiVisualizerQt::newFrameRequested(int value)
loadPointCloud();
if (pointCloudVisible)
showPointCloud();
loadImageFile();
loadAvailableTracklets();
if (trackletBoundingBoxesVisible)
showTrackletBoxes();
Expand Down Expand Up @@ -351,6 +392,13 @@ void KittiVisualizerQt::loadPointCloud()
pointCloud = dataset->getPointCloud(frame_index);
}

void KittiVisualizerQt::loadImageFile()
{
ui->imageWidget->setPixmapFile(dataset->getImageFileName(frame_index));
ui->imageWidget->repaint();
std::cout << "loaded:" << dataset->getImageFileName(frame_index) << std::endl;
}

void KittiVisualizerQt::showPointCloud()
{
KittiPointCloudColorHandlerCustom colorHandler(pointCloud, 255, 255, 255);
Expand Down Expand Up @@ -428,9 +476,9 @@ void KittiVisualizerQt::updateTrackletLabel()

void KittiVisualizerQt::showTrackletBoxes()
{
double boxHeight = 0.0d;
double boxWidth = 0.0d;
double boxLength = 0.0d;
double boxHeight = 0.0f;
double boxWidth = 0.0f;
double boxLength = 0.0f;
int pose_number = 0;

for (int i = 0; i < availableTracklets.size(); ++i)
Expand Down Expand Up @@ -569,3 +617,72 @@ void KittiVisualizerQt::keyboardEventOccurred (const pcl::visualization::Keyboar
}
}
}

void KittiVisualizerQt::exitApplication(void)
{
QCoreApplication::exit();
}

/** \brief Set the camera pose given by position, viewpoint and up vector
* \param[in] pos_x the x coordinate of the camera location
* \param[in] pos_y the y coordinate of the camera location
* \param[in] pos_z the z coordinate of the camera location
* \param[in] view_x the x component of the view point of the camera
* \param[in] view_y the y component of the view point of the camera
* \param[in] view_z the z component of the view point of the camera
* \param[in] up_x the x component of the view up direction of the camera
* \param[in] up_y the y component of the view up direction of the camera
* \param[in] up_z the y component of the view up direction of the camera
* \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
*/



void KittiVisualizerQt::camViewChanged(int index)
{
std::cout << "Selected View:" << index << std::endl;

switch (index) {
case CameraView::front:
pclVisualizer->setCameraPosition(-100, 0, 0,
-17, 9.5, -9.5,
0,0,1);
break;

case CameraView::eye_level:
pclVisualizer->setCameraPosition(-100, 0, 20,
-17, 9.5, -9.5,
0, 0, 1);
break;

case CameraView::birds_eye:
pclVisualizer->setCameraPosition(-100, 10, 30,
-17, 9.5, -9.5,
0, 0, 1);
break;


case CameraView::left_pers:
pclVisualizer->setCameraPosition(22, 150, 57,
1, -57, 8,
0, 0, 1);
break;



case CameraView::right_pers:
pclVisualizer->setCameraPosition(-22, -150, 57,
1, -57, 8,
0, 0, 1);
break;


case CameraView::top: /* facing down on y */
default:

pclVisualizer->setCameraPosition(1, 29, -110,
21, 6, 147, /* focal point */
0, -1, 0);
break;
}
}
4 changes: 3 additions & 1 deletion QtKittiVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public slots:
void showTrackletBoundingBoxesToggled(bool value);
void showTrackletPointCloudsToggled(bool value);
void showTrackletInCenterToggled(bool value);
void exitApplication(void);
void camViewChanged(int index);

private:

Expand All @@ -89,7 +91,7 @@ public slots:
void updateDatasetLabel();
void updateFrameLabel();
void updateTrackletLabel();

void loadImageFile();
void loadPointCloud();
void showPointCloud();
void hidePointCloud();
Expand Down
Loading