kopia lustrzana https://github.com/OpenDroneMap/ODM
				
				
				
			Merge pull request #702 from dakotabenjamin/bug-fixes
Bug fixes
Former-commit-id: 9438e4bea4
			
			
				pull/1161/head
			
			
		
						commit
						0a3871e67b
					
				| 
						 | 
				
			
			@ -3,7 +3,6 @@ add_subdirectory(odm_extract_utm)
 | 
			
		|||
add_subdirectory(odm_georef)
 | 
			
		||||
add_subdirectory(odm_meshing)
 | 
			
		||||
add_subdirectory(odm_orthophoto)
 | 
			
		||||
add_subdirectory(odm_texturing)
 | 
			
		||||
add_subdirectory(odm_25dmeshing)
 | 
			
		||||
if (ODM_BUILD_SLAM)
 | 
			
		||||
  add_subdirectory(odm_slam)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -272,7 +272,7 @@ void Georef::parseArguments(int argc, char *argv[])
 | 
			
		|||
    bool imageListSpecified = false;
 | 
			
		||||
    bool gcpFileSpecified = false;
 | 
			
		||||
    bool imageLocation = false;
 | 
			
		||||
    bool bundleResized = false;
 | 
			
		||||
    // bool bundleResized = false;
 | 
			
		||||
    bool outputCoordSpecified = false;
 | 
			
		||||
    bool inputCoordSpecified = false;
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -435,7 +435,7 @@ void Georef::parseArguments(int argc, char *argv[])
 | 
			
		|||
            log_ << "Georef file output path is set to: " << georefFilename_ << "\n";
 | 
			
		||||
            exportGeorefSystem_ = true;
 | 
			
		||||
        }
 | 
			
		||||
        else if(argument == "-bundleResizedTo" && argIndex < argc)
 | 
			
		||||
        /*else if(argument == "-bundleResizedTo" && argIndex < argc)
 | 
			
		||||
        {
 | 
			
		||||
            argIndex++;
 | 
			
		||||
            if (argIndex >= argc)
 | 
			
		||||
| 
						 | 
				
			
			@ -450,7 +450,7 @@ void Georef::parseArguments(int argc, char *argv[])
 | 
			
		|||
            }
 | 
			
		||||
            log_ << "Bundle resize value is set to: " << bundleResizedTo_ << "\n";
 | 
			
		||||
            bundleResized = true;
 | 
			
		||||
        }
 | 
			
		||||
        }*/
 | 
			
		||||
        else if(argument == "-outputFile" && argIndex < argc)
 | 
			
		||||
        {
 | 
			
		||||
            argIndex++;
 | 
			
		||||
| 
						 | 
				
			
			@ -485,7 +485,7 @@ void Georef::parseArguments(int argc, char *argv[])
 | 
			
		|||
        throw GeorefException("Both output and input coordfile specified, only one of those are accepted.");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (imageListSpecified && gcpFileSpecified && imageLocation && bundleResized)
 | 
			
		||||
    if (imageListSpecified && gcpFileSpecified && imageLocation ) // && bundleResized)
 | 
			
		||||
    {
 | 
			
		||||
        useGCP_ = true;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -550,8 +550,8 @@ void Georef::printHelp()
 | 
			
		|||
    log_ << "\"-imagesPath <path>\" (mandatory if using ground control points)\n";
 | 
			
		||||
    log_ << "Path to the folder containing full resolution images.\n\n";
 | 
			
		||||
 | 
			
		||||
    log_ << "\"-bundleResizedTo <integer>\" (mandatory if using ground control points)\n";
 | 
			
		||||
    log_ << "The resized resolution used in bundler.\n\n";
 | 
			
		||||
    // log_ << "\"-bundleResizedTo <integer>\" (mandatory if using ground control points)\n";
 | 
			
		||||
    // log_ << "The resized resolution used in bundler.\n\n";
 | 
			
		||||
    
 | 
			
		||||
    log_ << "\"-outputFile <path>\" (optional, default <inputFile>_geo)" << "\n";
 | 
			
		||||
    log_ << "\"Output obj file that will contain the georeferenced texture mesh.\n\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -797,7 +797,6 @@ void Georef::performGeoreferencingWithGCP()
 | 
			
		|||
        cv::Mat image = cv::imread(cam.texture_file);
 | 
			
		||||
        cam.height = static_cast<double>(image.rows);
 | 
			
		||||
        cam.width = static_cast<double>(image.cols);
 | 
			
		||||
        cam.focal_length *= static_cast<double>(cam.width)/bundleResizedTo_;
 | 
			
		||||
 | 
			
		||||
        // The pixel position for the GCP in pcl-format in order to use pcl-functions
 | 
			
		||||
        pcl::PointXY gcpPos;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -271,7 +271,7 @@ private:
 | 
			
		|||
    bool            exportCoordinateFile_;
 | 
			
		||||
    bool            exportGeorefSystem_;
 | 
			
		||||
    bool            useGCP_;                    /**< Check if GCP-file is present and use this to georeference the model. **/
 | 
			
		||||
    double          bundleResizedTo_;           /**< The size used in the previous steps to calculate the camera focal_length. */
 | 
			
		||||
    // double          bundleResizedTo_;           /**< The size used in the previous steps to calculate the camera focal_length. */
 | 
			
		||||
 | 
			
		||||
    std::vector<GeorefCamera> cameras_;         /**< A vector of all cameras. **/
 | 
			
		||||
    std::vector<GeorefGCP> gcps_;               /**< A vector of all GCPs. **/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,37 +0,0 @@
 | 
			
		|||
project(odm_texturing)
 | 
			
		||||
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 to the input spedified with option -DOPENCV_DIR="path"
 | 
			
		||||
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 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})
 | 
			
		||||
target_link_libraries(odm_texturing ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_SURFACE_LIBRARIES} ${OpenCV_LIBS})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,203 +0,0 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE QtCreatorProject>
 | 
			
		||||
<!-- Written by Qt Creator 2.4.1, 2015-02-09T16:23:25. -->
 | 
			
		||||
<qtcreator>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.ActiveTarget</variable>
 | 
			
		||||
  <value type="int">0</value>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.EditorSettings</variable>
 | 
			
		||||
  <valuemap type="QVariantMap">
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
 | 
			
		||||
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
 | 
			
		||||
    <value type="QString" key="language">Cpp</value>
 | 
			
		||||
    <valuemap type="QVariantMap" key="value">
 | 
			
		||||
     <value type="QString" key="CurrentPreferences">CppGlobal</value>
 | 
			
		||||
    </valuemap>
 | 
			
		||||
   </valuemap>
 | 
			
		||||
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
 | 
			
		||||
    <value type="QString" key="language">QmlJS</value>
 | 
			
		||||
    <valuemap type="QVariantMap" key="value">
 | 
			
		||||
     <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
 | 
			
		||||
    </valuemap>
 | 
			
		||||
   </valuemap>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
 | 
			
		||||
   <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.IndentSize">4</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.TabSize">8</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
 | 
			
		||||
   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
 | 
			
		||||
   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
 | 
			
		||||
  </valuemap>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.PluginSettings</variable>
 | 
			
		||||
  <valuemap type="QVariantMap"/>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.Target.0</variable>
 | 
			
		||||
  <valuemap type="QVariantMap">
 | 
			
		||||
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
 | 
			
		||||
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.DefaultCMakeTarget</value>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
 | 
			
		||||
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
 | 
			
		||||
    <value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory">/home/spotscale/odm/OpenDroneMap_spotscale/odm_texturing4-build</value>
 | 
			
		||||
    <value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
 | 
			
		||||
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
 | 
			
		||||
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 | 
			
		||||
      <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
 | 
			
		||||
      <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
 | 
			
		||||
      <value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
 | 
			
		||||
     </valuemap>
 | 
			
		||||
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
 | 
			
		||||
    </valuemap>
 | 
			
		||||
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
 | 
			
		||||
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
 | 
			
		||||
      <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
 | 
			
		||||
      <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
 | 
			
		||||
      <value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
 | 
			
		||||
     </valuemap>
 | 
			
		||||
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
 | 
			
		||||
    </valuemap>
 | 
			
		||||
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
 | 
			
		||||
    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
 | 
			
		||||
    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">all</value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
 | 
			
		||||
   </valuemap>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
 | 
			
		||||
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
 | 
			
		||||
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
 | 
			
		||||
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
 | 
			
		||||
    </valuemap>
 | 
			
		||||
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
 | 
			
		||||
   </valuemap>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
 | 
			
		||||
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
 | 
			
		||||
    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
 | 
			
		||||
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
 | 
			
		||||
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
 | 
			
		||||
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
 | 
			
		||||
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
 | 
			
		||||
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
 | 
			
		||||
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
 | 
			
		||||
    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
 | 
			
		||||
    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
 | 
			
		||||
    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
 | 
			
		||||
     <value type="int">0</value>
 | 
			
		||||
     <value type="int">1</value>
 | 
			
		||||
     <value type="int">2</value>
 | 
			
		||||
     <value type="int">3</value>
 | 
			
		||||
     <value type="int">4</value>
 | 
			
		||||
     <value type="int">5</value>
 | 
			
		||||
     <value type="int">6</value>
 | 
			
		||||
     <value type="int">7</value>
 | 
			
		||||
     <value type="int">8</value>
 | 
			
		||||
     <value type="int">9</value>
 | 
			
		||||
     <value type="int">10</value>
 | 
			
		||||
     <value type="int">11</value>
 | 
			
		||||
     <value type="int">12</value>
 | 
			
		||||
     <value type="int">13</value>
 | 
			
		||||
     <value type="int">14</value>
 | 
			
		||||
    </valuelist>
 | 
			
		||||
    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
 | 
			
		||||
     <value type="int">0</value>
 | 
			
		||||
     <value type="int">1</value>
 | 
			
		||||
     <value type="int">2</value>
 | 
			
		||||
     <value type="int">3</value>
 | 
			
		||||
     <value type="int">4</value>
 | 
			
		||||
     <value type="int">5</value>
 | 
			
		||||
     <value type="int">6</value>
 | 
			
		||||
     <value type="int">7</value>
 | 
			
		||||
     <value type="int">8</value>
 | 
			
		||||
     <value type="int">9</value>
 | 
			
		||||
     <value type="int">10</value>
 | 
			
		||||
     <value type="int">11</value>
 | 
			
		||||
     <value type="int">12</value>
 | 
			
		||||
     <value type="int">13</value>
 | 
			
		||||
     <value type="int">14</value>
 | 
			
		||||
    </valuelist>
 | 
			
		||||
    <value type="int" key="CMakeProjectManager.BaseEnvironmentBase">2</value>
 | 
			
		||||
    <value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">odm_texturing</value>
 | 
			
		||||
    <value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments">-verbose -bundleFile "../../../shared_folder/copr2/reconstruction-with-image-size-1200/bundle/bundle.out" -imagesPath "../../../shared_folder/copr2" -imagesListPath "../../../shared_folder/copr2/reconstruction-with-image-size-1200/list.txt" -inputModelPath "../../../shared_folder/copr2/reconstruction-with-image-size-1200-results/odm_mesh-0000.ply" -outputFolder "../../../shared_folder/copr2/reconstruction-with-image-size-1200-results/odm_texturing/" -textureResolution 4096 -textureWithSize 3600 -bundleResizedTo 1200</value>
 | 
			
		||||
    <value type="bool" key="CMakeProjectManager.CMakeRunConfiguration.UseTerminal">false</value>
 | 
			
		||||
    <valuelist type="QVariantList" key="CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges"/>
 | 
			
		||||
    <value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">odm_texturing</value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
 | 
			
		||||
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
 | 
			
		||||
    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
 | 
			
		||||
    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
 | 
			
		||||
    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
 | 
			
		||||
    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
 | 
			
		||||
   </valuemap>
 | 
			
		||||
   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
 | 
			
		||||
  </valuemap>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.TargetCount</variable>
 | 
			
		||||
  <value type="int">1</value>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
 | 
			
		||||
  <value type="QString">{785a73be-b55f-490c-9d46-e1451c235840}</value>
 | 
			
		||||
 </data>
 | 
			
		||||
 <data>
 | 
			
		||||
  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
 | 
			
		||||
  <value type="int">10</value>
 | 
			
		||||
 </data>
 | 
			
		||||
</qtcreator>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,31 +0,0 @@
 | 
			
		|||
#include "Logger.hpp"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Logger::Logger(bool isPrintingInCout) : isPrintingInCout_(isPrintingInCout)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Logger::~Logger()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Logger::printToFile(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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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 printToFile(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. */
 | 
			
		||||
};
 | 
			
		||||
										
											
												Plik diff jest za duży
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,211 +0,0 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
// STL
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
 | 
			
		||||
// PCL
 | 
			
		||||
#include <pcl/point_types.h>
 | 
			
		||||
#include <pcl/search/kdtree.h>
 | 
			
		||||
#include <pcl/surface/texture_mapping.h>
 | 
			
		||||
 | 
			
		||||
// OpenCV
 | 
			
		||||
#include <opencv2/imgproc/imgproc.hpp>
 | 
			
		||||
#include <opencv2/highgui/highgui.hpp>
 | 
			
		||||
 | 
			
		||||
// Modified PCL functions
 | 
			
		||||
#include "modifiedPclFunctions.hpp"
 | 
			
		||||
 | 
			
		||||
// Logging
 | 
			
		||||
#include "Logger.hpp"
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief The Coords struct     Coordinate class used in recursiveFindCoordinates for OdmTexturing::sortPatches().
 | 
			
		||||
 */
 | 
			
		||||
struct Coords
 | 
			
		||||
{
 | 
			
		||||
    // Coordinates for row and column
 | 
			
		||||
    float r_, c_;
 | 
			
		||||
 | 
			
		||||
    // If coordinates have been placed
 | 
			
		||||
    bool success_;
 | 
			
		||||
 | 
			
		||||
    Coords()
 | 
			
		||||
    {
 | 
			
		||||
        r_ = 0.0;
 | 
			
		||||
        c_ = 0.0;
 | 
			
		||||
        success_ = false;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief The Patch struct      Struct to hold all faces connected and with the same optimal camera.
 | 
			
		||||
 */
 | 
			
		||||
struct Patch
 | 
			
		||||
{
 | 
			
		||||
    std::vector<size_t> faces_;
 | 
			
		||||
    float minu_, minv_, maxu_, maxv_;
 | 
			
		||||
    Coords c_;
 | 
			
		||||
    bool placed_;
 | 
			
		||||
    int materialIndex_;
 | 
			
		||||
    int optimalCameraIndex_;
 | 
			
		||||
 | 
			
		||||
    Patch()
 | 
			
		||||
    {
 | 
			
		||||
        placed_ = false;
 | 
			
		||||
        faces_ = std::vector<size_t>(0);
 | 
			
		||||
        minu_ = std::numeric_limits<double>::infinity();
 | 
			
		||||
        minv_ = std::numeric_limits<double>::infinity();
 | 
			
		||||
        maxu_ = 0.0;
 | 
			
		||||
        maxv_ = 0.0;
 | 
			
		||||
        optimalCameraIndex_ = -1;
 | 
			
		||||
        materialIndex_ = 0;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief The Node struct       Node class for acceleration structure in OdmTexturing::sortPatches().
 | 
			
		||||
 */
 | 
			
		||||
struct Node
 | 
			
		||||
{
 | 
			
		||||
    float r_, c_, width_, height_;
 | 
			
		||||
    bool used_;
 | 
			
		||||
    Node* rgt_;
 | 
			
		||||
    Node* lft_;
 | 
			
		||||
 | 
			
		||||
    Node()
 | 
			
		||||
    {
 | 
			
		||||
        r_ = 0.0;
 | 
			
		||||
        c_ = 0.0;
 | 
			
		||||
        width_ = 1.0;
 | 
			
		||||
        height_ = 1.0;
 | 
			
		||||
        used_ = false;
 | 
			
		||||
        rgt_ = NULL;
 | 
			
		||||
        lft_ = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Node(const Node &n)
 | 
			
		||||
    {
 | 
			
		||||
        r_ = n.r_;
 | 
			
		||||
        c_ = n.c_;
 | 
			
		||||
        used_ = n.used_;
 | 
			
		||||
        width_ = n.width_;
 | 
			
		||||
        height_ = n.height_;
 | 
			
		||||
        rgt_ = n.rgt_;
 | 
			
		||||
        lft_ = n.lft_;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   The OdmTexturing class is used to create textures to a welded ply-mesh using the camera
 | 
			
		||||
 *          positions from pmvs as input. The result is stored in an obj-file with corresponding
 | 
			
		||||
 *          mtl-file and the textures saved as jpg.
 | 
			
		||||
 */
 | 
			
		||||
class OdmTexturing
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    OdmTexturing();
 | 
			
		||||
    ~OdmTexturing();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief   run   Runs the texturing functionality using the provided input arguments.
 | 
			
		||||
     *                For a list of the accepted arguments, please 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:
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief parseArguments    Parses command line arguments.
 | 
			
		||||
     * \param argc              Application argument count.
 | 
			
		||||
     * \param argv              Argument values.
 | 
			
		||||
     */
 | 
			
		||||
    void parseArguments(int argc, char** argv);
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief loadMesh          Loads a PLY-file containing vertices and faces.
 | 
			
		||||
     */
 | 
			
		||||
    void loadMesh();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief loadCameras       Loads cameras from a bundle.out file with corresponding image list file.
 | 
			
		||||
     */
 | 
			
		||||
    void loadCameras();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief triangleToImageAssignment     Assigns optimal camera to faces for the faces that are visible.
 | 
			
		||||
     */
 | 
			
		||||
    void triangleToImageAssignment();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief calculatePatches      Arrange faces into patches as a prestep to arranging UV-mapping.
 | 
			
		||||
     */
 | 
			
		||||
    void calculatePatches();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief recursiveFindCoords   Recursive function used in sortPatches() to find free area to place patch.
 | 
			
		||||
     * \param n                     The container in which to check for free space in.
 | 
			
		||||
     * \param w                     The width of the box to place.
 | 
			
		||||
     * \param h                     The height of the box to place.
 | 
			
		||||
     * \return                      The coordinates where the patch has been placed.
 | 
			
		||||
     */
 | 
			
		||||
    Coords recursiveFindCoords(Node &n, float w, float h);
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief sortPatches       Sorts patches into UV-containers to be used in createTextures() using a rectangle packer approach.
 | 
			
		||||
     */
 | 
			
		||||
    void sortPatches();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief createTextures    Creates textures to the mesh.
 | 
			
		||||
     */
 | 
			
		||||
    void createTextures();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief writeObjFile      Writes the textured mesh to file on the OBJ format.
 | 
			
		||||
     */
 | 
			
		||||
    void writeObjFile();
 | 
			
		||||
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief printHelp         Prints help, explaining usage. Can be shown by calling the program with arguments: "-help".
 | 
			
		||||
     */
 | 
			
		||||
    void printHelp();
 | 
			
		||||
 | 
			
		||||
    Logger log_;                    /**< Logging object. */
 | 
			
		||||
    std::string logFilePath_;       /**< Path to store the log file. */
 | 
			
		||||
 | 
			
		||||
    std::string bundlePath_;        /**< Path to the bundle.out file. */
 | 
			
		||||
    std::string imagesPath_;        /**< Path to the folder with all images in the image list. */
 | 
			
		||||
    std::string imagesListPath_;    /**< Path to the image list. */
 | 
			
		||||
    std::string inputModelPath_;    /**< Path to the ply-file containing the mesh to be textured. */
 | 
			
		||||
    std::string outputFolder_;      /**< Path to the folder to store the output mesh and textures. */
 | 
			
		||||
 | 
			
		||||
    double bundleResizedTo_;        /**< The size used in the previous steps to calculate the camera focal_length. */
 | 
			
		||||
    double textureWithSize_;        /**< The desired size of the images to texture with. */
 | 
			
		||||
    double textureResolution_;      /**< The resolution of each texture. */
 | 
			
		||||
    double padding_;                /**< A padding used to handle edge cases. */
 | 
			
		||||
    int nrTextures_;             /**< The number of textures created. */
 | 
			
		||||
 | 
			
		||||
    pcl::TextureMesh::Ptr mesh_;    /**< PCL Texture Mesh */
 | 
			
		||||
    std::vector<Patch> patches_;    /**< The vector containing all patches */
 | 
			
		||||
    pcl::texture_mapping::CameraVector cameras_;    /**< The vector containing all cameras. */
 | 
			
		||||
    std::vector<int> tTIA_;         /**< The vector containing the optimal cameras for all faces. */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class OdmTexturingException : public std::exception
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    OdmTexturingException() : message("Error in OdmTexturing") {}
 | 
			
		||||
    OdmTexturingException(std::string msgInit) : message("Error in OdmTexturing:\n" + msgInit) {}
 | 
			
		||||
    ~OdmTexturingException() throw() {}
 | 
			
		||||
    virtual const char* what() const throw() {return message.c_str(); }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::string message;        /**< The error message. */
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1,15 +0,0 @@
 | 
			
		|||
// Include texturing source code
 | 
			
		||||
#include "OdmTexturing.hpp"
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * \mainpage main OpenDroneMap Texturing Module
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int main (int argc, char** argv)
 | 
			
		||||
{
 | 
			
		||||
    OdmTexturing textureCreator;
 | 
			
		||||
    return textureCreator.run(argc, argv);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,336 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
* Software License Agreement (BSD License)
 | 
			
		||||
*
 | 
			
		||||
* Point Cloud Library (PCL) - www.pointclouds.org
 | 
			
		||||
* Copyright (c) 2012-, Open Perception, Inc.
 | 
			
		||||
*
 | 
			
		||||
* All rights reserved.
 | 
			
		||||
*
 | 
			
		||||
* Redistribution and use in source and binary forms, with or without
 | 
			
		||||
* modification, are permitted provided that the following conditions
 | 
			
		||||
* are met:
 | 
			
		||||
*
 | 
			
		||||
* * Redistributions of source code must retain the above copyright
 | 
			
		||||
* notice, this list of conditions and the following disclaimer.
 | 
			
		||||
* * Redistributions in binary form must reproduce the above
 | 
			
		||||
* copyright notice, this list of conditions and the following
 | 
			
		||||
* disclaimer in the documentation and/or other materials provided
 | 
			
		||||
* with the distribution.
 | 
			
		||||
* * Neither the name of the copyright holder(s) nor the names of its
 | 
			
		||||
* contributors may be used to endorse or promote products derived
 | 
			
		||||
* from this software without specific prior written permission.
 | 
			
		||||
*
 | 
			
		||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 | 
			
		||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
			
		||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 | 
			
		||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 | 
			
		||||
* POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
*
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "modifiedPclFunctions.hpp"
 | 
			
		||||
 | 
			
		||||
int saveOBJFile(const std::string &file_name, const pcl::TextureMesh &tex_mesh, unsigned precision)
 | 
			
		||||
{
 | 
			
		||||
  if (tex_mesh.cloud.data.empty ())
 | 
			
		||||
  {
 | 
			
		||||
    PCL_ERROR ("[pcl::io::saveOBJFile] Input point cloud has no data!\n");
 | 
			
		||||
    return (-1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Open file
 | 
			
		||||
  std::ofstream fs;
 | 
			
		||||
  fs.precision (precision);
 | 
			
		||||
  fs.open (file_name.c_str ());
 | 
			
		||||
 | 
			
		||||
  // Define material file
 | 
			
		||||
  std::string mtl_file_name = file_name.substr (0, file_name.find_last_of (".")) + ".mtl";
 | 
			
		||||
  // Strip path for "mtllib" command
 | 
			
		||||
  std::string mtl_file_name_nopath = mtl_file_name;
 | 
			
		||||
  //std::cout << mtl_file_name_nopath << std::endl;
 | 
			
		||||
  mtl_file_name_nopath.erase (0, mtl_file_name.find_last_of ('/') + 1);
 | 
			
		||||
 | 
			
		||||
  /* Write 3D information */
 | 
			
		||||
  // number of points
 | 
			
		||||
  int nr_points  = tex_mesh.cloud.width * tex_mesh.cloud.height;
 | 
			
		||||
  int point_size = tex_mesh.cloud.data.size () / nr_points;
 | 
			
		||||
 | 
			
		||||
  // mesh size
 | 
			
		||||
  int nr_meshes = tex_mesh.tex_polygons.size ();
 | 
			
		||||
  // number of faces for header
 | 
			
		||||
  int nr_faces = 0;
 | 
			
		||||
  for (int m = 0; m < nr_meshes; ++m)
 | 
			
		||||
    nr_faces += tex_mesh.tex_polygons[m].size ();
 | 
			
		||||
 | 
			
		||||
  // Write the header information
 | 
			
		||||
  fs << "####" << std::endl;
 | 
			
		||||
  fs << "# OBJ dataFile simple version. File name: " << file_name << std::endl;
 | 
			
		||||
  fs << "# Vertices: " << nr_points << std::endl;
 | 
			
		||||
  fs << "# Faces: " <<nr_faces << std::endl;
 | 
			
		||||
  fs << "# Material information:" << std::endl;
 | 
			
		||||
  fs << "mtllib " << mtl_file_name_nopath << std::endl;
 | 
			
		||||
  fs << "####" << std::endl;
 | 
			
		||||
 | 
			
		||||
  // Write vertex coordinates
 | 
			
		||||
  fs << "# Vertices" << std::endl;
 | 
			
		||||
  for (int i = 0; i < nr_points; ++i)
 | 
			
		||||
  {
 | 
			
		||||
    int xyz = 0;
 | 
			
		||||
    // "v" just be written one
 | 
			
		||||
    bool v_written = false;
 | 
			
		||||
    for (size_t d = 0; d < tex_mesh.cloud.fields.size (); ++d)
 | 
			
		||||
    {
 | 
			
		||||
      int count = tex_mesh.cloud.fields[d].count;
 | 
			
		||||
      if (count == 0)
 | 
			
		||||
        count = 1;          // we simply cannot tolerate 0 counts (coming from older converter code)
 | 
			
		||||
      int c = 0;
 | 
			
		||||
      // adding vertex
 | 
			
		||||
      if ((tex_mesh.cloud.fields[d].datatype == pcl::PCLPointField::FLOAT32) /*sensor_msgs::PointField::FLOAT32)*/ && (
 | 
			
		||||
                tex_mesh.cloud.fields[d].name == "x" ||
 | 
			
		||||
                tex_mesh.cloud.fields[d].name == "y" ||
 | 
			
		||||
                tex_mesh.cloud.fields[d].name == "z"))
 | 
			
		||||
      {
 | 
			
		||||
        if (!v_written)
 | 
			
		||||
        {
 | 
			
		||||
            // write vertices beginning with v
 | 
			
		||||
            fs << "v ";
 | 
			
		||||
            v_written = true;
 | 
			
		||||
        }
 | 
			
		||||
        float value;
 | 
			
		||||
        memcpy (&value, &tex_mesh.cloud.data[i * point_size + tex_mesh.cloud.fields[d].offset + c * sizeof (float)], sizeof (float));
 | 
			
		||||
        fs << value;
 | 
			
		||||
        if (++xyz == 3)
 | 
			
		||||
            break;
 | 
			
		||||
        fs << " ";
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (xyz != 3)
 | 
			
		||||
    {
 | 
			
		||||
      PCL_ERROR ("[pcl::io::saveOBJFile] Input point cloud has no XYZ data!\n");
 | 
			
		||||
      return (-2);
 | 
			
		||||
    }
 | 
			
		||||
    fs << std::endl;
 | 
			
		||||
  }
 | 
			
		||||
  fs << "# "<< nr_points <<" vertices" << std::endl;
 | 
			
		||||
 | 
			
		||||
//  // Write vertex normals
 | 
			
		||||
//  for (int i = 0; i < nr_points; ++i)
 | 
			
		||||
//  {
 | 
			
		||||
//    int xyz = 0;
 | 
			
		||||
//    // "vn" just be written one
 | 
			
		||||
//    bool v_written = false;
 | 
			
		||||
//    for (size_t d = 0; d < tex_mesh.cloud.fields.size (); ++d)
 | 
			
		||||
//    {
 | 
			
		||||
//      int count = tex_mesh.cloud.fields[d].count;
 | 
			
		||||
//      if (count == 0)
 | 
			
		||||
//      count = 1;          // we simply cannot tolerate 0 counts (coming from older converter code)
 | 
			
		||||
//      int c = 0;
 | 
			
		||||
//      // adding vertex
 | 
			
		||||
//      if ((tex_mesh.cloud.fields[d].datatype == pcl::PCLPointField::FLOAT32) && (
 | 
			
		||||
//      tex_mesh.cloud.fields[d].name == "normal_x" ||
 | 
			
		||||
//      tex_mesh.cloud.fields[d].name == "normal_y" ||
 | 
			
		||||
//      tex_mesh.cloud.fields[d].name == "normal_z"))
 | 
			
		||||
//      {
 | 
			
		||||
//        if (!v_written)
 | 
			
		||||
//        {
 | 
			
		||||
//          // write vertices beginning with vn
 | 
			
		||||
//          fs << "vn ";
 | 
			
		||||
//          v_written = true;
 | 
			
		||||
//        }
 | 
			
		||||
//        float value;
 | 
			
		||||
//        memcpy (&value, &tex_mesh.cloud.data[i * point_size + tex_mesh.cloud.fields[d].offset + c * sizeof (float)], sizeof (float));
 | 
			
		||||
//        fs << value;
 | 
			
		||||
//        if (++xyz == 3)
 | 
			
		||||
//          break;
 | 
			
		||||
//        fs << " ";
 | 
			
		||||
//      }
 | 
			
		||||
//    }
 | 
			
		||||
//    if (xyz != 3)
 | 
			
		||||
//    {
 | 
			
		||||
//    //PCL_ERROR ("[pcl::io::saveOBJFile] Input point cloud has no normals!\n");
 | 
			
		||||
//    //return (-2);
 | 
			
		||||
//    }
 | 
			
		||||
//    fs << std::endl;
 | 
			
		||||
//  }
 | 
			
		||||
  // Write vertex texture with "vt" (adding latter)
 | 
			
		||||
 | 
			
		||||
  for (int m = 0; m < nr_meshes; ++m)
 | 
			
		||||
  {
 | 
			
		||||
    if(tex_mesh.tex_coordinates.size() == 0)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    //PCL_INFO ("%d vertex textures in submesh %d\n", tex_mesh.tex_coordinates[m].size (), m);
 | 
			
		||||
    fs << "# " << tex_mesh.tex_coordinates[m].size() << " vertex textures in submesh " << m <<  std::endl;
 | 
			
		||||
    for (size_t i = 0; i < tex_mesh.tex_coordinates[m].size (); ++i)
 | 
			
		||||
    {
 | 
			
		||||
      fs << "vt ";
 | 
			
		||||
      fs <<  tex_mesh.tex_coordinates[m][i][0] << " " << tex_mesh.tex_coordinates[m][i][1] << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int f_idx = 0;
 | 
			
		||||
 | 
			
		||||
  // int idx_vt =0;
 | 
			
		||||
  //PCL_INFO ("Writting faces...\n");
 | 
			
		||||
  for (int m = 0; m < nr_meshes; ++m)
 | 
			
		||||
  {
 | 
			
		||||
    if (m > 0)
 | 
			
		||||
      f_idx += tex_mesh.tex_polygons[m-1].size ();
 | 
			
		||||
 | 
			
		||||
    if(tex_mesh.tex_materials.size() !=0)
 | 
			
		||||
    {
 | 
			
		||||
      fs << "# The material will be used for mesh " << m << std::endl;
 | 
			
		||||
      //TODO pbl here with multi texture and unseen faces
 | 
			
		||||
      fs << "usemtl " <<  tex_mesh.tex_materials[m].tex_name << std::endl;
 | 
			
		||||
      fs << "# Faces" << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    for (size_t i = 0; i < tex_mesh.tex_polygons[m].size(); ++i)
 | 
			
		||||
    {
 | 
			
		||||
      // Write faces with "f"
 | 
			
		||||
      fs << "f";
 | 
			
		||||
      size_t j = 0;
 | 
			
		||||
      // There's one UV per vertex per face, i.e., the same vertex can have
 | 
			
		||||
      // different UV depending on the face.
 | 
			
		||||
      for (j = 0; j < tex_mesh.tex_polygons[m][i].vertices.size (); ++j)
 | 
			
		||||
      {
 | 
			
		||||
        unsigned int idx = tex_mesh.tex_polygons[m][i].vertices[j] + 1;
 | 
			
		||||
        fs << " " << idx
 | 
			
		||||
        << "/" << 3*(i+f_idx) +j+1;
 | 
			
		||||
        //<< "/" << idx; // vertex index in obj file format starting with 1
 | 
			
		||||
      }
 | 
			
		||||
      fs << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    //PCL_INFO ("%d faces in mesh %d \n", tex_mesh.tex_polygons[m].size () , m);
 | 
			
		||||
    fs << "# "<< tex_mesh.tex_polygons[m].size() << " faces in mesh " << m << std::endl;
 | 
			
		||||
  }
 | 
			
		||||
  fs << "# End of File";
 | 
			
		||||
 | 
			
		||||
  // Close obj file
 | 
			
		||||
  //PCL_INFO ("Closing obj file\n");
 | 
			
		||||
  fs.close ();
 | 
			
		||||
 | 
			
		||||
  /* Write material defination for OBJ file*/
 | 
			
		||||
  // Open file
 | 
			
		||||
  //PCL_INFO ("Writing material files\n");
 | 
			
		||||
  //dont do it if no material to write
 | 
			
		||||
  if(tex_mesh.tex_materials.size() ==0)
 | 
			
		||||
    return (0);
 | 
			
		||||
 | 
			
		||||
  std::ofstream m_fs;
 | 
			
		||||
  m_fs.precision (precision);
 | 
			
		||||
  m_fs.open (mtl_file_name.c_str ());
 | 
			
		||||
  //std::cout << "MTL file is located at_ " << mtl_file_name << std::endl;
 | 
			
		||||
  // default
 | 
			
		||||
  m_fs << "#" << std::endl;
 | 
			
		||||
  m_fs << "# Wavefront material file" << std::endl;
 | 
			
		||||
  m_fs << "#" << std::endl;
 | 
			
		||||
  for(int m = 0; m < nr_meshes; ++m)
 | 
			
		||||
  {
 | 
			
		||||
    m_fs << "newmtl " << tex_mesh.tex_materials[m].tex_name << std::endl;
 | 
			
		||||
    m_fs << "Ka "<< tex_mesh.tex_materials[m].tex_Ka.r << " " << tex_mesh.tex_materials[m].tex_Ka.g << " " << tex_mesh.tex_materials[m].tex_Ka.b << std::endl; // defines the ambient color of the material to be (r,g,b).
 | 
			
		||||
    m_fs << "Kd "<< tex_mesh.tex_materials[m].tex_Kd.r << " " << tex_mesh.tex_materials[m].tex_Kd.g << " " << tex_mesh.tex_materials[m].tex_Kd.b << std::endl; // defines the diffuse color of the material to be (r,g,b).
 | 
			
		||||
    m_fs << "Ks "<< tex_mesh.tex_materials[m].tex_Ks.r << " " << tex_mesh.tex_materials[m].tex_Ks.g << " " << tex_mesh.tex_materials[m].tex_Ks.b << std::endl; // defines the specular color of the material to be (r,g,b). This color shows up in highlights.
 | 
			
		||||
    m_fs << "d " << tex_mesh.tex_materials[m].tex_d << std::endl; // defines the transparency of the material to be alpha.
 | 
			
		||||
    m_fs << "Ns "<< tex_mesh.tex_materials[m].tex_Ns  << std::endl; // defines the shininess of the material to be s.
 | 
			
		||||
    m_fs << "illum "<< tex_mesh.tex_materials[m].tex_illum << std::endl; // denotes the illumination model used by the material.
 | 
			
		||||
    // illum = 1 indicates a flat material with no specular highlights, so the value of Ks is not used.
 | 
			
		||||
    // illum = 2 denotes the presence of specular highlights, and so a specification for Ks is required.
 | 
			
		||||
    m_fs << "map_Kd " << tex_mesh.tex_materials[m].tex_file << std::endl;
 | 
			
		||||
    m_fs << "###" << std::endl;
 | 
			
		||||
  }
 | 
			
		||||
  m_fs.close ();
 | 
			
		||||
  return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool getPixelCoordinates(const pcl::PointXYZ &pt, const pcl::TextureMapping<pcl::PointXYZ>::Camera &cam, pcl::PointXY &UV_coordinates)
 | 
			
		||||
{
 | 
			
		||||
    if (pt.z > 0)
 | 
			
		||||
    {
 | 
			
		||||
        // compute image center and dimension
 | 
			
		||||
        double sizeX = cam.width;
 | 
			
		||||
        double sizeY = cam.height;
 | 
			
		||||
        double cx, cy;
 | 
			
		||||
        if (cam.center_w > 0)
 | 
			
		||||
            cx = cam.center_w;
 | 
			
		||||
        else
 | 
			
		||||
            cx = sizeX / 2.0;
 | 
			
		||||
        if (cam.center_h > 0)
 | 
			
		||||
            cy = cam.center_h;
 | 
			
		||||
        else
 | 
			
		||||
            cy = sizeY / 2.0;
 | 
			
		||||
 | 
			
		||||
        double focal_x, focal_y;
 | 
			
		||||
        if (cam.focal_length_w > 0)
 | 
			
		||||
            focal_x = cam.focal_length_w;
 | 
			
		||||
        else
 | 
			
		||||
            focal_x = cam.focal_length;
 | 
			
		||||
        if (cam.focal_length_h > 0)
 | 
			
		||||
            focal_y = cam.focal_length_h;
 | 
			
		||||
        else
 | 
			
		||||
            focal_y = cam.focal_length;
 | 
			
		||||
 | 
			
		||||
        // project point on camera's image plane
 | 
			
		||||
        UV_coordinates.x = static_cast<float> ((focal_x * (pt.x / pt.z) + cx)); //horizontal
 | 
			
		||||
        UV_coordinates.y = static_cast<float> ((focal_y * (pt.y / pt.z) + cy)); //vertical
 | 
			
		||||
 | 
			
		||||
        // point is visible!
 | 
			
		||||
        if (UV_coordinates.x >= 15.0 && UV_coordinates.x <= (sizeX - 15.0) && UV_coordinates.y >= 15.0 && UV_coordinates.y <= (sizeY - 15.0))
 | 
			
		||||
        {
 | 
			
		||||
            return (true); // point was visible by the camera
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // point is NOT visible by the camera
 | 
			
		||||
    UV_coordinates.x = -1.0f;
 | 
			
		||||
    UV_coordinates.y = -1.0f;
 | 
			
		||||
    return (false); // point was not visible by the camera
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool isFaceProjected (const pcl::TextureMapping<pcl::PointXYZ>::Camera &camera, const pcl::PointXYZ &p1, const pcl::PointXYZ &p2, const pcl::PointXYZ &p3, pcl::PointXY &proj1, pcl::PointXY &proj2, pcl::PointXY &proj3)
 | 
			
		||||
{
 | 
			
		||||
    return (getPixelCoordinates(p1, camera, proj1) && getPixelCoordinates(p2, camera, proj2) && getPixelCoordinates(p3, camera, proj3));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void getTriangleCircumscribedCircleCentroid( const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, pcl::PointXY &circumcenter, double &radius)
 | 
			
		||||
{
 | 
			
		||||
 // compute centroid's coordinates (translate back to original coordinates)
 | 
			
		||||
 circumcenter.x = static_cast<float> (p1.x + p2.x + p3.x ) / 3;
 | 
			
		||||
 circumcenter.y = static_cast<float> (p1.y + p2.y + p3.y ) / 3;
 | 
			
		||||
 double r1 = (circumcenter.x - p1.x) * (circumcenter.x - p1.x) + (circumcenter.y - p1.y) * (circumcenter.y - p1.y) ;
 | 
			
		||||
 double r2 = (circumcenter.x - p2.x) * (circumcenter.x - p2.x) + (circumcenter.y - p2.y) * (circumcenter.y - p2.y) ;
 | 
			
		||||
 double r3 = (circumcenter.x - p3.x) * (circumcenter.x - p3.x) + (circumcenter.y - p3.y) * (circumcenter.y - p3.y) ;
 | 
			
		||||
 | 
			
		||||
 // radius
 | 
			
		||||
 radius = std::sqrt( std::max( r1, std::max( r2, r3) )) ;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool checkPointInsideTriangle(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, const pcl::PointXY &pt)
 | 
			
		||||
{
 | 
			
		||||
    // Compute vectors
 | 
			
		||||
    Eigen::Vector2d v0, v1, v2;
 | 
			
		||||
    v0(0) = p3.x - p1.x; v0(1) = p3.y - p1.y; // v0= C - A
 | 
			
		||||
    v1(0) = p2.x - p1.x; v1(1) = p2.y - p1.y; // v1= B - A
 | 
			
		||||
    v2(0) = pt.x - p1.x; v2(1) = pt.y - p1.y; // v2= P - A
 | 
			
		||||
 | 
			
		||||
    // Compute dot products
 | 
			
		||||
    double dot00 = v0.dot(v0); // dot00 = dot(v0, v0)
 | 
			
		||||
    double dot01 = v0.dot(v1); // dot01 = dot(v0, v1)
 | 
			
		||||
    double dot02 = v0.dot(v2); // dot02 = dot(v0, v2)
 | 
			
		||||
    double dot11 = v1.dot(v1); // dot11 = dot(v1, v1)
 | 
			
		||||
    double dot12 = v1.dot(v2); // dot12 = dot(v1, v2)
 | 
			
		||||
 | 
			
		||||
    // Compute barycentric coordinates
 | 
			
		||||
    double invDenom = 1.0 / (dot00*dot11 - dot01*dot01);
 | 
			
		||||
    double u = (dot11*dot02 - dot01*dot12) * invDenom;
 | 
			
		||||
    double v = (dot00*dot12 - dot01*dot02) * invDenom;
 | 
			
		||||
 | 
			
		||||
    // Check if point is in triangle
 | 
			
		||||
    return ((u >= 0) && (v >= 0) && (u + v < 1));
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,20 +0,0 @@
 | 
			
		|||
#pragma once
 | 
			
		||||
 | 
			
		||||
// STL
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
 | 
			
		||||
// PCL
 | 
			
		||||
#include <pcl/point_types.h>
 | 
			
		||||
#include <pcl/surface/texture_mapping.h>
 | 
			
		||||
#include <pcl/io/ply_io.h>
 | 
			
		||||
 | 
			
		||||
int saveOBJFile(const std::string &file_name, const pcl::TextureMesh &tex_mesh, unsigned precision);
 | 
			
		||||
 | 
			
		||||
bool getPixelCoordinates(const pcl::PointXYZ &pt, const pcl::TextureMapping<pcl::PointXYZ>::Camera &cam, pcl::PointXY &UV_coordinates);
 | 
			
		||||
 | 
			
		||||
bool isFaceProjected (const pcl::TextureMapping<pcl::PointXYZ>::Camera &camera, const pcl::PointXYZ &p1, const pcl::PointXYZ &p2, const pcl::PointXYZ &p3, pcl::PointXY &proj1, pcl::PointXY &proj2, pcl::PointXY &proj3);
 | 
			
		||||
 | 
			
		||||
void getTriangleCircumscribedCircleCentroid(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, pcl::PointXY &circumcenter, double &radius);
 | 
			
		||||
 | 
			
		||||
bool checkPointInsideTriangle(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, const pcl::PointXY &pt);
 | 
			
		||||
| 
						 | 
				
			
			@ -69,8 +69,7 @@ class ODMApp(ecto.BlackBox):
 | 
			
		|||
                                            skip_hole_fill=p.args.texturing_skip_hole_filling,
 | 
			
		||||
                                            keep_unseen_faces=p.args.texturing_keep_unseen_faces,
 | 
			
		||||
                                            tone_mapping=p.args.texturing_tone_mapping),
 | 
			
		||||
                 'georeferencing': ODMGeoreferencingCell(img_size=p.args.resize_to,
 | 
			
		||||
                                                         gcp_file=p.args.gcp,
 | 
			
		||||
                 'georeferencing': ODMGeoreferencingCell(gcp_file=p.args.gcp,
 | 
			
		||||
                                                         use_exif=p.args.use_exif,
 | 
			
		||||
                                                         verbose=p.args.verbose),
 | 
			
		||||
                 'dem': ODMDEMCell(verbose=p.args.verbose),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,6 @@ class ODMGeoreferencingCell(ecto.Cell):
 | 
			
		|||
                            'points used for georeferencing.The file needs to '
 | 
			
		||||
                            'be on the following line format: \neasting '
 | 
			
		||||
                            'northing height pixelrow pixelcol imagename', 'gcp_list.txt')
 | 
			
		||||
        params.declare("img_size", 'image size used in calibration', 2400)
 | 
			
		||||
        params.declare("use_exif", 'use exif', False)
 | 
			
		||||
        params.declare("verbose", 'print additional messages to console', False)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +121,6 @@ class ODMGeoreferencingCell(ecto.Cell):
 | 
			
		|||
                    'pc_geo': odm_georeferencing_model_ply_geo,
 | 
			
		||||
                    'geo_sys': os.path.join(r['georeferencing_dir'], tree.odm_georeferencing_model_txt_geo),
 | 
			
		||||
                    'model_geo': odm_georeferencing_model_obj_geo,
 | 
			
		||||
                    'size': self.params.img_size,
 | 
			
		||||
                    'gcp': gcpfile,
 | 
			
		||||
                    'verbose': verbose
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -138,7 +136,7 @@ class ODMGeoreferencingCell(ecto.Cell):
 | 
			
		|||
                    log.ODM_INFO('Found %s' % gcpfile)
 | 
			
		||||
                    try:
 | 
			
		||||
                        system.run('{bin}/odm_georef -bundleFile {bundle} -imagesPath {imgs} -imagesListPath {imgs_list} '
 | 
			
		||||
                                   '-bundleResizedTo {size} -inputFile {model} -outputFile {model_geo} '
 | 
			
		||||
                                   '-inputFile {model} -outputFile {model_geo} '
 | 
			
		||||
                                   '-inputPointCloudFile {pc} -outputPointCloudFile {pc_geo} {verbose} '
 | 
			
		||||
                                   '-logFile {log} -outputTransformFile {transform_file} -georefFileOutputPath {geo_sys} -gcpFile {gcp} '
 | 
			
		||||
                                   '-outputCoordFile {coords}'.format(**kwargs))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue