Moved odm_orthophoto to separate repo, removed build, modules folders

pull/1276/head
Piero Toffanin 2021-04-28 14:58:19 -04:00
rodzic 5e98c8bbc1
commit 22373321b4
12 zmienionych plików z 16 dodań i 1787 usunięć

Wyświetl plik

@ -147,6 +147,14 @@ externalproject_add(dem2points
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
)
externalproject_add(odm_orthophoto
GIT_REPOSITORY https://github.com/OpenDroneMap/odm_orthophoto.git
GIT_TAG main
PREFIX ${SB_BINARY_DIR}/odm_orthophoto
SOURCE_DIR ${SB_SOURCE_DIR}/odm_orthophoto
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR}
)
externalproject_add(lastools
GIT_REPOSITORY https://github.com/LAStools/LAStools.git
GIT_TAG 2ef44281645999ec7217facec84a5913bbbbe165

Wyświetl plik

@ -143,11 +143,6 @@ install() {
mkdir -p build && cd build
cmake .. && make -j$processes
echo "Compiling build"
cd ${RUNPATH}
mkdir -p build && cd build
cmake .. && make -j$processes
echo "Configuration Finished"
}
@ -191,6 +186,8 @@ clean() {
${RUNPATH}/SuperBuild/build/dem2points \
${RUNPATH}/SuperBuild/src/openmvs \
${RUNPATH}/SuperBuild/build/openmvs \
${RUNPATH}/SuperBuild/src/odm_orthophoto \
${RUNPATH}/SuperBuild/build/odm_orthophoto \
${RUNPATH}/SuperBuild/src/vcg
# find in /code and delete static libraries and intermediate object files

Wyświetl plik

@ -1,7 +0,0 @@
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# Add ODM sub-modules
add_subdirectory(odm_orthophoto)

Wyświetl plik

@ -1,42 +0,0 @@
project(odm_orthophoto)
cmake_minimum_required(VERSION 2.8)
# Set pcl dir to the input spedified with option -DPCL_DIR="path"
set(PCL_DIR "PCL_DIR-NOTFOUND" CACHE "PCL_DIR" "Path to the pcl installation directory")
set(OPENCV_DIR "OPENCV_DIR-NOTFOUND" CACHE "OPENCV_DIR" "Path to the OPENCV installation directory")
# Add compiler options.
add_definitions(-Wall -Wextra)
# Find pcl at the location specified by PCL_DIR
find_package(PCL 1.8 HINTS "${PCL_DIR}/share/pcl-1.8" REQUIRED)
find_package(GDAL REQUIRED)
# PCL should already link to Boost, but for some reason it doesn't...
find_package(Boost COMPONENTS filesystem REQUIRED)
include_directories(${GDAL_INCLUDE_DIR})
# Find OpenCV at the default location
find_package(OpenCV HINTS "${OPENCV_DIR}" REQUIRED)
# Only link with required opencv modules.
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui)
# Add the PCL, Eigen and OpenCV include dirs.
# Necessary since the PCL_INCLUDE_DIR variable set by find_package is broken.)
include_directories(${PCL_ROOT}/include/pcl-${PCL_VERSION_MAJOR}.${PCL_VERSION_MINOR})
include_directories(${EIGEN_ROOT})
include_directories(${OpenCV_INCLUDE_DIRS})
#library_directories(${OpenCV_LIBRARY_DIRS})
# Add source directory
aux_source_directory("./src" SRC_LIST)
# Add exectuteable
add_executable(${PROJECT_NAME} ${SRC_LIST})
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
)
target_link_libraries(odm_orthophoto ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_SURFACE_LIBRARIES} ${OpenCV_LIBS} ${GDAL_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})

Wyświetl plik

@ -1,29 +0,0 @@
#include "Logger.hpp"
Logger::Logger(bool isPrintingInCout) : isPrintingInCout_(isPrintingInCout)
{
}
Logger::~Logger()
{
}
void Logger::print(std::string filePath)
{
std::ofstream file(filePath.c_str(), std::ios::binary);
file << logStream_.str();
file.close();
}
bool Logger::isPrintingInCout() const
{
return isPrintingInCout_;
}
void Logger::setIsPrintingInCout(bool isPrintingInCout)
{
isPrintingInCout_ = isPrintingInCout;
}

Wyświetl plik

@ -1,68 +0,0 @@
#pragma once
// STL
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
/*!
* \brief The Logger class is used to store program messages in a log file.
* \details By using the << operator while printInCout is set, the class writes both to
* cout and to file, if the flag is not set, output is written to file only.
*/
class Logger
{
public:
/*!
* \brief Logger Contains functionality for printing and displaying log information.
* \param printInCout Flag toggling if operator << also writes to cout.
*/
Logger(bool isPrintingInCout = true);
/*!
* \brief Destructor.
*/
~Logger();
/*!
* \brief print Prints the contents of the log to file.
* \param filePath Path specifying where to write the log.
*/
void print(std::string filePath);
/*!
* \brief isPrintingInCout Check if console printing flag is set.
* \return Console printing flag.
*/
bool isPrintingInCout() const;
/*!
* \brief setIsPrintingInCout Set console printing flag.
* \param isPrintingInCout Value, if true, messages added to the log are also printed in cout.
*/
void setIsPrintingInCout(bool isPrintingInCout);
/*!
* Operator for printing messages to log and in the standard output stream if desired.
*/
template<class T>
friend Logger& operator<< (Logger &log, T t)
{
// If console printing is enabled.
if (log.isPrintingInCout_)
{
std::cout << t;
std::cout.flush();
}
// Write to log.
log.logStream_ << t;
return log;
}
private:
bool isPrintingInCout_; /*!< If flag is set, log is printed in cout and written to the log. */
std::stringstream logStream_; /*!< Stream for storing the log. */
};

Wyświetl plik

@ -1,207 +0,0 @@
#pragma once
// C++
#include <limits.h>
#include <istream>
#include <ostream>
// PCL
#include <pcl/io/obj_io.h>
#include <pcl/common/transforms.h>
// OpenCV
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
// PCL
#include <pcl/common/eigen.h>
#include <pcl/common/common.h>
// OpenCV
#include <opencv2/core/core.hpp>
// GDAL
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
// Logger
#include "Logger.hpp"
struct Bounds{
float xMin;
float xMax;
float yMin;
float yMax;
Bounds() : xMin(0), xMax(0), yMin(0), yMax(0) {}
Bounds(float xMin, float xMax, float yMin, float yMax) :
xMin(xMin), xMax(xMax), yMin(yMin), yMax(yMax){}
Bounds(const Bounds &b) {
xMin = b.xMin;
xMax = b.xMax;
yMin = b.yMin;
yMax = b.yMax;
}
};
/*!
* \brief The OdmOrthoPhoto class is used to create an orthographic photo over a given area.
* The class reads an oriented textured mesh from an OBJ-file.
* The class uses file read from pcl.
* The class uses image read and write from opencv.
*/
class OdmOrthoPhoto
{
public:
OdmOrthoPhoto();
~OdmOrthoPhoto();
/*!
* \brief run Runs the ortho photo functionality using the provided input arguments.
* For a list of accepted arguments, pleas see the main page documentation or
* call the program with parameter "-help".
* \param argc Application argument count.
* \param argv Argument values.
* \return 0 if successful.
*/
int run(int argc, char* argv[]);
private:
int width, height;
void parseArguments(int argc, char* argv[]);
void printHelp();
void createOrthoPhoto();
/*!
* \brief Compute the boundary points so that the entire model fits inside the photo.
*
* \param mesh The model which decides the boundary.
*/
Bounds computeBoundsForModel(const pcl::TextureMesh &mesh);
/*!
* \brief Creates a transformation which aligns the area for the orthophoto.
*/
Eigen::Transform<float, 3, Eigen::Affine> getROITransform(float xMin, float yMin) const;
template <typename T>
void initBands(int count);
template <typename T>
void initAlphaBand();
template <typename T>
void finalizeAlphaBand();
void saveTIFF(const std::string &filename, GDALDataType dataType);
/*!
* \brief Renders a triangle into the ortho photo.
*
* Pixel center defined as middle of pixel for triangle rasterisation, and in lower left corner for texture look-up.
*
* \param texture The texture of the polygon.
* \param polygon The polygon as athree indices relative meshCloud.
* \param meshCloud Contains all vertices.
* \param uvs Contains the texture coordinates for the active material.
* \param faceIndex The index of the face.
*/
template <typename T>
void drawTexturedTriangle(const cv::Mat &texture, const pcl::Vertices &polygon, const pcl::PointCloud<pcl::PointXYZ>::Ptr &meshCloud, const std::vector<Eigen::Vector2f> &uvs, size_t faceIndex);
/*!
* \brief Sets the color of a pixel in the photo.
*
* \param row The row index of the pixel.
* \param col The column index of the pixel.
* \param s The u texture-coordinate, multiplied with the number of columns in the texture.
* \param t The v texture-coordinate, multiplied with the number of rows in the texture.
* \param texture The texture from which to get the color.
**/
template <typename T>
void renderPixel(int row, int col, float u, float v, const cv::Mat &texture);
/*!
* \brief Calculates the barycentric coordinates of a point in a triangle.
*
* \param v1 The first triangle vertex.
* \param v2 The second triangle vertex.
* \param v3 The third triangle vertex.
* \param x The x coordinate of the point.
* \param y The y coordinate of the point.
* \param l1 The first vertex weight.
* \param l2 The second vertex weight.
* \param l3 The third vertex weight.
*/
void getBarycentricCoordinates(pcl::PointXYZ v1, pcl::PointXYZ v2, pcl::PointXYZ v3, float x, float y, float &l1, float &l2, float &l3) const;
/*!
* \brief Check if a given polygon is a sliver polygon.
*
* \param v1 The first vertex of the polygon.
* \param v2 The second vertex of the polygon.
* \param v3 The third vertex of the polygon.
*/
bool isSliverPolygon(pcl::PointXYZ v1, pcl::PointXYZ v2, pcl::PointXYZ v3) const;
/*!
* \brief Check if the model is suitable for ortho photo generation.
*
* \param mesh The model.
* \return True if the model is ok for generating ortho photo.
*/
bool isModelOk(const pcl::TextureMesh &mesh);
/*!
* \brief Loads a model from an .obj file (replacement for the pcl obj loader).
*
* \param inputFile Path to the .obj file.
* \param mesh The model.
* \return True if model was loaded successfully.
*/
bool loadObjFile(std::string inputFile, pcl::TextureMesh &mesh, std::vector<pcl::MTLReader> &companions);
/*!
* \brief Function is compied straight from the function in the pcl::io module.
*/
bool readHeader (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
Eigen::Vector4f &origin, Eigen::Quaternionf &orientation,
int &file_version, int &data_type, unsigned int &data_idx,
const int offset,
std::vector<pcl::MTLReader> &companions);
Logger log_; /**< Logging object. */
std::vector<std::string> inputFiles;
std::string outputFile_; /**< Path to the destination file. */
std::string outputCornerFile_; /**< Path to the output corner file. */
std::string logFile_; /**< Path to the log file. */
std::string bandsOrder;
float resolution_; /**< The number of pixels per meter in the ortho photo. */
std::vector<void *> bands;
std::vector<GDALColorInterp> colorInterps;
std::vector<std::string> bandDescriptions;
void *alphaBand; // Keep alpha band separate
int currentBandIndex;
cv::Mat depth_; /**< The depth of the ortho photo as an OpenCV matrix, CV_32F. */
};
/*!
* \brief The OdmOrthoPhoto class
*/
class OdmOrthoPhotoException : public std::exception
{
public:
OdmOrthoPhotoException() : message("Error in OdmOrthoPhoto") {}
OdmOrthoPhotoException(std::string msgInit) : message("Error in OdmOrthoPhoto:\n" + msgInit) {}
~OdmOrthoPhotoException() throw() {}
virtual const char* what() const throw() {return message.c_str(); }
private:
std::string message; /**< The error message **/
};

Wyświetl plik

@ -1,8 +0,0 @@
// Ortho photo generator.
#include "OdmOrthoPhoto.hpp"
int main(int argc, char* argv[])
{
OdmOrthoPhoto orthoPhotoGenerator;
return orthoPhotoGenerator.run(argc, argv);
}

Wyświetl plik

@ -44,6 +44,7 @@ pdal_path = os.path.join(superbuild_path, 'build/pdal/bin')
odm_modules_path = os.path.join(root_path, "build/bin")
odm_modules_src_path = os.path.join(root_path, "modules")
odm_orthophoto_path = os.path.join(superbuild_bin_path, "odm_orthophoto")
settings_path = os.path.join(root_path, 'settings.yaml')
# Define supported image extensions

Wyświetl plik

@ -184,20 +184,14 @@ parts:
cmake -G Ninja ..
cmake --build . --parallel 1
# Build the main ODM project
cd $SNAPCRAFT_PART_BUILD
mkdir -p build
cd build
cmake -G Ninja ..
cmake --build . --parallel $SNAPCRAFT_PARALLEL_BUILD_COUNT
rsync -av --exclude .git \
$SNAPCRAFT_PART_BUILD/ $SNAPCRAFT_PART_INSTALL/odm/
chmod -R u=rwX,go=rX $PYTHONUSERBASE/lib/python*
stage:
# strip the temporary build files and sources
- -odm/SuperBuild/build/opencv
- -odm/SuperBuild/build/openmvs
- -odm/SuperBuild/build/openmvs
- -odm/SuperBuild/build/odm_orthophoto
- -odm/SuperBuild/download
- -odm/SuperBuild/src/ceres
- -odm/SuperBuild/src/untwine
@ -215,6 +209,7 @@ parts:
- -odm/SuperBuild/src/vcg
- -odm/SuperBuild/src/dem2mesh
- -odm/SuperBuild/src/dem2points
- -odm/SuperBuild/src/odm_orthophoto
prime:
# remove any static-libraries
- -**/*.a

Wyświetl plik

@ -38,7 +38,7 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
# odm_orthophoto definitions
kwargs = {
'bin': context.odm_modules_path,
'odm_ortho_bin': context.odm_orthophoto_path,
'log': tree.odm_orthophoto_log,
'ortho': tree.odm_orthophoto_render,
'corners': tree.odm_orthophoto_corners,
@ -70,7 +70,7 @@ class ODMOrthoPhotoStage(types.ODM_Stage):
kwargs['models'] = ','.join(map(quote, models))
# run odm_orthophoto
system.run('{bin}/odm_orthophoto -inputFiles {models} '
system.run('{odm_ortho_bin} -inputFiles {models} '
'-logFile {log} -outputFile {ortho} -resolution {res} {verbose} '
'-outputCornerFile {corners} {bands}'.format(**kwargs))