Skip to content

Files for cubert.example #2

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

Open
wants to merge 19 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
64 changes: 64 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{


// docker build commands are to create the docker image
// docker build -t docker_image_name -f dockerfile_name .
//docker network is needed to assign ip address to docker container
// docker network create --driver bridge --subnet 192.168.200.0/24 my_custom_network


// make sure to uncomment the image that is desired for development
"image": "hypertools_sfm:latest" ,
// "image": "hypertools_cubert:latest" ,
// "image": "hypertools_4_2_cuda:latest" ,
// "image": "hypertools_current_opencv:latest" ,
// "image": "hypertools_cubert_cuda:latest" ,
// "image": "hypertools_cuda_ml:latest" ,


"mounts": [

// below two mounts are for visualization on windows machine if there are issues with wsl
// "source=/run/desktop/mnt/host/wslg/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
// "source=/run/desktop/mnt/host/wslg,target=/mnt/wslg,type=bind,consistency=cached",

// below is used for visualization on ubuntu machine if there are issues with visualization
// "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",

// below mounts hyperimages in container
"source=${localWorkspaceFolder}/../HyperImages,target=/workspaces/HyperImages,type=bind,consistency=cached"
],


// "remoteEnv": {"DISPLAY":":0"},

//below is used when cuda image is being used
/*
"runArgs": [
"--gpus=all", // used for cuda images
//"--network=host", //used to connect to camera on ubunutu, assumes host has ethernet interface ip of 192.168.20.x, subnet of 255.255.255.0
//testing below for getting camera working with docker in wsl
// "-p", "9392:9392", "--network=my_custom_network", "ip=192.168.200.20"
//note: subnet needs to be 255.255.255.0, camera ip is 127.0.0.1
],*/

"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"GitHub.copilot",
"ms-vscode.cmake-tools",
"ms-azuretools.vscode-docker",
"streetsidesoftware.code-spell-checker",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack"

]
}
}

}
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

#build directory
**/build/*

# temp ui
*.ui~

*.json
*.DS_Store
*.log
*.pyc
125 changes: 65 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,87 +1,90 @@
##############################################################################
# CMAKE CONFIGURATION
##############################################################################
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)

# set project name
project(iTree3DMap VERSION 1.0.0)
project(iTree3DMap C CXX)

# set build type = Debug mode
set(CMAKE_BUILD_TYPE Release)

message("\n" "=========================================")
message("Project: ${PROJECT_NAME} ")
message("=========================================")
# set(CMAKE_BUILD_TYPE Release)

# set the include directive in the same project folder
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# set(CMAKE_INCLUDE_CURRENT_DIR ON)

# set corresponding package directories
set(OpenCV_DIR /opt/opencv-3.4.1/build)
set(PCL_DIR /opt/pcl-1.8.1/build)
find_package(OpenCV REQUIRED)
find_package(Ceres REQUIRED)
find_package(PCL REQUIRED)
find_package(VTK 7.1 REQUIRED)

# set(OpenCV_DIR /opt/opencv-3.4.1/build)
# set(PCL_DIR /opt/pcl-1.8.1/build)

# set the CMP0074 policy to old behavior (disable warnings)
cmake_policy(SET CMP0074 OLD)
# cmake_policy(SET CMP0074 OLD)

# Include dependencies of pcl 1.8.1 in project directorie
set(CMAKE_MODULE_PATH ${PCL_DIR}/../cmake/Modules)
# set(CMAKE_MODULE_PATH ${PCL_DIR}/../cmake/Modules)

# set cmake for use std c++11 and output executable folder to bin
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

# set turn off the output rule messages of cmake
set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)

##############################################################################
# PACKAGES
##############################################################################
message("Finding packages...")

message("***********************")
message("OpenCV PACKAGE")
message("***********************")

set(OpenCV_Components core highgui features2d xfeatures2d calib3d imgcodecs imgproc)
find_package(OpenCV 3.4.1 REQUIRED PATHS ${OPENCV_DIR} COMPONENTS ${OpenCV_Components})
if(OpenCV_FOUND)
message(STATUS "OpenCV status:")
message(STATUS " version: ${OpenCV_VERSION}")
else()
message(FATAL_ERROR " ERROR: OpenCV ${OpenCV_VERSION} not found")
endif()

message("***********************")
message("Ceres PACKAGE")
message("***********************")

find_package(Ceres 1.13.0 REQUIRED)
if(Ceres_FOUND)
message(STATUS "Ceres library status:")
message(STATUS " version: ${CERES_VERSION}")
else()
message(FATAL_ERROR " ERROR: Ceres ${CERES_VERSION} not found")
endif()

message("***********************")
message("PCL PACKAGE")
message("***********************")

find_package(PCL 1.8.1 REQUIRED PATHS ${PCL_DIR})
if(PCL_FOUND)
message(STATUS "PCL library status:")
message(STATUS " version: ${PCL_VERSION}")
else()
message(FATAL_ERROR " ERROR: PCL not found")
endif()
# message("Finding packages...")

# message("***********************")
# message("OpenCV PACKAGE")
# message("***********************")

# set(OpenCV_Components core highgui features2d xfeatures2d calib3d imgcodecs imgproc)
# find_package(OpenCV REQUIRED)
# if(OpenCV_FOUND)
# message(STATUS "OpenCV status:")
# message(STATUS " version: ${OpenCV_VERSION}")
# else()
# message(FATAL_ERROR " ERROR: OpenCV ${OpenCV_VERSION} not found")
# endif()

# message("***********************")
# message("Ceres PACKAGE")
# message("***********************")

# find_package(Ceres REQUIRED)
# if(Ceres_FOUND)
# message(STATUS "Ceres library status:")
# message(STATUS " version: ${CERES_VERSION}")
# else()
# message(FATAL_ERROR " ERROR: Ceres ${CERES_VERSION} not found")
# endif()

# message("***********************")
# message("PCL PACKAGE")
# message("***********************")

# find_package(PCL REQUIRED)
# if(PCL_FOUND)
# message(STATUS "PCL library status:")
# message(STATUS " version: ${PCL_VERSION}")
# else()
# message(FATAL_ERROR " ERROR: PCL not found")
# endif()

##############################################################################
# HEADERS
##############################################################################
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${PCL_INCLUDE_DIRS})
include_directories(${CERES_INCLUDE_DIRS})
include(CheckFunctionExists)
include(${VTK_USE_FILE})
# include(CheckFunctionExists)

# Use the compile definitions defined in PCL
#add_definitions(${PCL_DEFINITIONS})
Expand All @@ -92,6 +95,7 @@ include(CheckFunctionExists)
link_directories(${OpenCV_LIBRARIES})
link_directories(${PCL_LIBRARY_DIRS})
link_directories(${CERES_LIBRARIES})
link_directories(${VTK_LIBRARIES})

##############################################################################
# SOURCE CODE
Expand All @@ -117,11 +121,12 @@ add_executable(${PROJECT_NAME} ${SFM_HEADER} ${SFM_SOURCE} ${SEGMENT_HEADER} ${S
##############################################################################
# TARGET LIBRARIES
##############################################################################
set(OpenCV_LIBRARIES opencv_core opencv_highgui opencv_features2d opencv_calib3d
opencv_imgproc opencv_imgcodecs opencv_xfeatures2d)
# set(OpenCV_LIBRARIES opencv_core opencv_highgui opencv_features2d opencv_calib3d
# opencv_imgproc opencv_imgcodecs opencv_xfeatures2d)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES} ${VTK_LIBRARIES})

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${CERES_LIBRARIES})

message("=========================================")
message("Project: ${PROJECT_NAME} COMPILED WITH CMAKE " ${CMAKE_VERSION})
message("=========================================")
# message("=========================================")
# message("Project: ${PROJECT_NAME} COMPILED WITH CMAKE " ${CMAKE_VERSION})
# message("=========================================")
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM hypertools_4_2:latest

RUN apt-get update

RUN apt-get install -y \
python3-pip \
libceres-dev


RUN apt update && apt-get update && apt-get install -y \
libpcl-dev \
libvtk7-dev

# gdb \
# gdbserver

33 changes: 15 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,33 @@ A simple incremental SFM pipeline for 3D reconstruction of a tree with bundle ad

<img src="./imgs/example.png" align="center" height="500" width="950"><br>

### Resources

* Homepage: <http://opencv.org>
* Docs: <http://docs.opencv.org/master/>

## Build

To build use CMake minimum required 3.5.1 : https://github.com/Kitware/CMake

### Prerequisite
- OpenCV 3.4.1: https://github.com/opencv/opencv/tree/3.4.1
- PCL 1.8.1: https://github.com/PointCloudLibrary/pcl/tree/pcl-1.8.1

### Compilation
* Set "YOUR OWN" PCL Build DIR in CMakeList.txt e.g: **/opt/pcl-1.8.1/build** and save it.
* Set "YOUR OWN" OpenCV Build DIR in CMakeList.txt e.g: **/opt/opencv-3.4.1/build** and save it.
* Create a "build" folder

in the main folder:
in the build folder:

cd /build
cmake ../
cd build/
cmake ..
make
./iTree3DMap

### Test
cd /build/bin
./iTree3DMap

*Note:*
If OpenCV is not installed (just compiled). please set the path to the current build directory in the CMakeList.txt file.



### debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
file ./iTree3DMap
apt-get update && apt-get install -y gdb gdbserver
gdb ./iTree3DMap
break main # adds breakpoint
run
continue
info locals infor args
quit # quit gdb
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char **argv){
STEP X: INPUT IMAGES
**************************/
StructFromMotion sf;
bool success = sf.imagesLOAD("/home/daniel/Proyecto-grado-3D-recons-master/data/temple");
bool success = sf.imagesLOAD("../data/temple");
if(not success){
std::cerr << "Error: set of images is not valid." << std::endl;
return -1;
Expand All @@ -56,7 +56,7 @@ int main(int argc, char **argv){
/*************************
STEP X: INPUT CAMERA FILE
**************************/
success = sf.getCameraMatrix("/home/daniel/Proyecto-grado-3D-recons-master/data/temple/camera_calibration_template.xml");
success = sf.getCameraMatrix("../data/temple/camera_calibration_template.xml");
if(not success){
std::cerr << "Error: camera calibration file is not valid." << std::endl;
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/BundleAdjustment.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "include/BundleAdjustment.h"
#include "../include/BundleAdjustment.h"
#include <ceres/ceres.h>
#include <ceres/rotation.h>

Expand Down
2 changes: 1 addition & 1 deletion src/DendrometryE.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "include/DendrometryE.h"
#include "../include/DendrometryE.h"

void Dendrometry::estimate(pcl::PointCloud<pcl::PointXYZRGB>::Ptr& cloudPCL){

Expand Down
2 changes: 1 addition & 1 deletion src/Segmentation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "include/Segmentation.h"
#include "../include/Segmentation.h"

void Segmentation::color_based_growing_segmentation(){

Expand Down
Loading