├── CMakeLists.txt
├── Readme.md
├── View.cpp
├── View.h
├── binFile
├── 47.bin
└── 8.bin
├── img
├── example1.png
└── example2.png
├── main.cpp
├── object.cpp
├── object.h
├── simpleViewer.cpp
├── simpleViewer.h
├── utils.cpp
└── utils.h
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(simpleViewer)
3 | add_definitions(-Wall)
4 |
5 | set(CMAKE_CXX_STANDARD 11)
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 | set(CMAKE_CXX_EXTENSIONS OFF)
8 |
9 | # if has no defined build set it to Release
10 | if(NOT CMAKE_BUILD_TYPE)
11 | set(CMAKE_BUILD_TYPE Release)
12 | endif()
13 |
14 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -fPIC")
15 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
16 | set(CMAKE_CXX_FLAGS_RELEASE "-O3")
17 |
18 | set(CMAKE_MODULE_PATH
19 | ${CMAKE_MODULE_PATH}
20 | "${PROJECT_SOURCE_DIR}/cmake_modules"
21 | )
22 |
23 | # Qt5
24 | set(Qt5_DIR "/opt/Qt5.6.0/5.6/gcc_64/lib/cmake/Qt5")
25 | set(Qt5_Widgets "/opt/Qt5.6.0/5.6/gcc_64/lib/cmake/Qt5Widgets")
26 | find_package(Qt5 COMPONENTS Core Widgets Gui Xml OpenGL REQUIRED)
27 | include_directories(${Qt5Core_INCLUDE_DIRS}
28 | ${Qt5Xml_INCLUDE_DIRS}
29 | ${Qt5Gui_INCLUDE_DIRS}
30 | ${Qt5Widgets_INCLUDE_DIRS}
31 | ${Qt5OpenGL_INCLUDE_DIRS})
32 |
33 | set(MY_QT_LIBRARIES
34 | ${Qt5Widgets_LIBRARIES}
35 | ${Qt5Core_LIBRARIES}
36 | ${Qt5Gui_LIBRARIES}
37 | ${Qt5Xml_LIBRARIES}
38 | ${Qt5OpenGL_LIBRARIES}
39 | ${Boost_LIBRARIES}
40 | /usr/lib/x86_64-linux-gnu/libtiff.so.5
41 | )
42 |
43 | # for opengl
44 | find_package(OpenGL REQUIRED)
45 | include_directories(${OPENGL_INCLUDE})
46 |
47 | find_package(QGLViewer REQUIRED)
48 | message(STATUS "Linking against Qt libs: ${MY_QT_LIBRARIES}")
49 | message(STATUS "Linking against QGlViewer lib: ${QGLVIEWER_LIBRARY}")
50 |
51 | ## include
52 | include_directories($CMAKE_CURRENT_SOURCE_DIR)
53 | add_executable(${PROJECT_NAME} main.cpp View.cpp simpleViewer.cpp utils.cpp)
54 | target_link_libraries(
55 | ${PROJECT_NAME}
56 | ${QGLVIEWER_LIBRARY}
57 | ${MY_QT_LIBRARIES}
58 | ${OPENGL_gl_LIBRARY}
59 | ${OPENGL_glu_LIBRARY})
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | ## Semantic-aware 3D-voxel CenterNet for point cloud object detection
2 | ## All code will be released upon publication of the paper.
3 | ### More detailed results of our SA-voxel-centernet are on the [sa-voxel-centernet](http://www.cvlibs.net/datasets/kitti/eval_object_detail.php?&result=6832bef733b8ae207539e5dbb9d186f572ab8959)
4 |
5 | * src file can get offset as this
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/View.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by sj on 2020/5/30.
3 | //
4 |
5 | #include "View.h"
6 |
7 | View::View()
8 | {
9 | // rows_ = 512U;
10 | // cols_ = 512U;
11 | rows_ = 256U;
12 | cols_ = 256U;
13 | resolution_ = rows_ / 80.0F;
14 | range_x_max_ = 80.0f;
15 | range_x_min_ = 0.0f;
16 | range_y_min_ = -40.0f;
17 | range_y_max_ = 40.0f;
18 | voxelPointNum_ = imgInt(rows_, std::vector(cols_, 0));
19 | voxelProb_ = imgFloat(rows_, std::vector(cols_, 0.0f));
20 | voxelOffset_ = imgCenter(rows_, std::vector
21 | (cols_, utils::point2d(0.0f, 0.0f)));
22 | voxelCenter_ = imgCenter(rows_, std::vector
23 | (cols_, utils::point2d(0.0f, 0.0f)));
24 | }
25 |
26 | void View::Build(const std::vector& input) {
27 | for(size_t dataIdx = 0; dataIdx < input.size(); ++dataIdx)
28 | {
29 | const utils::data& da = input[dataIdx];
30 | int row;
31 | int col;
32 | Project(da, row, col);
33 | size_t debug = 1U;
34 | ++voxelPointNum_[row][col];
35 | if (voxelProb_[row][col] < da.cls) {
36 | voxelProb_[row][col] = da.cls;
37 | voxelOffset_[row][col] = utils::point2d((da.x - da.reg[0]), (da.y - da.reg[1]));
38 | }
39 | }
40 | for (int row = 0; row < rows_; ++row) {
41 | for (int col = 0; col < cols_; ++col)
42 | {
43 | voxelCenter_[row][col] = utils::point2d((range_x_max_ - static_cast(row) / resolution_ - 0.5f / resolution_),
44 | (range_y_max_ - static_cast(col) / resolution_ - 0.5f / resolution_));
45 | }
46 | }
47 | std::cout << "View::build finished..." << std::endl;
48 | }
49 |
50 | void View::Project(const utils::data& da, int& row, int& col)
51 | {
52 | row = floor((-da.x + range_x_max_) * resolution_);
53 | col = floor((-da.y + range_y_max_) * resolution_);
54 | }
55 |
56 | void View::Project(const utils::point2d& input, int& row, int& col)
57 | {
58 | printf("input ==> [%f, %f]\n", input.x, input.y);
59 | row = floor((-input.x + range_x_max_) * resolution_);
60 | col = floor((-input.y + range_y_max_) * resolution_);
61 | row = std::min(row, int(rows_ - 1));
62 | col = std::min(col, int(cols_ - 1));
63 | printf("input ==> [%d, %d]\n", row, col);
64 | }
--------------------------------------------------------------------------------
/View.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by sj on 2020/5/30.
3 | //
4 |
5 | #ifndef SIMPLEVIEWER_VIEW_H
6 | #define SIMPLEVIEWER_VIEW_H
7 |
8 | #include
9 | #include
10 | #include "utils.h"
11 | #include
12 | #include "object.h"
13 |
14 | typedef std::vector> imgFloat;
15 | typedef std::vector> imgInt;
16 | typedef std::vector> imgCenter;
17 |
18 | class View {
19 | public:
20 | View();
21 | View(const std::vector& input);
22 | void Build(const std::vector& input);
23 | void Project(const utils::data& da, int& row, int& col);
24 | void Project(const utils::point2d& input, int& row, int& col);
25 | int Count(const int& row, const int& col) {return voxelPointNum_[row][col];}
26 | int GetProb(const int& row, const int& col) {return voxelProb_[row][col];}
27 | utils::point2d GetCenter(const int& row, const int& col){return voxelCenter_[row][col];};
28 | utils::point2d GetOffset(const int& row, const int& col){return voxelOffset_[row][col];};
29 |
30 | const size_t rows() const {return rows_;};
31 | const size_t cols() const {return cols_;};
32 |
33 | private:
34 | size_t rows_;
35 | size_t cols_;
36 | float range_x_max_;
37 | float range_x_min_;
38 | float range_y_max_;
39 | float range_y_min_;
40 | float resolution_;
41 | imgInt voxelPointNum_;
42 | imgFloat voxelProb_;
43 | imgCenter voxelOffset_;
44 | imgCenter voxelCenter_;
45 | imgFloat voxel;
46 |
47 | };
48 |
49 |
50 | #endif //SIMPLEVIEWER_VIEW_H
51 |
--------------------------------------------------------------------------------
/binFile/47.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunjingnjupt/sa-voxel-centernet/75743f9358e56581be82f659f17854c63f64333e/binFile/47.bin
--------------------------------------------------------------------------------
/binFile/8.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunjingnjupt/sa-voxel-centernet/75743f9358e56581be82f659f17854c63f64333e/binFile/8.bin
--------------------------------------------------------------------------------
/img/example1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunjingnjupt/sa-voxel-centernet/75743f9358e56581be82f659f17854c63f64333e/img/example1.png
--------------------------------------------------------------------------------
/img/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sunjingnjupt/sa-voxel-centernet/75743f9358e56581be82f659f17854c63f64333e/img/example2.png
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include "simpleViewer.h"
2 | #include
3 |
4 | int main(int argc, char **argv) {
5 | // Read command lines arguments.
6 | QApplication application(argc, argv);
7 |
8 | // Instantiate the viewer.
9 | Viewer viewer;
10 |
11 | viewer.setWindowTitle("simpleViewer");
12 |
13 | // Make the viewer window visible on screen.
14 | viewer.show();
15 |
16 | // Run main loop.
17 | return application.exec();
18 | }
--------------------------------------------------------------------------------
/object.cpp:
--------------------------------------------------------------------------------
1 | #include "object.h"
2 | #include
3 |
4 | using namespace qglviewer;
5 |
6 | void Object::draw() const {
7 | // glPushMatrix();
8 | // glMultMatrixd(frame.matrix());
9 | // glRectf(-0.01f, -0.01f, 0.01f, 0.01f);
10 | // glPopMatrix();
11 |
12 |
13 | // glPushMatrix();
14 | // glPointSize(2);
15 | // glBegin(GL_POINT);
16 | // // glBegin(GL_POINTS);
17 | // glMultMatrixd(frame.matrix());
18 | // glVertex3f(0.0, 0.0,0.0);
19 | // // glRectf(-0.01f, -0.01f, 0.01f, 0.01f);
20 | // glEnd();
21 | // glPopMatrix();
22 |
23 | static GLUquadric *quad = gluNewQuadric();
24 | glPushMatrix();
25 | glMultMatrixd(frame.matrix());
26 | glBegin(GL_POINTS);
27 | glVertex3d(0.0, 0.0, 0.0);
28 | glEnd();
29 | glPopMatrix();
30 | }
--------------------------------------------------------------------------------
/object.h:
--------------------------------------------------------------------------------
1 | #ifndef OBJECT_H_
2 | #define OBJECT_H_
3 |
4 | #include "QGLViewer/frame.h"
5 | #include
6 | class Object {
7 | public:
8 | using Ptr = std::shared_ptr