Skip to content

Commit

Permalink
Merge pull request #38 from nilsbore/windows
Browse files Browse the repository at this point in the history
Start of Windows library. Wohoo!!
  • Loading branch information
nilsbore authored Sep 19, 2019
2 parents 6d0e64a + 723d656 commit f17e2fa
Show file tree
Hide file tree
Showing 42 changed files with 423 additions and 246 deletions.
39 changes: 39 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 1.0.{build}
os: Visual Studio 2017
platform: x64
clone_folder: C:\projects\auvlib
#shallow_clone: true
branches:
only:
- master
environment:
matrix:
- CONFIG: Release
BOOST_ROOT: C:/Libraries/boost_1_65_1
OpenCV_DIR: C:/tools/opencv/build/x64/vc14/lib
PYTHON: 27
install:
- cd C:\projects\auvlib
- git submodule update --init
#- cinst python2 appveyor already has python
- cinst OpenCV --version 3.4.7
build:
parallel: true
build_script:
# Tutorials and tests
#- set PATH=C:\Python%PYTHON%-x64;C:\Python%PYTHON%-x64\Scripts;%PATH%
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=%CONFIG%
-G "Visual Studio 15 2017 Win64"
-DAUVLIB_WITH_GSF=OFF
-DAUVLIB_USE_LIBIGL_GLFW=ON
-DAUVLIB_USE_LIBIGL_TINYXML=ON
-DAUVLIB_EXPORT_BUILD=OFF
-DCMAKE_SKIP_INSTALL_RULES=true
../
#-DCMAKE_INSTALL_PREFIX=../install
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- set MSBuildOptions=/v:m /m /p:BuildInParallel=true /p:Configuration=%CONFIG% /logger:%MSBuildLogger%
#- msbuild %MSBuildOptions% INSTALL.vcxproj
- msbuild %MSBuildOptions% ALL_BUILD.vcxproj
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "src/cxxopts"]
path = src/cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "src/cereal"]
path = src/cereal
url = https://github.com/USCiLab/cereal.git
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 2.8)
project(auvlib)

add_subdirectory(src)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# auvlib

[![Build Status](https://travis-ci.org/nilsbore/auvlib.svg?branch=master)](https://travis-ci.org/nilsbore/auvlib)
[![Build status](https://ci.appveyor.com/api/projects/status/kcfxp0jlpwqxt2fs/branch/master?svg=true)](https://ci.appveyor.com/project/nilsbore/auvlib/branch/master)
[![license](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

Tools for reading AUV deployment data files and for
Expand Down
64 changes: 55 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# locations on all platforms.
include(GNUInstallDirs)

find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(Ceres REQUIRED)
option(AUVLIB_WITH_GSF "Enable reading and processing gsf data" ON)
option(AUVLIB_USE_LIBIGL_EIGEN "Use libigl's version of Eigen" ON)
option(AUVLIB_USE_LIBIGL_GLFW "Use libigl's version of glfw" OFF)
option(AUVLIB_USE_LIBIGL_TINYXML "Use libigl's version of tinyxml" OFF)
option(AUVLIB_USE_PYTHON3 "Use python3 instead of python2" OFF)
option(AUVLIB_EXPORT_BUILD "Export build dir configs" ON)

# libigl
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
Expand All @@ -35,13 +36,55 @@ option(LIBIGL_WITH_PYTHON "Use Python" OFF)
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
option(LIBIGL_WITH_XML "Use XML" OFF)
option(LIBIGL_WITH_XML "Use XML" ON)
#option(LIBIGL_EXPORT_TARGETS "Export libigl CMake targets" ON)

find_package(OpenCV REQUIRED core highgui imgproc)
find_package(OpenGL REQUIRED)
if (AUVLIB_USE_LIBIGL_TINYXML)
set(TinyXML2_LIBRARIES tinyxml2)
else()
#find_package(TinyXML2 REQUIRED)
set(TinyXML2_LIBRARIES -ltinyxml2)
endif()

set(ENV{LIBIGL_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libigl)
find_package(LIBIGL REQUIRED QUIET)
include(${CMAKE_CURRENT_BINARY_DIR}/embree/embree-config.cmake)

if (AUVLIB_USE_LIBIGL_GLFW)
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libigl/external/glfw) # this might be needed on windows?
set(GLFW3_LIBRARY glfw)
else()
find_package(glfw3 REQUIRED)
endif()

if (AUVLIB_USE_LIBIGL_EIGEN)
set(EIGEN3_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libigl/external/eigen)
else()
find_package(Eigen3 REQUIRED)
endif()

if(MSVC)
if (AUVLIB_USE_PYTHON3)
set(PYTHON_EXECUTABLE C:/Python35/python.exe)
else()
#set(PYTHON_EXECUTABLE C:/Python27/python.exe)
set(PYTHON_EXECUTABLE C:/Python27-x64/python.exe)
endif()
else()
if (AUVLIB_USE_PYTHON3)
set(PYTHON_EXECUTABLE /usr/bin/python3.5)
else()
set(PYTHON_EXECUTABLE /usr/bin/python2.7)
endif()
endif()

if (MSVC)
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "use static libraries from Boost")
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_DEBUG_RUNTIME OFF)
endif()
# For some reason it seems like we need to do this after libigl
find_package(Boost COMPONENTS system filesystem date_time REQUIRED)

Expand All @@ -51,18 +94,21 @@ set(PYBIND11_CPP_STANDARD -std=c++11)
#add_definitions(-DPYBIND11_PYTHON_VERSION=2.7)
#set(PYBIND11_PYTHON_VERSION 2.7)
#set(PYTHON_LIBRARIES /usr/lib/x86_64-linux-gnu/libpython2.7.so)
set(PYTHON_EXECUTABLE /usr/bin/python2.7)

add_subdirectory(pybind11)

message("Pybind11: " ${PYBIND11_INCLUDE_DIR})

add_subdirectory(cxxopts)

include_directories(${PYBIND11_INCLUDE_DIR} ${CERES_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS})
include_directories(${PYBIND11_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/cereal/include ${TinyXML2_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
#include_directories(eigen_cereal/include)

include(cmake/glad.cmake)
add_subdirectory(libgsf)
if(AUVLIB_WITH_GSF)
add_subdirectory(libgsf)
endif()
add_subdirectory(libxtf)
add_subdirectory(eigen_cereal)
add_subdirectory(data_tools)
Expand Down
16 changes: 11 additions & 5 deletions src/bathy_maps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ add_library(sss_meas_data src/sss_meas_data.cpp)

add_library(sss_gen_sim src/sss_gen_sim.cpp)

add_executable(test_mesh src/test_mesh.cpp)
if(AUVLIB_WITH_GSF)
add_executable(test_mesh src/test_mesh.cpp)
endif()

# Define headers for this library. PUBLIC headers are used for
# compiling the library, and will be added to consumers' build
Expand Down Expand Up @@ -110,14 +112,16 @@ target_include_directories(sss_gen_sim PUBLIC
target_link_libraries(draw_map std_data ${OpenCV_LIBS})

#target_link_libraries(mesh_map std_data igl::embree ${OpenCV_LIBS} glad ${GLFW3_LIBRARY} ${OPENGL_LIBRARY} ${OPENGL_glu_LIBRARY} -lpthread)
target_link_libraries(mesh_map PRIVATE std_data ${OpenCV_LIBS} ${GLFW3_LIBRARY} auvlib_glad -lpthread -ltinyxml2) # ${TinyXML2_LIBRARIES})
target_link_libraries(mesh_map std_data ${OpenCV_LIBS} ${GLFW3_LIBRARY} auvlib_glad -lpthread ${TinyXML2_LIBRARIES})

target_link_libraries(align_map mesh_map std_data xyz_data ${GLFW3_LIBRARY} auvlib_glad -lpthread) # ${TinyXML2_LIBRARIES})


target_link_libraries(drape_mesh snell_ray_tracing xtf_data ${GLFW3_LIBRARY} auvlib_glad)

target_link_libraries(test_mesh std_data gsf_data xtf_data csv_data navi_data mesh_map draw_map patch_draper igl::embree ${OpenCV_LIBS} cxxopts)
if(AUVLIB_WITH_GSF)
target_link_libraries(test_mesh std_data gsf_data xtf_data csv_data navi_data mesh_map draw_map patch_draper igl::embree ${OpenCV_LIBS} cxxopts)
endif()

target_link_libraries(patch_views eigen_cereal ${OpenCV_LIBS})

Expand Down Expand Up @@ -146,5 +150,7 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# just go into 'cmake'.
install(EXPORT BathyMapsConfig DESTINATION share/BathyMaps/cmake)

# This makes the project importable from the build directory
export(TARGETS draw_map mesh_map align_map drape_mesh patch_draper base_draper map_draper patch_views sss_map_image sss_meas_data sss_gen_sim FILE BathyMapsConfig.cmake)
if (AUVLIB_EXPORT_BUILD)
# This makes the project importable from the build directory
export(TARGETS draw_map mesh_map align_map drape_mesh patch_draper base_draper map_draper patch_views sss_map_image sss_meas_data sss_gen_sim FILE BathyMapsConfig.cmake)
endif()
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/align_map.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef ALIGN_MAP_H
#define ALIGN_MAP_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <igl/AABB.h>
#include <data_tools/xyz_data.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/base_draper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <igl/opengl/glfw/Viewer.h>
#include <igl/opengl/gl.h>

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <random>

#include <data_tools/xtf_data.h>
Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/drape_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef DRAPE_MESH_H
#define DRAPE_MESH_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <data_tools/xtf_data.h>
#include <data_tools/csv_data.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/mesh_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef MESH_MAP_H
#define MESH_MAP_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <data_tools/std_data.h>
#include <data_tools/xtf_data.h>

Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/patch_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef PATCH_VIEWS_H
#define PATCH_VIEWS_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <eigen_cereal/eigen_cereal.h>
#include <cereal/archives/binary.hpp>
#include <cereal/types/vector.hpp>
Expand Down
6 changes: 3 additions & 3 deletions src/bathy_maps/include/bathy_maps/sss_map_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef SSS_MAP_IMAGE_H
#define SSS_MAP_IMAGE_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <eigen_cereal/eigen_cereal.h>
#include <cereal/archives/binary.hpp>
#include <cereal/types/vector.hpp>
Expand All @@ -27,7 +27,7 @@ struct sss_map_image {

BoundsT bounds;

Eigen::MatrixXd sss_map_image;
Eigen::MatrixXd sss_map_image_;

double sss_ping_duration; // max time in waterfall image
Eigen::MatrixXf sss_waterfall_image;
Expand All @@ -40,7 +40,7 @@ struct sss_map_image {
template <class Archive>
void serialize( Archive & ar )
{
ar(CEREAL_NVP(bounds), CEREAL_NVP(sss_map_image), CEREAL_NVP(sss_ping_duration),
ar(CEREAL_NVP(bounds), CEREAL_NVP(sss_map_image_), CEREAL_NVP(sss_ping_duration),
CEREAL_NVP(sss_waterfall_image), CEREAL_NVP(sss_waterfall_cross_track),
CEREAL_NVP(sss_waterfall_depth), CEREAL_NVP(sss_waterfall_model), CEREAL_NVP(pos));
}
Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/include/bathy_maps/sss_meas_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef SSS_MEAS_DATA_H
#define SSS_MEAS_DATA_H

#include <eigen3/Eigen/Dense>
#include <Eigen/Dense>
#include <eigen_cereal/eigen_cereal.h>
#include <cereal/archives/binary.hpp>
#include <cereal/types/vector.hpp>
Expand Down
36 changes: 18 additions & 18 deletions src/bathy_maps/src/align_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ double compute_overlap_ratio(const Eigen::MatrixXd& P1, const Eigen::MatrixXd& P
int overlapping_points = 0;
for (int i = 0; i < P1.rows(); i += skip) {
Eigen::MatrixXd::Index index;
// find nearest neighbour
// find near_est neighbour
//(P2_sub.rowwise() - P1.row(i)).colwise().squaredNorm().minCoeff(&index);
double dist = sqrt((P2_sub.rowwise() - P1.row(i)).colwise().squaredNorm().minCoeff(&index));
//double dist = (P2_sub.row(index) - P1.row(i)).norm();
Expand Down Expand Up @@ -113,16 +113,16 @@ double points_to_mesh_rmse(const Eigen::MatrixXd& P, const Eigen::MatrixXd& V, c
tree.squared_distance(V, F, P, sqrD, I, Q);
//Eigen::ArrayXd temp = (P - Q).rowwise().squaredNorm().array();
//cout << "Temp: " << temp.transpose() << endl;
Eigen::Array<bool, Eigen::Dynamic, 1> near = (P - Q).rowwise().squaredNorm().array() < assoc_threshold*assoc_threshold;
Eigen::Array<bool, Eigen::Dynamic, 1> near_ = (P - Q).rowwise().squaredNorm().array() < assoc_threshold*assoc_threshold;

int nbr_near = near.cast<int>().sum();
int nbr_near_ = near_.cast<int>().sum();

cout << "Number points near surface: " << nbr_near << endl;
cout << "Number points near_ surface: " << nbr_near_ << endl;
cout << "Out of: " << P.rows() << endl;
cout << "P rows: " << P.rows() << endl;

Eigen::MatrixXd goodP = igl::slice_mask(P, near, 1);
Eigen::MatrixXd goodQ = igl::slice_mask(Q, near, 1);
Eigen::MatrixXd goodP = igl::slice_mask(P, near_, 1);
Eigen::MatrixXd goodQ = igl::slice_mask(Q, near_, 1);

cout << "GoodP rows: " << goodP.rows() << ", cols: " << goodP.cols() << endl;

Expand All @@ -142,13 +142,13 @@ Eigen::MatrixXd filter_points_mesh_offset(const Eigen::MatrixXd& P, const Eigen:
cout << "Finding closes mesh points..." << endl;

tree.squared_distance(V, F, P, sqrD, I, Q);
Eigen::Array<bool, Eigen::Dynamic, 1> near = sqrD.array() < offset*offset;
Eigen::Array<bool, Eigen::Dynamic, 1> near_ = sqrD.array() < offset*offset;

int nbr_near = near.cast<int>().sum();
int nbr_near_ = near_.cast<int>().sum();

cout << "Number points near surface: " << nbr_near << " out of: " << P.rows() << endl;
cout << "Number points near_ surface: " << nbr_near_ << " out of: " << P.rows() << endl;

Eigen::MatrixXd goodP = igl::slice_mask(P, near, 1);
Eigen::MatrixXd goodP = igl::slice_mask(P, near_, 1);

cout << "GoodP rows: " << goodP.rows() << ", cols: " << goodP.cols() << endl;

Expand Down Expand Up @@ -304,26 +304,26 @@ tuple<Eigen::Matrix4d, double, bool> icp_iteration(const Eigen::MatrixXd& P, con
Eigen::MatrixXd Q;

tree.squared_distance(V, F, P, sqrD, I, Q);
//Eigen::Array<bool, Eigen::Dynamic, 1> near = (P - Q).rowwise().squaredNorm().array() < assoc_threshold*assoc_threshold;
//Eigen::Array<bool, Eigen::Dynamic, 1> near_ = (P - Q).rowwise().squaredNorm().array() < assoc_threshold*assoc_threshold;
Eigen::Array<bool, Eigen::Dynamic, 1> close = (P - Q).leftCols<2>().rowwise().squaredNorm().array() < 0.1*0.1;
Eigen::Array<bool, Eigen::Dynamic, 1> near = sqrD.array() < assoc_threshold*assoc_threshold && close;
Eigen::Array<bool, Eigen::Dynamic, 1> near_ = sqrD.array() < assoc_threshold*assoc_threshold && close;

int nbr_near = near.cast<int>().sum();
cout << "Number points near surface: " << nbr_near << endl;
int nbr_near_ = near_.cast<int>().sum();
cout << "Number points near_ surface: " << nbr_near_ << endl;
cout << "Out of: " << P.rows() << endl;

if (nbr_near < 100) {
if (nbr_near_ < 100) {
cout << "Breaking since we do not have enough points!" << endl;
return make_tuple(Eigen::Matrix4d::Identity(), 0., false);
}

Eigen::MatrixXd goodP = igl::slice_mask(P, near, 1);
Eigen::MatrixXd goodQ = igl::slice_mask(Q, near, 1);
Eigen::MatrixXd goodP = igl::slice_mask(P, near_, 1);
Eigen::MatrixXd goodQ = igl::slice_mask(Q, near_, 1);

Eigen::Vector3d meanP = goodP.rowwise().mean().transpose();
Eigen::Vector3d meanQ = goodQ.rowwise().mean().transpose();

double mean_dist = igl::slice_mask(sqrD, near, 1).mean(); //(goodP - goodQ).rowwise().squaredNorm().mean();
double mean_dist = igl::slice_mask(sqrD, near_, 1).mean(); //(goodP - goodQ).rowwise().squaredNorm().mean();

Eigen::Matrix3d covariance = 1./double(goodP.rows())*(goodQ.transpose().colwise() - meanQ)*(goodP.rowwise() - meanP.transpose());

Expand Down
2 changes: 1 addition & 1 deletion src/bathy_maps/src/sss_gen_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bool SSSGenSim::callback_pre_draw(igl::opengl::glfw::Viewer& viewer)
time_windows.tail(time_windows_right.rows()) = time_windows_right;
time_windows.head(time_windows_left.rows()) = time_windows_left.reverse();

for (int i = 0; i < std::min(time_windows.rows(), long(waterfall_image.cols)); ++i) {
for (int i = 0; i < std::min(time_windows.rows(), int64_t(waterfall_image.cols)); ++i) {
waterfall_image.at<uint8_t>(0, i) = uint8_t(255.*time_windows(i));
}

Expand Down
Loading

0 comments on commit f17e2fa

Please sign in to comment.