diff --git a/src/asp/Camera/BundleAdjustCamera.h b/src/asp/Camera/BundleAdjustCamera.h index fd795211e..c023d38a5 100644 --- a/src/asp/Camera/BundleAdjustCamera.h +++ b/src/asp/Camera/BundleAdjustCamera.h @@ -83,14 +83,17 @@ struct BaBaseOptions: public vw::GdalWriteOptions { ip_edge_buffer_percent, max_num_reference_points, num_passes; bool have_overlap_list; std::set> overlap_list; - std::string overlap_list_file, auto_overlap_params, datum_str, proj_str; + std::string overlap_list_file, auto_overlap_params, datum_str, proj_str, + csv_format_str, csv_srs, csv_proj4_str, disparity_list; bool match_first_to_last, single_threaded_cameras, update_isis_cubes_with_csm_state; - double min_triangulation_angle, max_init_reproj_error, robust_threshold, parameter_tolerance; + double forced_triangulation_distance, min_triangulation_angle, max_init_reproj_error, + robust_threshold, parameter_tolerance; double heights_from_dem_uncertainty, reference_terrain_weight, heights_from_dem_robust_threshold, camera_weight, rotation_weight, camera_position_weight, camera_position_robust_threshold, - tri_weight, tri_robust_threshold, camera_position_uncertainty_power; + tri_weight, tri_robust_threshold, camera_position_uncertainty_power, + max_disp_error; std::vector camera_position_uncertainty; vw::Vector remove_outliers_params; BACameraType camera_type; @@ -100,16 +103,18 @@ struct BaBaseOptions: public vw::GdalWriteOptions { vw::cartography::Datum datum; vw::BBox2 proj_win; // Limit input triangulated points to this projwin - BaBaseOptions(): min_triangulation_angle(0.0), camera_position_weight(0.0), - camera_position_robust_threshold(0.0), camera_weight(-1.0), - rotation_weight(0.0), tri_weight(0.0), - robust_threshold(0.0), min_matches(0), - num_iterations(0), num_passes(0), - overlap_limit(0), have_overlap_list(false), - camera_type(BaCameraType_Other), max_num_reference_points(-1), - datum(vw::cartography::Datum(asp::UNSPECIFIED_DATUM, - "User Specified Spheroid", - "Reference Meridian", 1, 1, 0)) {} + BaBaseOptions(): + forced_triangulation_distance(-1), + min_triangulation_angle(0.0), camera_position_weight(0.0), + camera_position_robust_threshold(0.0), camera_weight(-1.0), + rotation_weight(0.0), tri_weight(0.0), + robust_threshold(0.0), min_matches(0), + num_iterations(0), num_passes(0), + overlap_limit(0), have_overlap_list(false), + camera_type(BaCameraType_Other), max_num_reference_points(-1), + datum(vw::cartography::Datum(asp::UNSPECIFIED_DATUM, + "User Specified Spheroid", + "Reference Meridian", 1, 1, 0)) {} }; // A structure to hold percentiles of given sorted values. This sorts the inputs. diff --git a/src/asp/Camera/BundleAdjustCostFuns.cc b/src/asp/Camera/BundleAdjustCostFuns.cc index c9c1a69b4..efb071948 100644 --- a/src/asp/Camera/BundleAdjustCostFuns.cc +++ b/src/asp/Camera/BundleAdjustCostFuns.cc @@ -662,8 +662,10 @@ void add_disparity_residual_block(vw::Vector3 const& reference_xyz, residual_ptrs); if (opt.camera_type == asp::BaCameraType_Other) { - boost::shared_ptr left_wrapper (new AdjustedCameraBundleModel(left_camera_model )); - boost::shared_ptr right_wrapper(new AdjustedCameraBundleModel(right_camera_model)); + boost::shared_ptr + left_wrapper (new AdjustedCameraBundleModel(left_camera_model)); + boost::shared_ptr + right_wrapper(new AdjustedCameraBundleModel(right_camera_model)); ceres::CostFunction* cost_function = BaDispXyzError::Create(opt.max_disp_error, opt.reference_terrain_weight, reference_xyz, interp_disp, left_wrapper, right_wrapper, @@ -913,7 +915,7 @@ void addTriConstraint(asp::BaOptions const& opt, // stereo with the option --unalign-disparity. If there are n images, there must // be n-1 disparities, from each image to the next. void addReferenceTerrainCostFunction( - asp::BaOptions & opt, + asp::BaOptions & opt, asp::BAParams & param_storage, ceres::Problem & problem, std::vector & reference_vec, @@ -1010,7 +1012,7 @@ void addReferenceTerrainCostFunction( // Call function to select the appropriate Ceres residual block to add. add_disparity_residual_block(reference_xyz, interp_disp[icam], - icam, icam+1, // left icam and right icam + icam, icam + 1, // left icam and right icam param_storage, opt, problem); } tpc.report_incremental_progress(inc_amount); diff --git a/src/asp/Camera/BundleAdjustCostFuns.h b/src/asp/Camera/BundleAdjustCostFuns.h index c447f3294..9591c82f5 100644 --- a/src/asp/Camera/BundleAdjustCostFuns.h +++ b/src/asp/Camera/BundleAdjustCostFuns.h @@ -433,22 +433,6 @@ struct RotTransError { /// From the input options select the correct Ceres loss function. ceres::LossFunction* get_loss_function(std::string const& cost_function, double th); -/// Add error source for projecting a 3D point into the camera. -void add_reprojection_residual_block(vw::Vector2 const& observation, - vw::Vector2 const& pixel_sigma, - int point_index, int camera_index, - asp::BAParams & param_storage, - asp::BaOptions const& opt, - ceres::Problem & problem); - -/// Add residual block for the error using reference xyz. -void add_disparity_residual_block(vw::Vector3 const& reference_xyz, - vw::ImageViewRef const& interp_disp, - int left_cam_index, int right_cam_index, - asp::BAParams & param_storage, - asp::BaOptions const& opt, - ceres::Problem & problem); - // Pixel reprojection error. Note: cam_residual_counts and num_pixels_per_cam // serve different purposes. void addPixelReprojCostFun(asp::BaOptions const& opt, diff --git a/src/asp/Camera/BundleAdjustOptions.h b/src/asp/Camera/BundleAdjustOptions.h index 4c80ceeb1..c6b2a2760 100644 --- a/src/asp/Camera/BundleAdjustOptions.h +++ b/src/asp/Camera/BundleAdjustOptions.h @@ -31,7 +31,7 @@ struct BaOptions: public asp::BaBaseOptions { std::string cnet_file, vwip_prefix, cost_function, mapprojected_data, gcp_from_mapprojected; int ip_per_tile, ip_per_image, matches_per_tile; - double forced_triangulation_distance, overlap_exponent, ip_triangulation_max_error; + double overlap_exponent, ip_triangulation_max_error; int instance_count, instance_index, num_random_passes, ip_num_ransac_iterations; bool save_intermediate_cameras, approximate_pinhole_intrinsics, init_camera_using_gcp, disable_pinhole_gcp_init, @@ -40,7 +40,7 @@ struct BaOptions: public asp::BaBaseOptions { ip_normalize_tiles, ip_debug_images, stop_after_stats, stop_after_matching, skip_matching, apply_initial_transform_only, save_vwip, propagate_errors; std::string camera_position_file, initial_transform_file, - csv_format_str, csv_srs, csv_proj4_str, disparity_list, + dem_file_for_overlap; double semi_major, semi_minor, position_filter_dist; std::string remove_outliers_params_str; @@ -48,7 +48,7 @@ struct BaOptions: public asp::BaBaseOptions { boost::shared_ptr cnet; int ip_detect_method, num_scales; double epipolar_threshold; // Max distance from epipolar line to search for IP matches. - double ip_inlier_factor, ip_uniqueness_thresh, nodata_value, max_disp_error, + double ip_inlier_factor, ip_uniqueness_thresh, nodata_value, auto_overlap_buffer, pct_for_overlap, min_distortion; bool skip_rough_homography, enable_rough_homography, disable_tri_filtering, enable_tri_filtering, no_datum, individually_normalize, use_llh_error, @@ -56,7 +56,7 @@ struct BaOptions: public asp::BaBaseOptions { vw::Vector2 elevation_limit; // Expected range of elevation to limit results to. vw::BBox2 lon_lat_limit; // Limit the triangulated interest points to this lonlat range vw::Matrix initial_transform; - std::string fixed_cameras_indices_str, flann_method; + std::string fixed_cameras_indices_str, flann_method; std::set fixed_cameras_indices; asp::IntrinsicOptions intrinsics_options; vw::Vector2i matches_per_tile_params; @@ -66,7 +66,7 @@ struct BaOptions: public asp::BaBaseOptions { // Make sure all values are initialized, even though they will be // over-written later. BaOptions(): ip_per_tile(0), ip_per_image(0), - forced_triangulation_distance(-1), overlap_exponent(0), + overlap_exponent(0), save_intermediate_cameras(false), fix_gcp_xyz(false), solve_intrinsics(false), semi_major(0), semi_minor(0), position_filter_dist(-1), diff --git a/src/asp/Tools/bundle_adjust.cc b/src/asp/Tools/bundle_adjust.cc index fd2199b87..863139e82 100644 --- a/src/asp/Tools/bundle_adjust.cc +++ b/src/asp/Tools/bundle_adjust.cc @@ -1770,15 +1770,15 @@ void handle_arguments(int argc, char *argv[], asp::BaOptions& opt) { if (opt.reference_terrain != "") { std::string file_type = asp::get_cloud_type(opt.reference_terrain); if (file_type == "DEM") { - // TODO(oalexan1): What if a different planet is specified in the images? vw::cartography::GeoReference georef; bool is_good = vw::cartography::read_georeference(georef, opt.reference_terrain); if (!is_good) vw_throw(ArgumentErr() << "The reference terrain DEM does not have a georeference.\n"); + // Ensure the datum read from the DEM agrees with the one from the cameras/user if (is_good && have_datum) vw::checkDatumConsistency(opt.datum, georef.datum(), warn_only); - if (opt.datum_str == ""){ + if (opt.datum_str == "") { opt.datum = georef.datum(); opt.datum_str = opt.datum.name(); have_datum = true; diff --git a/src/asp/Tools/jitter_solve.cc b/src/asp/Tools/jitter_solve.cc index 38871d013..1f8026918 100644 --- a/src/asp/Tools/jitter_solve.cc +++ b/src/asp/Tools/jitter_solve.cc @@ -77,7 +77,6 @@ struct Options: public asp::BaBaseOptions { use_initial_rig_transforms; double quat_norm_weight, anchor_weight, roll_weight, yaw_weight; std::map cam2group; - double forced_triangulation_distance; }; void handle_arguments(int argc, char *argv[], Options& opt, rig::RigSet & rig) {