From 7586b96ea585625efb4bb8b46dfc145358961415 Mon Sep 17 00:00:00 2001 From: Matt Leotta Date: Mon, 30 Aug 2010 22:16:38 -0400 Subject: [PATCH] Renamed modrec to dml. --- CMakeLists.txt | 2 +- cmd/CMakeLists.txt | 12 +- cmd/fit_mesh_body.cxx | 8 +- cmd/fit_parts.cxx | 10 +- cmd/make_vehicle_mesh.cxx | 10 +- cmd/mesh_extract_features.cxx | 6 +- cmd/parts2svg.cxx | 6 +- cmd/parts_pca.cxx | 10 +- dml/CMakeLists.txt | 70 +++++++ modrec/modrec_edgel.cxx => dml/dml_edgel.cxx | 30 +-- modrec/modrec_edgel.h => dml/dml_edgel.h | 32 +-- .../dml_pca_vehicle.cxx | 74 +++---- .../dml_pca_vehicle.h | 40 ++-- .../dml_pca_vehicle_projector.cxx | 90 ++++----- .../dml_pca_vehicle_projector.h | 46 ++--- .../dml_proj_cost_func.cxx | 34 ++-- .../dml_proj_cost_func.h | 34 ++-- .../dml_proj_lsqr_cost_func.cxx | 18 +- .../dml_proj_lsqr_cost_func.h | 20 +- .../dml_solar_position.cxx | 10 +- .../dml_solar_position.h | 14 +- .../dml_vehicle_fit.cxx | 86 ++++---- .../dml_vehicle_fit.h | 46 ++--- .../dml_vehicle_fit.py | 188 +++++++++--------- .../dml_vehicle_fit_multiview.cxx | 62 +++--- .../dml_vehicle_fit_multiview.h | 24 +-- .../dml_vehicle_fit_video.cxx | 93 ++++----- .../dml_vehicle_fit_video.h | 46 ++--- .../dml_vehicle_mesh.cxx | 74 +++---- .../dml_vehicle_mesh.h | 46 ++--- .../dml_vehicle_parts.cxx | 14 +- .../dml_vehicle_parts.h | 18 +- .../dml_vehicle_state.cxx | 28 +-- .../dml_vehicle_state.h | 36 ++-- .../dml_vehicle_track_init.cxx | 46 ++--- .../dml_vehicle_track_init.h | 30 +-- .../dml_vehicle_tracker.cxx | 90 ++++----- .../dml_vehicle_tracker.h | 18 +- modrec/py_modrec.cxx => dml/py_dml.cxx | 104 +++++----- .../py_dml_manager.cxx | 148 +++++++------- .../py_dml_manager.h | 44 ++-- dml/tests/CMakeLists.txt | 22 ++ {modrec => dml}/tests/test_driver.cxx | 0 dml/tests/test_include.cxx | 23 +++ {modrec => dml}/tests/test_solar_position.cxx | 20 +- gui/CMakeLists.txt | 2 +- gui/pca_vehicle_frame.cxx | 4 +- gui/pca_vehicle_manager.cxx | 66 +++--- gui/pca_vehicle_manager.h | 38 ++-- modrec/CMakeLists.txt | 70 ------- modrec/tests/CMakeLists.txt | 22 -- modrec/tests/test_include.cxx | 23 --- 52 files changed, 1056 insertions(+), 1051 deletions(-) create mode 100644 dml/CMakeLists.txt rename modrec/modrec_edgel.cxx => dml/dml_edgel.cxx (78%) rename modrec/modrec_edgel.h => dml/dml_edgel.h (70%) rename modrec/modrec_pca_vehicle.cxx => dml/dml_pca_vehicle.cxx (85%) rename modrec/modrec_pca_vehicle.h => dml/dml_pca_vehicle.h (82%) rename modrec/modrec_pca_vehicle_projector.cxx => dml/dml_pca_vehicle_projector.cxx (96%) rename modrec/modrec_pca_vehicle_projector.h => dml/dml_pca_vehicle_projector.h (90%) rename modrec/modrec_proj_cost_func.cxx => dml/dml_proj_cost_func.cxx (81%) rename modrec/modrec_proj_cost_func.h => dml/dml_proj_cost_func.h (63%) rename modrec/modrec_proj_lsqr_cost_func.cxx => dml/dml_proj_lsqr_cost_func.cxx (72%) rename modrec/modrec_proj_lsqr_cost_func.h => dml/dml_proj_lsqr_cost_func.h (67%) rename modrec/modrec_solar_position.cxx => dml/dml_solar_position.cxx (91%) rename modrec/modrec_solar_position.h => dml/dml_solar_position.h (78%) rename modrec/modrec_vehicle_fit.cxx => dml/dml_vehicle_fit.cxx (90%) rename modrec/modrec_vehicle_fit.h => dml/dml_vehicle_fit.h (89%) rename modrec/modrec_vehicle_fit.py => dml/dml_vehicle_fit.py (80%) rename modrec/modrec_vehicle_fit_multiview.cxx => dml/dml_vehicle_fit_multiview.cxx (77%) rename modrec/modrec_vehicle_fit_multiview.h => dml/dml_vehicle_fit_multiview.h (86%) rename modrec/modrec_vehicle_fit_video.cxx => dml/dml_vehicle_fit_video.cxx (92%) rename modrec/modrec_vehicle_fit_video.h => dml/dml_vehicle_fit_video.h (84%) rename modrec/modrec_vehicle_mesh.cxx => dml/dml_vehicle_mesh.cxx (91%) rename modrec/modrec_vehicle_mesh.h => dml/dml_vehicle_mesh.h (64%) rename modrec/modrec_vehicle_parts.cxx => dml/dml_vehicle_parts.cxx (88%) rename modrec/modrec_vehicle_parts.h => dml/dml_vehicle_parts.h (59%) rename modrec/modrec_vehicle_state.cxx => dml/dml_vehicle_state.cxx (88%) rename modrec/modrec_vehicle_state.h => dml/dml_vehicle_state.h (73%) rename modrec/modrec_vehicle_track_init.cxx => dml/dml_vehicle_track_init.cxx (95%) rename modrec/modrec_vehicle_track_init.h => dml/dml_vehicle_track_init.h (83%) rename modrec/modrec_vehicle_tracker.cxx => dml/dml_vehicle_tracker.cxx (92%) rename modrec/modrec_vehicle_tracker.h => dml/dml_vehicle_tracker.h (87%) rename modrec/py_modrec.cxx => dml/py_dml.cxx (81%) rename modrec/py_modrec_manager.cxx => dml/py_dml_manager.cxx (83%) rename modrec/py_modrec_manager.h => dml/py_dml_manager.h (85%) create mode 100644 dml/tests/CMakeLists.txt rename {modrec => dml}/tests/test_driver.cxx (100%) create mode 100644 dml/tests/test_include.cxx rename {modrec => dml}/tests/test_solar_position.cxx (61%) delete mode 100644 modrec/CMakeLists.txt delete mode 100644 modrec/tests/CMakeLists.txt delete mode 100644 modrec/tests/test_include.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index fa7e379..bed55fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if(VXL_FOUND) add_subdirectory(vpro) add_subdirectory(klt) - add_subdirectory(modrec) + add_subdirectory(dml) add_subdirectory(cmd) add_subdirectory(gui) endif(VXL_FOUND) diff --git a/cmd/CMakeLists.txt b/cmd/CMakeLists.txt index 2aad8c5..452db9c 100644 --- a/cmd/CMakeLists.txt +++ b/cmd/CMakeLists.txt @@ -13,19 +13,19 @@ ADD_EXECUTABLE(mesh_subdivide mesh_subdivide.cxx) TARGET_LINK_LIBRARIES(mesh_subdivide imesh_algo vul) ADD_EXECUTABLE(mesh_extract_features mesh_extract_features.cxx) -TARGET_LINK_LIBRARIES(mesh_extract_features imesh_algo modrec vul) +TARGET_LINK_LIBRARIES(mesh_extract_features imesh_algo dml vul) ADD_EXECUTABLE(make_vehicle_mesh make_vehicle_mesh.cxx) -TARGET_LINK_LIBRARIES(make_vehicle_mesh modrec imesh_algo vul) +TARGET_LINK_LIBRARIES(make_vehicle_mesh dml imesh_algo vul) ADD_EXECUTABLE(fit_mesh_body fit_mesh_body.cxx) -TARGET_LINK_LIBRARIES(fit_mesh_body modrec imesh_algo vul) +TARGET_LINK_LIBRARIES(fit_mesh_body dml imesh_algo vul) ADD_EXECUTABLE(fit_parts fit_parts.cxx) -TARGET_LINK_LIBRARIES(fit_parts modrec vul) +TARGET_LINK_LIBRARIES(fit_parts dml vul) ADD_EXECUTABLE(parts2svg parts2svg.cxx) -TARGET_LINK_LIBRARIES(parts2svg modrec vul) +TARGET_LINK_LIBRARIES(parts2svg dml vul) ADD_EXECUTABLE(pca_fit_mesh_body pca_fit_mesh_body.cxx) TARGET_LINK_LIBRARIES(pca_fit_mesh_body imesh_algo vul) @@ -34,7 +34,7 @@ ADD_EXECUTABLE(mesh_pca mesh_pca.cxx) TARGET_LINK_LIBRARIES(mesh_pca imesh_algo vul) ADD_EXECUTABLE(parts_pca parts_pca.cxx) -TARGET_LINK_LIBRARIES(parts_pca modrec vul) +TARGET_LINK_LIBRARIES(parts_pca dml vul) ADD_EXECUTABLE(mesh_exterior mesh_exterior.cxx) TARGET_LINK_LIBRARIES(mesh_exterior imesh_algo vul) diff --git a/cmd/fit_mesh_body.cxx b/cmd/fit_mesh_body.cxx index a68ee05..ed6783c 100644 --- a/cmd/fit_mesh_body.cxx +++ b/cmd/fit_mesh_body.cxx @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include @@ -413,15 +413,15 @@ int main(int argc, char** argv) #if 0 vcl_map params; - modrec_read_vehicle_params(a_in_file(),params); + dml_read_vehicle_params(a_in_file(),params); double r1 = params["wheel_rad"]; double r2 = r1+params["tire_thick"]; double ww = params["wheel_width"]; double so = params["susp_offset"]; - vcl_auto_ptr verts(modrec_generate_vehicle_body_verts(params)); - vcl_auto_ptr faces(modrec_generate_vehicle_body_faces()); + vcl_auto_ptr verts(dml_generate_vehicle_body_verts(params)); + vcl_auto_ptr faces(dml_generate_vehicle_body_faces()); imesh_mesh model_mesh(verts,faces); imesh_transform_inplace(model_mesh,vgl_vector_3d(0,0,r2+so)); diff --git a/cmd/fit_parts.cxx b/cmd/fit_parts.cxx index 69cfbd9..e07b399 100644 --- a/cmd/fit_parts.cxx +++ b/cmd/fit_parts.cxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,12 +109,12 @@ int main(int argc, char** argv) typedef vcl_map > pmap; - pmap iparts = modrec_read_vehicle_parts(a_in_file()); - pmap mparts = modrec_read_vehicle_parts(a_model_file()); + pmap iparts = dml_read_vehicle_parts(a_in_file()); + pmap mparts = dml_read_vehicle_parts(a_model_file()); pmap parts; - //modrec_write_svg(a_out_file(),parts); + //dml_write_svg(a_out_file(),parts); //return 0; for(pmap::const_iterator itr=mparts.begin(); itr!=mparts.end(); ++itr) @@ -188,7 +188,7 @@ int main(int argc, char** argv) } - modrec_write_vehicle_parts(a_out_file(),parts); + dml_write_vehicle_parts(a_out_file(),parts); return 0; diff --git a/cmd/make_vehicle_mesh.cxx b/cmd/make_vehicle_mesh.cxx index 2c3b6fd..a5c4a6f 100644 --- a/cmd/make_vehicle_mesh.cxx +++ b/cmd/make_vehicle_mesh.cxx @@ -11,7 +11,7 @@ #include #include #include -#include +#include @@ -33,15 +33,15 @@ int main(int argc, char** argv) } vcl_map params; - modrec_read_vehicle_params(a_in_file(),params); + dml_read_vehicle_params(a_in_file(),params); imesh_mesh mesh; if(a_dodec()) - modrec_generate_dodec_vehicle(params, mesh); + dml_generate_dodec_vehicle(params, mesh); else if(a_ferryman()) - modrec_generate_ferryman_vehicle(params, mesh); + dml_generate_ferryman_vehicle(params, mesh); else - modrec_generate_vehicle(params, mesh); + dml_generate_vehicle(params, mesh); imesh_write_obj(a_out_file(), mesh); diff --git a/cmd/mesh_extract_features.cxx b/cmd/mesh_extract_features.cxx index c0798a4..2447874 100644 --- a/cmd/mesh_extract_features.cxx +++ b/cmd/mesh_extract_features.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include @@ -174,8 +174,8 @@ int main(int argc, char** argv) } if(a_svg_file.set()) - modrec_write_svg(a_svg_file(), parts); - modrec_write_vehicle_parts(a_out_file(), parts); + dml_write_svg(a_svg_file(), parts); + dml_write_vehicle_parts(a_out_file(), parts); return 0; } diff --git a/cmd/parts2svg.cxx b/cmd/parts2svg.cxx index 80826af..460884b 100644 --- a/cmd/parts2svg.cxx +++ b/cmd/parts2svg.cxx @@ -8,7 +8,7 @@ #include #include -#include +#include @@ -27,9 +27,9 @@ int main(int argc, char** argv) typedef vcl_map > pmap; - pmap parts = modrec_read_vehicle_parts(a_in_file()); + pmap parts = dml_read_vehicle_parts(a_in_file()); - modrec_write_svg(a_out_file(),parts); + dml_write_svg(a_out_file(),parts); return 0; diff --git a/cmd/parts_pca.cxx b/cmd/parts_pca.cxx index 8e5261e..98c9b61 100644 --- a/cmd/parts_pca.cxx +++ b/cmd/parts_pca.cxx @@ -14,8 +14,8 @@ #include #include #include -#include -#include +#include +#include @@ -62,7 +62,7 @@ int main(int argc, char** argv) vcl_string fname; while(ifs >> fname){ vcl_cout << "loading: " << fname << vcl_endl; - pmap parts = modrec_read_vehicle_parts(fname); + pmap parts = dml_read_vehicle_parts(fname); parts["hubcap1"] = h1; parts["hubcap2"] = h2; parts["hubcap3"] = h3; @@ -85,9 +85,9 @@ int main(int argc, char** argv) ifs.close(); } - modrec_pca_vehicle pca_vehicle(meshes,part_groups); + dml_pca_vehicle pca_vehicle(meshes,part_groups); - modrec_write_pca_vehicle(a_mean_mesh_file(), + dml_write_pca_vehicle(a_mean_mesh_file(), a_mean_parts_file(), a_pca_file(), pca_vehicle); diff --git a/dml/CMakeLists.txt b/dml/CMakeLists.txt new file mode 100644 index 0000000..bd9609f --- /dev/null +++ b/dml/CMakeLists.txt @@ -0,0 +1,70 @@ + +# Copyright Matthew Leotta 2006 - 2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file ../LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# dml/CMakeLists.txt + + +include_directories( ${VXL_GEL_INCLUDE_DIR}/mrc ) +include_directories( ${VXL_RPL_INCLUDE_DIR} ) +include_directories( ${VXL_BRL_INCLUDE_DIR}/bbas ) + +set(dml_sources + dml_proj_cost_func.cxx dml_proj_cost_func.h + dml_proj_lsqr_cost_func.cxx dml_proj_lsqr_cost_func.h + + dml_vehicle_mesh.cxx dml_vehicle_mesh.h + dml_vehicle_parts.cxx dml_vehicle_parts.h + dml_vehicle_fit.cxx dml_vehicle_fit.h + dml_vehicle_fit_multiview.cxx dml_vehicle_fit_multiview.h + dml_vehicle_fit_video.cxx dml_vehicle_fit_video.h + dml_vehicle_state.cxx dml_vehicle_state.h + dml_vehicle_tracker.cxx dml_vehicle_tracker.h + dml_vehicle_track_init.cxx dml_vehicle_track_init.h + dml_pca_vehicle.cxx dml_pca_vehicle.h + dml_pca_vehicle_projector.cxx dml_pca_vehicle_projector.h + + dml_solar_position.cxx dml_solar_position.h + + dml_edgel.cxx dml_edgel.h +) + +add_library(dml ${dml_sources}) + +target_link_libraries(dml vpro vpro_filters bbgm rrel imesh_algo vpgl vil_algo klt) + +if( BUILD_TESTING ) + add_subdirectory(tests) +endif() + +# Make the Python Module for running experiemnts +include( ${VXL_CMAKE_DIR}/NewCMake/FindPython.cmake ) +if( PYTHON_FOUND ) + include_directories( ${PYTHON_INCLUDE_PATH} ) + + set(py_dml_sources + py_dml.cxx + py_dml_manager.cxx py_dml_manager.h + ) + + add_library(py_dml MODULE ${py_dml_sources}) + + if(WIN32) + #library has to have different name depending on debug or release version. + set_target_properties(py_dml PROPERTIES OUTPUT_NAME py_dml DEBUG_POSTFIX _d SUFFIX .pyd) + endif(WIN32) + set_target_properties(py_dml PROPERTIES PREFIX "") + + target_link_libraries(py_dml dml) + + if (PYTHON_DEBUG_LIBRARIES) + target_link_libraries( py_dml debug ${PYTHON_DEBUG_LIBRARY}) + endif(PYTHON_DEBUG_LIBRARIES ) + + if(PYTHON_LIBRARIES) + target_link_libraries( py_dml optimized ${PYTHON_LIBRARY}) + endif(PYTHON_LIBRARIES) +endif( PYTHON_FOUND ) + diff --git a/modrec/modrec_edgel.cxx b/dml/dml_edgel.cxx similarity index 78% rename from modrec/modrec_edgel.cxx rename to dml/dml_edgel.cxx index d936de9..46de4e8 100644 --- a/modrec/modrec_edgel.cxx +++ b/dml/dml_edgel.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_edgel.cxx +// This is dml/dml_edgel.cxx // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -8,7 +8,7 @@ //: // \file -#include "modrec_edgel.h" +#include "dml_edgel.h" #include @@ -32,7 +32,7 @@ inline double angle_diff(double a1, double a2) inline void scan_edgels(const vil_image_view& edge_map, double angle, double ang_t, vgl_triangle_scan_iterator& tsi, - vcl_vector& edgels) + vcl_vector& edgels) { int ni = edge_map.ni(); int nj = edge_map.nj(); @@ -51,8 +51,8 @@ inline void scan_edgels(const vil_image_view& edge_map, double offset = edge_map(x,y,2); double gx = vcl_cos(theta); double gy = vcl_sin(theta); - edgels.push_back(modrec_edgel(x+gx*offset, y+gy*offset, - theta, edge_map(x,y,0))); + edgels.push_back(dml_edgel(x+gx*offset, y+gy*offset, + theta, edge_map(x,y,0))); } } } @@ -62,10 +62,10 @@ inline void scan_edgels(const vil_image_view& edge_map, //: Return a vector of all edgels in the edge map -vcl_vector -modrec_find_all_edgels(const vil_image_view& edge_map) +vcl_vector +dml_find_all_edgels(const vil_image_view& edge_map) { - vcl_vector edgels; + vcl_vector edgels; const unsigned ni = edge_map.ni(); const unsigned nj = edge_map.nj(); @@ -76,8 +76,8 @@ modrec_find_all_edgels(const vil_image_view& edge_map) double offset = edge_map(i,j,2); double gx = vcl_cos(theta); double gy = vcl_sin(theta); - edgels.push_back(modrec_edgel(i+gx*offset, j+gy*offset, - theta, edge_map(i,j,0))); + edgels.push_back(dml_edgel(i+gx*offset, j+gy*offset, + theta, edge_map(i,j,0))); } } } @@ -89,12 +89,12 @@ modrec_find_all_edgels(const vil_image_view& edge_map) // return a vector of edgels found within \a ndist pixel in the normal direction, // with a \a edist pixel padding added in the line direction. // Edgel orientation must form an angle with the line less than \a ang_t (modulo pi radians) -vcl_vector -modrec_find_edgel_neighbors(const vil_image_view& edge_map, - const vgl_line_segment_2d& line, - int ndist, int edist, double ang_t) +vcl_vector +dml_find_edgel_neighbors(const vil_image_view& edge_map, + const vgl_line_segment_2d& line, + int ndist, int edist, double ang_t) { - vcl_vector edgels; + vcl_vector edgels; vgl_vector_2d v = line.direction(); double angle = atan2(-v.x(),v.y()); diff --git a/modrec/modrec_edgel.h b/dml/dml_edgel.h similarity index 70% rename from modrec/modrec_edgel.h rename to dml/dml_edgel.h index 27e46a9..ff1fee5 100644 --- a/modrec/modrec_edgel.h +++ b/dml/dml_edgel.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_edgel.h -#ifndef modrec_edgel_h_ -#define modrec_edgel_h_ +// This is dml/dml_edgel.h +#ifndef dml_edgel_h_ +#define dml_edgel_h_ //: // \file @@ -23,19 +23,19 @@ #include //: A subpixel edge point with orientation and strength -class modrec_edgel : public vgl_point_2d +class dml_edgel : public vgl_point_2d { public: //: Default Constructor - modrec_edgel() : angle_(0.0), strength_(0.0) {} + dml_edgel() : angle_(0.0), strength_(0.0) {} //: Constructor - modrec_edgel(const vgl_point_2d& p, + dml_edgel(const vgl_point_2d& p, double a, double s) : vgl_point_2d(p), angle_(a), strength_(s) {} //: Constructor - modrec_edgel(double x, double y, + dml_edgel(double x, double y, double a, double s) : vgl_point_2d(x,y), angle_(a), strength_(s) {} @@ -60,26 +60,26 @@ class modrec_edgel : public vgl_point_2d //: Comparison operator for sorting edgels by strength -inline bool modrec_edgel_strength_less(const modrec_edgel& e1, - const modrec_edgel& e2) +inline bool dml_edgel_strength_less(const dml_edgel& e1, + const dml_edgel& e2) { return e1.strength() < e2.strength(); } //: Return a vector of all edgels in the edge map -vcl_vector -modrec_find_all_edgels(const vil_image_view& edge_map); +vcl_vector +dml_find_all_edgels(const vil_image_view& edge_map); //: Search the edge map in the neighborhood of a line segment // return a vector of edgels found within \a ndist pixel in the normal direction, // with a \a edist pixel padding added in the line direction. // Edgel orientation must form an angle with the line less than \a ang_t (modulo pi/2 radians) -vcl_vector -modrec_find_edgel_neighbors(const vil_image_view& edge_map, - const vgl_line_segment_2d& line, - int ndist, int edist, double ang_t); +vcl_vector +dml_find_edgel_neighbors(const vil_image_view& edge_map, + const vgl_line_segment_2d& line, + int ndist, int edist, double ang_t); -#endif // modrec_edgel_h_ +#endif // dml_edgel_h_ diff --git a/modrec/modrec_pca_vehicle.cxx b/dml/dml_pca_vehicle.cxx similarity index 85% rename from modrec/modrec_pca_vehicle.cxx rename to dml/dml_pca_vehicle.cxx index 3652068..72d2dc6 100644 --- a/modrec/modrec_pca_vehicle.cxx +++ b/dml/dml_pca_vehicle.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_pca_vehicle.cxx +// This is dml/dml_pca_vehicle.cxx //========================================================================= //: // \file @@ -11,17 +11,17 @@ // //========================================================================= -#include "modrec_pca_vehicle.h" +#include "dml_pca_vehicle.h" #include #include -#include +#include #include //: Constructor -modrec_pca_vehicle::modrec_pca_vehicle(const imesh_pca_mesh& pca_mesh, - const part_map& parts) +dml_pca_vehicle::dml_pca_vehicle(const imesh_pca_mesh& pca_mesh, + const part_map& parts) : imesh_pca_mesh(pca_mesh), parts_(parts), mean_parts_(parts) @@ -31,11 +31,11 @@ modrec_pca_vehicle::modrec_pca_vehicle(const imesh_pca_mesh& pca_mesh, //: Constructor from a mesh, parts, mean, standard deviations, and PC matrix -modrec_pca_vehicle::modrec_pca_vehicle(const imesh_mesh& mesh, - const part_map& parts, - const vnl_vector& mean, - const vnl_vector& std_devs, - const vnl_matrix& pc) +dml_pca_vehicle::dml_pca_vehicle(const imesh_mesh& mesh, + const part_map& parts, + const vnl_vector& mean, + const vnl_vector& std_devs, + const vnl_matrix& pc) : imesh_pca_mesh(mesh), parts_(parts), mean_parts_(parts) @@ -46,9 +46,9 @@ modrec_pca_vehicle::modrec_pca_vehicle(const imesh_mesh& mesh, //: Constructor - compute the pca from a joint collection of meshes and parts -modrec_pca_vehicle::modrec_pca_vehicle(const vcl_vector& meshes, - const vcl_vector > >& part_groups) +dml_pca_vehicle::dml_pca_vehicle(const vcl_vector& meshes, + const vcl_vector > >& part_groups) : imesh_pca_mesh(meshes[0]) { assert(meshes.size() == part_groups.size()); @@ -158,16 +158,16 @@ modrec_pca_vehicle::modrec_pca_vehicle(const vcl_vector& meshes, //: Destructor -modrec_pca_vehicle::~modrec_pca_vehicle() +dml_pca_vehicle::~dml_pca_vehicle() { } //: Initialize the PCA data (assuming mesh and parts are already set) // use this to add PCA data after mesh and parts are loaded from files -void modrec_pca_vehicle::init(const vnl_vector& mean, - const vnl_vector& std_devs, - const vnl_matrix& pc) +void dml_pca_vehicle::init(const vnl_vector& mean, + const vnl_vector& std_devs, + const vnl_matrix& pc) { assert(mean.size() == pc.columns()); assert(std_devs.size() == pc.rows()); @@ -205,8 +205,8 @@ void modrec_pca_vehicle::init(const vnl_vector& mean, //: Project mesh vertices and parts into the joint PCA parameter space vnl_vector -modrec_pca_vehicle::project(const imesh_vertex_array_base& verts, - const part_map& parts) const +dml_pca_vehicle::project(const imesh_vertex_array_base& verts, + const part_map& parts) const { vnl_vector vals(parts_pc_.columns()); @@ -246,7 +246,7 @@ modrec_pca_vehicle::project(const imesh_vertex_array_base& verts, //: Set the parts -void modrec_pca_vehicle::set_parts(const part_map& parts) +void dml_pca_vehicle::set_parts(const part_map& parts) { parts_ = parts; if(mean_parts_.empty()) @@ -260,7 +260,7 @@ void modrec_pca_vehicle::set_parts(const part_map& parts) //: Set the pca parameters -void modrec_pca_vehicle::set_params(const vnl_vector& p) +void dml_pca_vehicle::set_params(const vnl_vector& p) { // set shape params in the base class imesh_pca_mesh::set_params(p); @@ -294,7 +294,7 @@ void modrec_pca_vehicle::set_params(const vnl_vector& p) //: Set an individual pca parameter // This is done by incremental difference, errors may accumulate // over many calls. -void modrec_pca_vehicle::set_param(unsigned int idx, double param) +void dml_pca_vehicle::set_param(unsigned int idx, double param) { double diff = std_devs_[idx]*(param - params_[idx]); @@ -320,8 +320,8 @@ void modrec_pca_vehicle::set_param(unsigned int idx, double param) //: Look up part number \a p and index \a i from the PC index \a pc -void modrec_pca_vehicle::pc_to_part_idx(unsigned int pc, - unsigned int& p, unsigned int& i) const +void dml_pca_vehicle::pc_to_part_idx(unsigned int pc, + unsigned int& p, unsigned int& i) const { unsigned int j=1; for(; jhas_tex_coords()); //imesh_mesh mesh = imesh_submesh_from_faces(*this,this->faces().group_face_set("body")); @@ -414,7 +414,7 @@ void modrec_pca_vehicle::project_tex_to_bary() //: Project barycentric coordinates into 3D coordinates -void modrec_pca_vehicle::project_bary_to_3d() +void dml_pca_vehicle::project_bary_to_3d() { assert(this->has_tex_coords()); @@ -435,7 +435,7 @@ void modrec_pca_vehicle::project_bary_to_3d() //: Compute the part index offsets for the part_map -void modrec_pca_vehicle::init_part_idx_offsets() +void dml_pca_vehicle::init_part_idx_offsets() { part_idx_offsets_.resize(parts_.size()+1); part_idx_offsets_[0] = 0; @@ -453,16 +453,16 @@ void modrec_pca_vehicle::init_part_idx_offsets() //: Write the mean mesh, mean parts, and PCA file -void modrec_write_pca_vehicle(const vcl_string& mesh_file, - const vcl_string& parts_file, - const vcl_string& pca_file, - const modrec_pca_vehicle& pmesh) +void dml_write_pca_vehicle(const vcl_string& mesh_file, + const vcl_string& parts_file, + const vcl_string& pca_file, + const dml_pca_vehicle& pmesh) { const vnl_vector& std_dev = pmesh.std_devs(); const vnl_matrix& mesh_pc = pmesh.principal_comps(); const vnl_matrix& parts_pc = pmesh.parts_principal_comps(); const imesh_vertex_array<3>& mverts = pmesh.mean_vertices<3>(); - const modrec_pca_vehicle::part_map& mparts = pmesh.mean_parts(); + const dml_pca_vehicle::part_map& mparts = pmesh.mean_parts(); const unsigned int num_mesh_pts = mesh_pc.columns(); const unsigned int num_parts_pts = parts_pc.columns(); @@ -472,7 +472,7 @@ void modrec_write_pca_vehicle(const vcl_string& mesh_file, mean[i] = mverts[i/3][i%3]; unsigned int pidx=num_mesh_pts; - for(modrec_pca_vehicle::part_map::const_iterator pitr=mparts.begin(); + for(dml_pca_vehicle::part_map::const_iterator pitr=mparts.begin(); pitr!=mparts.end(); ++pitr){ const vcl_vector >& pts = pitr->second[0]; for(unsigned int i=0; i > part_map; //: Constructor - modrec_pca_vehicle() {} + dml_pca_vehicle() {} //: Constructor - compute the pca from a joint collection of meshes and parts - modrec_pca_vehicle(const vcl_vector& meshes, - const vcl_vector& part_groups); + dml_pca_vehicle(const vcl_vector& meshes, + const vcl_vector& part_groups); //: Constructor - modrec_pca_vehicle(const imesh_pca_mesh& pca_mesh, - const part_map& parts); + dml_pca_vehicle(const imesh_pca_mesh& pca_mesh, + const part_map& parts); //: Constructor from a mesh, parts, mean, standard deviations, and PC matrix - modrec_pca_vehicle(const imesh_mesh& mesh, - const part_map& parts, - const vnl_vector& mean, - const vnl_vector& std_devs, - const vnl_matrix& pc); + dml_pca_vehicle(const imesh_mesh& mesh, + const part_map& parts, + const vnl_vector& mean, + const vnl_vector& std_devs, + const vnl_matrix& pc); //: Destructor - ~modrec_pca_vehicle(); + ~dml_pca_vehicle(); //: A structure containing information about each barycentric point struct uv_point @@ -158,10 +158,10 @@ class modrec_pca_vehicle : public imesh_pca_mesh //: Write the mean mesh, mean parts, and PCA file -void modrec_write_pca_vehicle(const vcl_string& mesh_file, - const vcl_string& parts_file, - const vcl_string& pca_file, - const modrec_pca_vehicle& pmesh); +void dml_write_pca_vehicle(const vcl_string& mesh_file, + const vcl_string& parts_file, + const vcl_string& pca_file, + const dml_pca_vehicle& pmesh); -#endif // modrec_pca_vehicle_h_ +#endif // dml_pca_vehicle_h_ diff --git a/modrec/modrec_pca_vehicle_projector.cxx b/dml/dml_pca_vehicle_projector.cxx similarity index 96% rename from modrec/modrec_pca_vehicle_projector.cxx rename to dml/dml_pca_vehicle_projector.cxx index b5caff1..64f8926 100644 --- a/modrec/modrec_pca_vehicle_projector.cxx +++ b/dml/dml_pca_vehicle_projector.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_pca_vehicle.cxx +// This is dml/dml_pca_vehicle.cxx //========================================================================= //: // \file @@ -11,7 +11,7 @@ // //========================================================================= -#include "modrec_pca_vehicle_projector.h" +#include "dml_pca_vehicle_projector.h" #include #include @@ -25,15 +25,15 @@ //: Constructor - takes width and height of the image -modrec_pca_vehicle_projector:: -modrec_pca_vehicle_projector(unsigned int w, unsigned int h) +dml_pca_vehicle_projector:: +dml_pca_vehicle_projector(unsigned int w, unsigned int h) : depth_img_(w,h) { depth_img_.fill(vcl_numeric_limits::infinity()); } //: resize the depth map image and clear it -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: resize(unsigned int w, unsigned int h) { depth_img_.set_size(w,h); @@ -42,7 +42,7 @@ resize(unsigned int w, unsigned int h) //: Compute the minimum projected depth -double modrec_pca_vehicle_projector::min_depth() const +double dml_pca_vehicle_projector::min_depth() const { double min_depth = vcl_numeric_limits::infinity(); for(vcl_vector::const_iterator i=depths_.begin(); @@ -55,7 +55,7 @@ double modrec_pca_vehicle_projector::min_depth() const //: Compute the maximum projected depth -double modrec_pca_vehicle_projector::max_depth() const +double dml_pca_vehicle_projector::max_depth() const { double max_depth = -vcl_numeric_limits::infinity(); for(vcl_vector::const_iterator i=depths_.begin(); @@ -69,7 +69,7 @@ double modrec_pca_vehicle_projector::max_depth() const //: Compute a camera that incorporates the vehicle rotation and translation vpgl_perspective_camera -modrec_pca_vehicle_projector:: +dml_pca_vehicle_projector:: compute_relative_camera(const vpgl_perspective_camera& camera, const vgl_rotation_3d& R, const vgl_vector_3d& t) @@ -85,7 +85,7 @@ compute_relative_camera(const vpgl_perspective_camera& camera, //: Compute a camera that images the projection onto the ground plane vpgl_proj_camera -modrec_pca_vehicle_projector:: +dml_pca_vehicle_projector:: compute_shadow_camera(const vpgl_perspective_camera& camera, const vgl_rotation_3d& R, const vgl_vector_3d& t, @@ -105,9 +105,9 @@ compute_shadow_camera(const vpgl_perspective_camera& camera, //: Project the vehicle curves using the camera -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: project(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun, @@ -156,9 +156,9 @@ project(const vpgl_perspective_camera& camera, //: Reproject the last vehicle curves using the camera. // Do not recompute the depth map or redetermine part and contour visibility. // Requires that \c project() has been called at least once first -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: reproject(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun, @@ -191,9 +191,9 @@ reproject(const vpgl_perspective_camera& camera, //: Project all mesh edges and no parts using the camera -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: project_all_edges(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun, @@ -296,7 +296,7 @@ project_all_edges(const vpgl_perspective_camera& camera, //: use the last produced depth map to estimate the fast back projection. vgl_homg_point_3d -modrec_pca_vehicle_projector:: +dml_pca_vehicle_projector:: back_project_fast(const vpgl_perspective_camera& camera, const vgl_point_2d& pt) { @@ -335,7 +335,7 @@ back_project_fast(const vpgl_perspective_camera& camera, //: Project all mesh edges vcl_vector > > -modrec_pca_vehicle_projector:: +dml_pca_vehicle_projector:: project_all_edges(const vpgl_perspective_camera& camera, const imesh_mesh& vehicle, const vgl_rotation_3d& R, @@ -377,7 +377,7 @@ project_all_edges(const vpgl_perspective_camera& camera, //: Project the shadow of the vehicle onto Z=0 along the sun direction -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: project_shadow(const vpgl_perspective_camera& camera, const imesh_mesh& vehicle, const vgl_rotation_3d& R, @@ -410,7 +410,7 @@ project_shadow(const vpgl_perspective_camera& camera, //: build the depth map of the vehicle -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: build_depth_image(const vpgl_perspective_camera& camera, const imesh_mesh& vehicle) { @@ -426,7 +426,7 @@ build_depth_image(const vpgl_perspective_camera& camera, //: Test the depth of point \a x, \a y at depth \a depth against the depth map // Returns true only if deeper than the nearest 4 pixels -bool modrec_pca_vehicle_projector:: +bool dml_pca_vehicle_projector:: depth_test(double x, double y, double depth) const { int x1 = static_cast(vcl_floor(x)); @@ -449,9 +449,9 @@ depth_test(double x, double y, double depth) const //: project the visible part boundaries into the image -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: project_parts(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { parts_.clear(); parts_idx_.clear(); @@ -510,7 +510,7 @@ project_parts(const vpgl_perspective_camera& camera, } parts_bounds_.clear(); - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector >& parts_uv = vehicle.parts_bary(); for(unsigned int i=0; i& camera, //: project the visible occluding contours into the image -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: project_contours(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { // detect the contour generator vcl_vector > edge_loops = @@ -618,8 +618,8 @@ project_contours(const vpgl_perspective_camera& camera, //: map the silhouette contours back to vehicle mesh vertices -void modrec_pca_vehicle_projector:: -map_silhouette(const modrec_pca_vehicle& vehicle, +void dml_pca_vehicle_projector:: +map_silhouette(const dml_pca_vehicle& vehicle, const vcl_vector >& edge_loops, const vgl_polygon& sil, const vcl_vector >& sil_idx, @@ -695,7 +695,7 @@ map_silhouette(const modrec_pca_vehicle& vehicle, //: trace the outer silhoutte of the occluding contours // this function is incredibly complex and ugly to handle the many degenerate case // there must be a way to make this more elegant -bool modrec_pca_vehicle_projector:: +bool dml_pca_vehicle_projector:: trace_silhouette(vgl_polygon& p, vcl_vector >& sil_idx, vcl_vector >& sil_frac) @@ -1021,15 +1021,15 @@ trace_silhouette(vgl_polygon& p, //: reproject the last visible part boundaries into the image -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: reproject_parts(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { parts_.clear(); parts_idx_.clear(); vcl_vector > verts2d; vcl_vector depths; - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector > >& parts3d = vehicle.parts_3d(); const vcl_vector >& parts_uv = vehicle.parts_bary(); for(unsigned int b=0; b& camera, //: reproject the last visible occluding contours into the image -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: reproject_contours(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { contours_.clear(); contours_.resize(contours_vidx_.size()); @@ -1127,10 +1127,10 @@ reproject_contours(const vpgl_perspective_camera& camera, //: reproject the last valid silhouette edges into the image -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: reproject_silhouette(const vpgl_perspective_camera& camera, const vpgl_proj_camera& shadow_camera, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { const imesh_vertex_array< 3 >& verts3d = vehicle.vertices<3>(); @@ -1165,7 +1165,7 @@ reproject_silhouette(const vpgl_perspective_camera& camera, //: Arrange the projected silhouette as a closed polygon -vgl_polygon modrec_pca_vehicle_projector::silhouette_polygon() const +vgl_polygon dml_pca_vehicle_projector::silhouette_polygon() const { vgl_polygon sil(1); for(unsigned int i=0; i modrec_pca_vehicle_projector::silhouette_polygon() const } //: compute the PCA image Jacobians for both contours and part boundaries -void modrec_pca_vehicle_projector:: +void dml_pca_vehicle_projector:: compute_jacobians(const vpgl_perspective_camera& camera, const vpgl_proj_camera& shadow_cam, - const modrec_pca_vehicle& vehicle) + const dml_pca_vehicle& vehicle) { contours_jac_.clear(); silhouette_jac_.clear(); @@ -1406,8 +1406,8 @@ compute_jacobians(const vpgl_perspective_camera& camera, //: compute the PCA image Jacobians for contour points given the world-to-image Jacobians -void modrec_pca_vehicle_projector:: -compute_contour_pca_jacobians(const modrec_pca_vehicle& vehicle, +void dml_pca_vehicle_projector:: +compute_contour_pca_jacobians(const dml_pca_vehicle& vehicle, vcl_vector >::iterator J) { const vnl_matrix& pc = vehicle.principal_comps(); @@ -1435,8 +1435,8 @@ compute_contour_pca_jacobians(const modrec_pca_vehicle& vehicle, //: compute the PCA image Jacobians for part boundaries given the world-to-image Jacobians -void modrec_pca_vehicle_projector:: -compute_parts_pca_jacobians(const modrec_pca_vehicle& vehicle, +void dml_pca_vehicle_projector:: +compute_parts_pca_jacobians(const dml_pca_vehicle& vehicle, vcl_vector >::iterator J) { // now do the parts points @@ -1461,7 +1461,7 @@ compute_parts_pca_jacobians(const modrec_pca_vehicle& vehicle, vnl_matrix M(3,2); - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector >& parts_uv = vehicle.parts_bary(); for(unsigned int i=0; i +#include #include #include @@ -29,14 +29,14 @@ //: Projection of the occluding contours and part edges into an image -class modrec_pca_vehicle_projector +class dml_pca_vehicle_projector { public: //: Constructor - modrec_pca_vehicle_projector() {} + dml_pca_vehicle_projector() {} //: Constructor - takes width and height of the image - modrec_pca_vehicle_projector(unsigned int w, unsigned int h); + dml_pca_vehicle_projector(unsigned int w, unsigned int h); //: Compute a camera that incorporates the vehicle rotation and translation static vpgl_perspective_camera @@ -53,7 +53,7 @@ class modrec_pca_vehicle_projector //: Project the vehicle curves using the camera void project(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun = vgl_vector_3d(0,0,0), @@ -64,7 +64,7 @@ class modrec_pca_vehicle_projector // Do not recompute the depth map or redetermine part and contour visibility. // Requires that \c project() has been called at least once first void reproject(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun = vgl_vector_3d(0,0,0), @@ -73,7 +73,7 @@ class modrec_pca_vehicle_projector //: Project all mesh edges and no parts using the camera void project_all_edges(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle, + const dml_pca_vehicle& vehicle, const vgl_rotation_3d& R, const vgl_vector_3d& t, const vgl_vector_3d& sun = vgl_vector_3d(0,0,0), @@ -186,14 +186,14 @@ class modrec_pca_vehicle_projector //: project the visible part boundaries into the image void project_parts(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: project the visible occluding contours into the image void project_contours(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: map the silhouette contours back to vehicle mesh vertices - void map_silhouette(const modrec_pca_vehicle& vehicle, + void map_silhouette(const dml_pca_vehicle& vehicle, const vcl_vector >& edge_loops, const vgl_polygon& sil, const vcl_vector >& sil_idx, @@ -207,28 +207,28 @@ class modrec_pca_vehicle_projector //: reproject the last visible part boundaries into the image void reproject_parts(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: reproject the last visible occluding contours into the image void reproject_contours(const vpgl_perspective_camera& camera, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: reproject the last valid silhouette edges into the image void reproject_silhouette(const vpgl_perspective_camera& camera, const vpgl_proj_camera& shadow_camera, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: compute the PCA image Jacobians for both contours and part boundaries void compute_jacobians(const vpgl_perspective_camera& camera, const vpgl_proj_camera& shadow_cam, - const modrec_pca_vehicle& vehicle); + const dml_pca_vehicle& vehicle); //: compute the PCA image Jacobians for contour points given the world-to-image Jacobians - void compute_contour_pca_jacobians(const modrec_pca_vehicle& vehicle, + void compute_contour_pca_jacobians(const dml_pca_vehicle& vehicle, vcl_vector >::iterator J); //: compute the PCA image Jacobians for part boundaries given the world-to-image Jacobians - void compute_parts_pca_jacobians(const modrec_pca_vehicle& vehicle, + void compute_parts_pca_jacobians(const dml_pca_vehicle& vehicle, vcl_vector >::iterator J); @@ -283,8 +283,8 @@ class modrec_pca_vehicle_projector //: Save the projected contours as SVG -bool modrec_write_svg_curves(const vcl_string& filename, - const modrec_pca_vehicle_projector& projector); +bool dml_write_svg_curves(const vcl_string& filename, + const dml_pca_vehicle_projector& projector); -#endif // modrec_pca_vehicle_projector_h_ +#endif // dml_pca_vehicle_projector_h_ diff --git a/modrec/modrec_proj_cost_func.cxx b/dml/dml_proj_cost_func.cxx similarity index 81% rename from modrec/modrec_proj_cost_func.cxx rename to dml/dml_proj_cost_func.cxx index fef5687..9fdbcb9 100644 --- a/modrec/modrec_proj_cost_func.cxx +++ b/dml/dml_proj_cost_func.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_proj_cost_func.cxx +// This is dml/dml_proj_cost_func.cxx // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -8,19 +8,19 @@ //: // \file -#include "modrec_proj_cost_func.h" +#include "dml_proj_cost_func.h" #include //: Constructor -modrec_proj_cost_func:: -modrec_proj_cost_func(const vil_image_view& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys) +dml_proj_cost_func:: +dml_proj_cost_func(const vil_image_view& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys) : vnl_cost_function(2), errors_(errors), camera_(camera), @@ -39,7 +39,7 @@ modrec_proj_cost_func(const vil_image_view& errors, //: Set the image of error values void -modrec_proj_cost_func::set_errors(const vil_image_view& e) +dml_proj_cost_func::set_errors(const vil_image_view& e) { if(errors_.ni() != e.ni() || errors_.nj() != e.nj()){ mask_.set_size(e.ni(),e.nj(),1); @@ -53,7 +53,7 @@ modrec_proj_cost_func::set_errors(const vil_image_view& e) //: The main function. double -modrec_proj_cost_func::f(vnl_vector const& x) +dml_proj_cost_func::f(vnl_vector const& x) { vnl_double_3x4 cam(camera_); cam.set_column(3, x(0)*cam.get_column(0) + @@ -108,12 +108,12 @@ modrec_proj_cost_func::f(vnl_vector const& x) //========================================================================================= //: Constructor -modrec_motion_cost_func:: -modrec_motion_cost_func( const vcl_vector >& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys ) +dml_motion_cost_func:: +dml_motion_cost_func( const vcl_vector >& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys ) : vnl_cost_function(3), frame_cost_(errors[0],camera,lens,model,xs,ys), seq_errors_(errors) @@ -124,7 +124,7 @@ modrec_motion_cost_func( const vcl_vector >& errors, //: The main function. double -modrec_motion_cost_func::f(vnl_vector const& x) +dml_motion_cost_func::f(vnl_vector const& x) { double error = 0.0; diff --git a/modrec/modrec_proj_cost_func.h b/dml/dml_proj_cost_func.h similarity index 63% rename from modrec/modrec_proj_cost_func.h rename to dml/dml_proj_cost_func.h index 71451bc..a817595 100644 --- a/modrec/modrec_proj_cost_func.h +++ b/dml/dml_proj_cost_func.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_proj_cost_func.h -#ifndef modrec_proj_cost_func_h_ -#define modrec_proj_cost_func_h_ +// This is dml/dml_proj_cost_func.h +#ifndef dml_proj_cost_func_h_ +#define dml_proj_cost_func_h_ //: // \file // \brief A cost function for registering a 3D @@ -27,15 +27,15 @@ //: A cost function for registering a 3D // model and its projection into a single frame -class modrec_proj_cost_func : public vnl_cost_function +class dml_proj_cost_func : public vnl_cost_function { public: //: Constructor - modrec_proj_cost_func( const vil_image_view& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys ); + dml_proj_cost_func( const vil_image_view& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys ); //: The main function. @@ -60,15 +60,15 @@ class modrec_proj_cost_func : public vnl_cost_function //: A cost function for registering a 3D // model and its projection many frames under a motion model -class modrec_motion_cost_func : public vnl_cost_function +class dml_motion_cost_func : public vnl_cost_function { public: //: Constructor - modrec_motion_cost_func( const vcl_vector >& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys ); + dml_motion_cost_func( const vcl_vector >& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys ); //: The main function. @@ -77,12 +77,12 @@ class modrec_motion_cost_func : public vnl_cost_function protected: //: The cost function for a given frame - modrec_proj_cost_func frame_cost_; + dml_proj_cost_func frame_cost_; //: The error measures for each frame in the sequence vcl_vector > seq_errors_; }; -#endif // modrec_proj_cost_func_h_ +#endif // dml_proj_cost_func_h_ diff --git a/modrec/modrec_proj_lsqr_cost_func.cxx b/dml/dml_proj_lsqr_cost_func.cxx similarity index 72% rename from modrec/modrec_proj_lsqr_cost_func.cxx rename to dml/dml_proj_lsqr_cost_func.cxx index fd53ac4..735981c 100644 --- a/modrec/modrec_proj_lsqr_cost_func.cxx +++ b/dml/dml_proj_lsqr_cost_func.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_proj_lsqr_cost_func.cxx +// This is dml/dml_proj_lsqr_cost_func.cxx // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -8,19 +8,19 @@ //: // \file -#include "modrec_proj_lsqr_cost_func.h" +#include "dml_proj_lsqr_cost_func.h" #include //: Constructor -modrec_proj_lsqr_cost_func:: -modrec_proj_lsqr_cost_func( const vil_image_view& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys ) +dml_proj_lsqr_cost_func:: +dml_proj_lsqr_cost_func( const vil_image_view& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys ) : vnl_least_squares_function(1,errors.ni()*errors.nj(),no_gradient), errors_(errors), camera_(camera), @@ -36,7 +36,7 @@ modrec_proj_lsqr_cost_func( const vil_image_view& errors, // Given the parameter vector x, compute the vector of residuals fx. // Fx has been sized appropriately before the call. void -modrec_proj_lsqr_cost_func::f(vnl_vector const& x, vnl_vector& fx) +dml_proj_lsqr_cost_func::f(vnl_vector const& x, vnl_vector& fx) { vnl_double_3x4 cam(camera_); cam.set_column(3,x(0)*cam.get_column(0)+cam.get_column(3)); diff --git a/modrec/modrec_proj_lsqr_cost_func.h b/dml/dml_proj_lsqr_cost_func.h similarity index 67% rename from modrec/modrec_proj_lsqr_cost_func.h rename to dml/dml_proj_lsqr_cost_func.h index a50adcf..c02e308 100644 --- a/modrec/modrec_proj_lsqr_cost_func.h +++ b/dml/dml_proj_lsqr_cost_func.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_proj_lsqr_cost_func.h -#ifndef modrec_proj_lsqr_cost_func_h_ -#define modrec_proj_lsqr_cost_func_h_ +// This is dml/dml_proj_lsqr_cost_func.h +#ifndef dml_proj_lsqr_cost_func_h_ +#define dml_proj_lsqr_cost_func_h_ //: // \file // \brief A least squares cost function for registering a 3D @@ -27,15 +27,15 @@ //: A least squares cost function for registering a 3D // model and its projection -class modrec_proj_lsqr_cost_func : public vnl_least_squares_function +class dml_proj_lsqr_cost_func : public vnl_least_squares_function { public: //: Constructor - modrec_proj_lsqr_cost_func( const vil_image_view& errors, - const vnl_double_3x4& camera, - const vpgl_poly_radial_distortion& lens, - const imesh_mesh& model, - double xs, double ys ); + dml_proj_lsqr_cost_func( const vil_image_view& errors, + const vnl_double_3x4& camera, + const vpgl_poly_radial_distortion& lens, + const imesh_mesh& model, + double xs, double ys ); //: The main function. @@ -54,5 +54,5 @@ class modrec_proj_lsqr_cost_func : public vnl_least_squares_function }; -#endif // modrec_proj_lsqr_cost_func_h_ +#endif // dml_proj_lsqr_cost_func_h_ diff --git a/modrec/modrec_solar_position.cxx b/dml/dml_solar_position.cxx similarity index 91% rename from modrec/modrec_solar_position.cxx rename to dml/dml_solar_position.cxx index c998da9..4e942d2 100644 --- a/modrec/modrec_solar_position.cxx +++ b/dml/dml_solar_position.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_solar_position.cxx +// This is dml/dml_solar_position.cxx #ifdef VCL_NEEDS_PRAGMA_INTERFACE #pragma implementation #endif @@ -13,15 +13,15 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include "modrec_solar_position.h" +#include "dml_solar_position.h" #include //: Compute position of the sun given time, date, and location void -modrec_solar_position(int day, double utc_hour, - double lat, double lng, - double& alt, double& az) +dml_solar_position(int day, double utc_hour, + double lat, double lng, + double& alt, double& az) { const double pi = 3.14159265358979323846; diff --git a/modrec/modrec_solar_position.h b/dml/dml_solar_position.h similarity index 78% rename from modrec/modrec_solar_position.h rename to dml/dml_solar_position.h index 81f0f58..50a3ae0 100644 --- a/modrec/modrec_solar_position.h +++ b/dml/dml_solar_position.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_solar_position.h -#ifndef modrec_solar_position_h_ -#define modrec_solar_position_h_ +// This is dml/dml_solar_position.h +#ifndef dml_solar_position_h_ +#define dml_solar_position_h_ #ifdef VCL_NEEDS_PRAGMA_INTERFACE #pragma interface #endif @@ -36,10 +36,10 @@ // \param lng longitude in degrees // \retval alt altitude in radians from the horizon // \retval az azimuth in radians from North -void modrec_solar_position(int day, double utc_hour, - double lat, double lng, - double& alt, double& az); +void dml_solar_position(int day, double utc_hour, + double lat, double lng, + double& alt, double& az); -#endif // modrec_solar_position_h_ +#endif // dml_solar_position_h_ diff --git a/modrec/modrec_vehicle_fit.cxx b/dml/dml_vehicle_fit.cxx similarity index 90% rename from modrec/modrec_vehicle_fit.cxx rename to dml/dml_vehicle_fit.cxx index b3b5d72..0e1ac7c 100644 --- a/modrec/modrec_vehicle_fit.cxx +++ b/dml/dml_vehicle_fit.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_fit.cxx +// This is dml/dml_vehicle_fit.cxx //========================================================================= //: // \file @@ -11,7 +11,7 @@ // //========================================================================= -#include "modrec_vehicle_fit.h" +#include "dml_vehicle_fit.h" #include @@ -25,7 +25,7 @@ #include //: Constructor -modrec_vehicle_fit::modrec_vehicle_fit() +dml_vehicle_fit::dml_vehicle_fit() : min_e_strength_(0.0), max_e_strength_(30.0), lambda_(1.0), @@ -42,8 +42,8 @@ modrec_vehicle_fit::modrec_vehicle_fit() //: Compute the edge map for image \a img -void modrec_vehicle_fit::detect_edges(const vil_image_view& img, - vil_image_view& edge_map) const +void dml_vehicle_fit::detect_edges(const vil_image_view& img, + vil_image_view& edge_map) const { vil_image_view work; vil_image_view smooth; @@ -62,8 +62,8 @@ void modrec_vehicle_fit::detect_edges(const vil_image_view& img, // - [0] is top \a num_pc PCA params // - [1,2,3] is Tx,Ty,Tz respectively // - [4,5,6] is Rx,Ry,Rz respectively -void modrec_vehicle_fit::set_options(const vcl_vector& options, - unsigned int num_pc) +void dml_vehicle_fit::set_options(const vcl_vector& options, + unsigned int num_pc) { num_params_ = options[0]?num_pc:0; txi_ = options[1]?num_params_++:-1; @@ -81,7 +81,7 @@ void modrec_vehicle_fit::set_options(const vcl_vector& options, //: Set the initial uncertaintly to a scale times the default uncertainty -void modrec_vehicle_fit::set_init_uncert(double uncert) +void dml_vehicle_fit::set_init_uncert(double uncert) { init_uncert_.set_size(num_params_); init_uncert_.fill(uncert); @@ -99,14 +99,14 @@ void modrec_vehicle_fit::set_init_uncert(double uncert) // - 0 is a value in [0.0, 1.0] indicating location of the projection between the endpoints // - 1 is the perpendicular distance to the edgel // - 2 is the weight for use in optimization -void modrec_vehicle_fit:: +void dml_vehicle_fit:: compute_line_matches(const vgl_point_2d& p0, const vgl_point_2d& p1, const vil_image_view& edge_map, vcl_vector >& matches) const { unsigned int search_dist = vcl_ceil(4*mest_scale_); - vcl_vector edgels = - modrec_find_edgel_neighbors(edge_map, + vcl_vector edgels = + dml_find_edgel_neighbors(edge_map, vgl_line_segment_2d(p0,p1), search_dist, 0, 0.5); if(edgels.empty()) @@ -131,7 +131,7 @@ compute_line_matches(const vgl_point_2d& p0, const vgl_point_2d& unsigned int init_matches_size = matches.size(); for(unsigned int k=0; k > >& curves, const vcl_vector > >& J, const vil_image_view& edge_map, @@ -268,7 +268,7 @@ compute_curve_opt_terms(const vcl_vector > >& cu //: Compute the residuals of the optimization -void modrec_vehicle_fit:: +void dml_vehicle_fit:: compute_curve_residuals(const vcl_vector > >& curves, const vil_image_view& edge_map, double& total_weight, @@ -297,8 +297,8 @@ compute_curve_residuals(const vcl_vector > >& cu //: Compute the prior terms and update M and b -double modrec_vehicle_fit:: -compute_prior(const modrec_pca_vehicle& mesh, +double dml_vehicle_fit:: +compute_prior(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -335,10 +335,10 @@ compute_prior(const modrec_pca_vehicle& mesh, //: Apply the solution vector to update the shape and pose parameters -void modrec_vehicle_fit::apply_solution(const vnl_vector& soln, - modrec_pca_vehicle& mesh, - vgl_vector_3d& translation, - vgl_rotation_3d& rotation) +void dml_vehicle_fit::apply_solution(const vnl_vector& soln, + dml_pca_vehicle& mesh, + vgl_vector_3d& translation, + vgl_rotation_3d& rotation) { if(options_[0] && num_pc_ > 0) { @@ -367,10 +367,10 @@ void modrec_vehicle_fit::apply_solution(const vnl_vector& soln, #if 1 //: Fits the model parameters: PCA, translation, rotation to the image. -void modrec_vehicle_fit::fit_model(unsigned int num_itr, - modrec_pca_vehicle& mesh, - vgl_vector_3d& translation, - vgl_rotation_3d& rotation) +void dml_vehicle_fit::fit_model(unsigned int num_itr, + dml_pca_vehicle& mesh, + vgl_vector_3d& translation, + vgl_rotation_3d& rotation) { if(num_params_ == 0) return; @@ -435,10 +435,10 @@ void modrec_vehicle_fit::fit_model(unsigned int num_itr, #else //: Fits the model parameters: PCA, translation, rotation to the image. // use Levenberg-Marquardt -void modrec_vehicle_fit::fit_model(unsigned int num_itr, - modrec_pca_vehicle& mesh, - vgl_vector_3d& translation, - vgl_rotation_3d& rotation) +void dml_vehicle_fit::fit_model(unsigned int num_itr, + dml_pca_vehicle& mesh, + vgl_vector_3d& translation, + vgl_rotation_3d& rotation) { if(num_params_ == 0) return; @@ -521,12 +521,12 @@ void modrec_vehicle_fit::fit_model(unsigned int num_itr, //: One iteration of fitting PCA, translation, rotation to the image. // return true if the iteration successfully reached a lower residual -bool modrec_vehicle_fit::fit_model_once(modrec_pca_vehicle& mesh, - vgl_vector_3d& translation, - vgl_rotation_3d& rotation, - vnl_vector& soln, - double& last_residual, - bool compute_visibility) +bool dml_vehicle_fit::fit_model_once(dml_pca_vehicle& mesh, + vgl_vector_3d& translation, + vgl_rotation_3d& rotation, + vnl_vector& soln, + double& last_residual, + bool compute_visibility) { vnl_vector b(num_params_,0.0); vnl_matrix M(num_params_,num_params_,0.0); @@ -562,8 +562,8 @@ bool modrec_vehicle_fit::fit_model_once(modrec_pca_vehicle& mesh, //: Evaluate the residual at the current state and scale // this function is for generating a plot of the error surface -double modrec_vehicle_fit:: -evaluate_residual(const modrec_pca_vehicle& mesh, +double dml_vehicle_fit:: +evaluate_residual(const dml_pca_vehicle& mesh, const vgl_vector_3d& t, const vgl_rotation_3d& R, double scale, @@ -587,7 +587,7 @@ evaluate_residual(const modrec_pca_vehicle& mesh, //: Compute the edgel matches and weights from a set of curves // This is primarily for debugging -void modrec_vehicle_fit:: +void dml_vehicle_fit:: compute_edgel_matches(const vcl_vector > >& curves, const vil_image_view& edge_map, vcl_vector >& edgel_snaps, @@ -624,8 +624,8 @@ compute_edgel_matches(const vcl_vector > >& curv //: Compute all edgel matches and weights in view \a idx // This is primarily for debugging -void modrec_vehicle_fit:: -last_edgel_matches(const modrec_pca_vehicle_projector& projector, +void dml_vehicle_fit:: +last_edgel_matches(const dml_pca_vehicle_projector& projector, const vil_image_view& edge_map, vcl_vector >& edgel_snaps, vcl_vector >& edgels, @@ -643,7 +643,7 @@ last_edgel_matches(const modrec_pca_vehicle_projector& projector, //: Compute the number of pixel size edge points with an edge neighbor within \a dist_thresh // return the total samples and number of matches -void modrec_vehicle_fit:: +void dml_vehicle_fit:: compute_edgel_coverage(const vcl_vector > >& curves, const vil_image_view& edge_map, double dist_thresh, @@ -691,8 +691,8 @@ compute_edgel_coverage(const vcl_vector > >& cur //: Compute the number of pixel size edge points with an edge neighbor within \a dist_thresh // return the total samples and number of matches for both contours and part boundaries -void modrec_vehicle_fit:: -last_edgel_coverage(const modrec_pca_vehicle_projector& projector, +void dml_vehicle_fit:: +last_edgel_coverage(const dml_pca_vehicle_projector& projector, const vil_image_view& edge_map, double dist_thresh, unsigned int& num_contour_match, @@ -711,7 +711,7 @@ last_edgel_coverage(const modrec_pca_vehicle_projector& projector, //: estimate the initial scale given the set of Jacobians -double modrec_vehicle_fit:: +double dml_vehicle_fit:: estimate_initial_scale(const vnl_vector& sigma, const vcl_vector > >& J) { diff --git a/modrec/modrec_vehicle_fit.h b/dml/dml_vehicle_fit.h similarity index 89% rename from modrec/modrec_vehicle_fit.h rename to dml/dml_vehicle_fit.h index 64ab7a3..3b0f914 100644 --- a/modrec/modrec_vehicle_fit.h +++ b/dml/dml_vehicle_fit.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_fit.h -#ifndef modrec_vehicle_fit_h_ -#define modrec_vehicle_fit_h_ +// This is dml/dml_vehicle_fit.h +#ifndef dml_vehicle_fit_h_ +#define dml_vehicle_fit_h_ //========================================================================= //: // \file @@ -21,8 +21,8 @@ //========================================================================= -#include -#include +#include +#include #include #include #include @@ -31,12 +31,12 @@ //: A base class for fitting a PCA vehicle model with parts -class modrec_vehicle_fit +class dml_vehicle_fit { public: //: Constructor - modrec_vehicle_fit(); + dml_vehicle_fit(); //: clear all the data and reset to the initial setup virtual void reset() = 0; @@ -82,22 +82,22 @@ class modrec_vehicle_fit //: Fits the model parameters: PCA, translation, rotation to the image. void fit_model(unsigned int num_itr, - modrec_pca_vehicle& mesh, + dml_pca_vehicle& mesh, vgl_vector_3d& t, vgl_rotation_3d& R); //: One iteration of fitting PCA, translation, rotation to the image. // return true if the iteration successfully reached a lower residual - bool fit_model_once(modrec_pca_vehicle& mesh, - vgl_vector_3d& translation, - vgl_rotation_3d& rotation, - vnl_vector& soln, - double& last_residual, - bool compute_visibility); + bool fit_model_once(dml_pca_vehicle& mesh, + vgl_vector_3d& translation, + vgl_rotation_3d& rotation, + vnl_vector& soln, + double& last_residual, + bool compute_visibility); //: Evaluate the residual at the current state and scale // this function is for generating a plot of the error surface - double evaluate_residual(const modrec_pca_vehicle& mesh, + double evaluate_residual(const dml_pca_vehicle& mesh, const vgl_vector_3d& t, const vgl_rotation_3d& R, double scale, @@ -105,7 +105,7 @@ class modrec_vehicle_fit //: Compute the edgel matches and weights for the last projection of \a projector // This is primarily for debugging - void last_edgel_matches(const modrec_pca_vehicle_projector& projector, + void last_edgel_matches(const dml_pca_vehicle_projector& projector, const vil_image_view& edge_map, vcl_vector >& edgel_snaps, vcl_vector >& edgels, @@ -113,7 +113,7 @@ class modrec_vehicle_fit //: Compute the number of pixel size edge points with an edge neighbor within \a dist_thresh // return the total samples and number of matches for both contours and part boundaries - void last_edgel_coverage(const modrec_pca_vehicle_projector& projector, + void last_edgel_coverage(const dml_pca_vehicle_projector& projector, const vil_image_view& edge_map, double dist_thresh, unsigned int& num_contour_match, @@ -122,7 +122,7 @@ class modrec_vehicle_fit unsigned int& num_part_total) const; //: Estimate the initial M-estimator scale from parameter standard deviations - virtual double estimate_initial_scale(const modrec_pca_vehicle& mesh, + virtual double estimate_initial_scale(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, const vnl_vector& sigma) = 0; @@ -162,7 +162,7 @@ class modrec_vehicle_fit // Adds to the matrix \a M and vector \a b passed in. // Only recompute curve visiblity when \a compute_visibility is true. virtual void - compute_all_opt_terms(const modrec_pca_vehicle& mesh, + compute_all_opt_terms(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -173,7 +173,7 @@ class modrec_vehicle_fit //: Compute the residuals of optimization from all active views. virtual void - compute_all_residuals(const modrec_pca_vehicle& mesh, + compute_all_residuals(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, double& total_weight, @@ -181,7 +181,7 @@ class modrec_vehicle_fit //: Compute the prior terms and update M and b // \return the residual of the prior - virtual double compute_prior(const modrec_pca_vehicle& mesh, + virtual double compute_prior(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -205,7 +205,7 @@ class modrec_vehicle_fit //: Apply the solution vector to update the shape and pose parameters virtual void apply_solution(const vnl_vector& soln, - modrec_pca_vehicle& mesh, + dml_pca_vehicle& mesh, vgl_vector_3d& translation, vgl_rotation_3d& rotation); @@ -246,4 +246,4 @@ class modrec_vehicle_fit -#endif // modrec_vehicle_fit_h_ +#endif // dml_vehicle_fit_h_ diff --git a/modrec/modrec_vehicle_fit.py b/dml/dml_vehicle_fit.py similarity index 80% rename from modrec/modrec_vehicle_fit.py rename to dml/dml_vehicle_fit.py index a7016c4..6a721cb 100755 --- a/modrec/modrec_vehicle_fit.py +++ b/dml/dml_vehicle_fit.py @@ -6,7 +6,7 @@ # http://www.boost.org/LICENSE_1_0.txt) ########################################################################## -# This is modrec/modrec_vehicle_fit.py +# This is dml/dml_vehicle_fit.py ########################################################################## import os.path @@ -84,21 +84,21 @@ # load the ground truth model def load_truth(vehicle): print "--loading ground truth mesh--" - py_modrec.set_truth_mesh(geom_path+truth_model[vehicle]+"_m3.obj") + py_dml.set_truth_mesh(geom_path+truth_model[vehicle]+"_m3.obj") # load the image and camera data from files def load_data(vehicle, s, views): print "--loading images and cameras--" curr_img_path = img_path+v_img_path[vehicle] opened = [] - py_modrec.reset_views() + py_dml.reset_views() for i in views: img_file = curr_img_path+img_scale[s]+("%05d.jpg" % (i+1)) cam_file = curr_img_path+("%05d.cam" % (i+1)) if os.path.isfile(img_file) and os.path.isfile(cam_file): print ' ', i, img_file - py_modrec.set_image(i,img_file) - py_modrec.set_camera(i,cam_file) + py_dml.set_image(i,img_file) + py_dml.set_camera(i,cam_file) opened.append(i); else: break @@ -107,14 +107,14 @@ def load_data(vehicle, s, views): # load video data def load_video_data(video): print "--loading video and camera--" - py_modrec.set_fit_mode("video") - py_modrec.reset_views() + py_dml.set_fit_mode("video") + py_dml.reset_views() vid_file = video_path+video_files[video] cam_file = video_path+video_cameras[video] if os.path.isfile(vid_file) and os.path.isfile(cam_file): print ' ', vid_file - py_modrec.set_video(vid_file) - py_modrec.set_camera(0,cam_file) + py_dml.set_video(vid_file) + py_dml.set_camera(0,cam_file) else: print "video or camera file not found" print vid_file @@ -138,16 +138,16 @@ def load_rand_pose(pose_path): # fit with this initial pose def fit(R,t,pc): - py_modrec.set_translation(t) - py_modrec.set_rotation(R) - py_modrec.set_params(pc) - e0 = py_modrec.compute_error() - py_modrec.set_lambda(1.0) - py_modrec.fit_model(50) - e1 = py_modrec.compute_error() - t = py_modrec.get_translation() - R = py_modrec.get_rotation() - pc = py_modrec.get_params() + py_dml.set_translation(t) + py_dml.set_rotation(R) + py_dml.set_params(pc) + e0 = py_dml.compute_error() + py_dml.set_lambda(1.0) + py_dml.fit_model(50) + e1 = py_dml.compute_error() + t = py_dml.get_translation() + R = py_dml.get_rotation() + pc = py_dml.get_params() return ((e0,e1), R, t, pc) @@ -165,11 +165,11 @@ def write_results(f, E, R, t, R2, t2, pc): # fit the model with many sample points of initialization def fit_in_region(vehicle,scale,options,views): - py_modrec.set_options(options) + py_dml.set_options(options) load_truth(vehicle) load_data(vehicle, scale,views) - model = py_modrec.get_vehicle_model() + model = py_dml.get_vehicle_model() rfile = results_path + 'region_' + vehicle + '_'+model+'_s'+str(scale)+'_pc5.txt' print "Writting output to:", rfile f=open(rfile,'w') @@ -219,16 +219,16 @@ def find_R_range(Ri,thresh): # compute the data for the CVPR paper table def find_convergence(vehicle,scale,options,views): - py_modrec.set_options(options) + py_dml.set_options(options) load_truth(vehicle) opened = load_data(vehicle, scale, views) - pc = py_modrec.get_params() + pc = py_dml.get_params() R = (0,0,0) t = (0,0,0) (E, R2, t2, pc) = fit(R,t,[]) - #EC = py_modrec.compute_edgel_coverage(1.0) + #EC = py_dml.compute_edgel_coverage(1.0) #cov_pct = float(EC[0]+EC[2])/(EC[1]+EC[3])*100.0; #print "coverage percent is", cov_pct #return @@ -268,18 +268,18 @@ def find_convergence(vehicle,scale,options,views): # compute the fit with several predetermined random initial poses def fit_random_pose(vehicle,scale,options,views): - py_modrec.set_options(options) + py_dml.set_options(options) load_truth(vehicle) opened = load_data(vehicle, scale, views) - pc = py_modrec.get_params() + pc = py_dml.get_params() - model_type = py_modrec.get_vehicle_model() + model_type = py_dml.get_vehicle_model() partsfile = "" if model_type[:-1] == "Detailed": partsfile = geom_path+truth_model[vehicle]+'.parts' print 'parts file = ', partsfile - py_modrec.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type], partsfile) - pc = py_modrec.get_params("all") + py_dml.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type], partsfile) + pc = py_dml.get_params("all") num_pc = options[-1] print "pc = ", pc[:num_pc] @@ -296,11 +296,11 @@ def fit_random_pose(vehicle,scale,options,views): R = (0,0,0) t = (0,0,0) - py_modrec.set_init_uncert(0.25) + py_dml.set_init_uncert(0.25) (E, R2, t2, pc) = fit(R,t,pc[:num_pc]) write_results(f, E, R, t, R2, t2, pc) - py_modrec.set_init_uncert(1.0) + py_dml.set_init_uncert(1.0) for pose in poses: t = pose[0:3] R = pose[3:6] @@ -312,44 +312,44 @@ def fit_random_pose(vehicle,scale,options,views): # compute the data for the CVPR paper table def make_svg(vehicle,scale,options,views): - py_modrec.set_options(options) + py_dml.set_options(options) opened = load_data(vehicle, scale, views) - pc = py_modrec.get_params() + pc = py_dml.get_params() R = (0,0,0) t = (0,0,0) - py_modrec.set_translation(t) - py_modrec.set_rotation(R) - py_modrec.set_params([]) - py_modrec.set_lambda(1.0) - py_modrec.fit_model(50) + py_dml.set_translation(t) + py_dml.set_rotation(R) + py_dml.set_params([]) + py_dml.set_lambda(1.0) + py_dml.fit_model(50) rfile = results_path + vehicle + '_s'+str(scale)+'_v'+str(len(opened))+'_pc'+str(len(pc)) if len(options) == 4: rfile += '_gnd' - py_modrec.write_svg_curves(views[0],rfile+'_'+str(opened[0]+1)+'.svg') + py_dml.write_svg_curves(views[0],rfile+'_'+str(opened[0]+1)+'.svg') # compute error for each number of params 0-15 def find_best_num_params(vehicle,scale): load_truth(vehicle) opened = load_data(vehicle, scale, range(10)) - model_type = py_modrec.get_vehicle_model() - py_modrec.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type]) - pc = py_modrec.get_params("all") + model_type = py_dml.get_vehicle_model() + py_dml.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type]) + pc = py_dml.get_params("all") options = ['tx','ty','tz','rx','ry','rz']# ['tx','ty','rz'] - py_modrec.set_params([]) + py_dml.set_params([]) E = [] for i in range(min(len(pc),16)): - py_modrec.set_options(options+[i]) - py_modrec.set_translation((0,0,0)) - py_modrec.set_rotation((0,0,0)) - py_modrec.set_params([])#pc[:i]) + py_dml.set_options(options+[i]) + py_dml.set_translation((0,0,0)) + py_dml.set_rotation((0,0,0)) + py_dml.set_params([])#pc[:i]) - py_modrec.set_lambda(1.0) - py_modrec.fit_model(50) - E.append(py_modrec.compute_error()) + py_dml.set_lambda(1.0) + py_dml.fit_model(50) + E.append(py_dml.compute_error()) return E @@ -375,20 +375,20 @@ def find_best_num_params_all(scale,model_type): # running tracking in video def track_vehicles(vehicle,video,sf,nf,options,model_type,track_with_silhouette): load_video_data(video) - py_modrec.set_options(options) - py_modrec.set_track_with_silhouette(track_with_silhouette) + py_dml.set_options(options) + py_dml.set_track_with_silhouette(track_with_silhouette) print "setting track with silhouette ",track_with_silhouette num_pc = options[-1] if num_pc == 0: - model_type = py_modrec.get_vehicle_model() + model_type = py_dml.get_vehicle_model() partsfile = "" if model_type[:-1] == "Detailed": partsfile = geom_path+truth_model[vehicle]+'.parts' print 'parts file = ', partsfile - py_modrec.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type], partsfile) - pc = py_modrec.get_params("all") + py_dml.set_mesh(geom_path+truth_model[vehicle]+truth_postfix[model_type], partsfile) + pc = py_dml.get_params("all") gnd = '' if len(options)==4: @@ -405,20 +405,20 @@ def track_vehicles(vehicle,video,sf,nf,options,model_type,track_with_silhouette) # prime the BG model with 100 frames num_bg_prime = 100 - py_modrec.enable_tracking(False) + py_dml.enable_tracking(False) if num_bg_prime > sf: num_bg_prime = sf - py_modrec.video_seek(sf-num_bg_prime) + py_dml.video_seek(sf-num_bg_prime) for i in range(num_bg_prime): - print "Current Frame: ",py_modrec.get_current_frame() - py_modrec.advance_video() - py_modrec.enable_tracking(True) + print "Current Frame: ",py_dml.get_current_frame() + py_dml.advance_video() + py_dml.enable_tracking(True) for i in range(nf): - py_modrec.advance_video() - frame = py_modrec.get_current_frame() - print "Current Frame: ",py_modrec.get_current_frame() - states = py_modrec.get_vehicle_states() + py_dml.advance_video() + frame = py_dml.get_current_frame() + print "Current Frame: ",py_dml.get_current_frame() + states = py_dml.get_vehicle_states() if not states: continue @@ -441,25 +441,25 @@ def track_vehicles(vehicle,video,sf,nf,options,model_type,track_with_silhouette) # sample the residual surface for later plotting def residual_surface(vehicle,scale,views): opened = load_data(vehicle, scale, views) - py_modrec.set_options([2]) - py_modrec.set_translation((0,0,0)) - py_modrec.set_rotation((0,0,0)) - py_modrec.set_params([]) - model_type = py_modrec.get_vehicle_model() + py_dml.set_options([2]) + py_dml.set_translation((0,0,0)) + py_dml.set_rotation((0,0,0)) + py_dml.set_params([]) + model_type = py_dml.get_vehicle_model() img_scale = 8.0; rfile = results_path + 'rsurf_'+vehicle+'_'+model_type+'_s'+str(scale)+'_is'+str(int(img_scale))+'.txt' print "Writting output to:", rfile f=open(rfile,'w') - res = py_modrec.evaluate_residual(img_scale,True) + res = py_dml.evaluate_residual(img_scale,True) r1 = range(-50,51) for i in r1: for j in r1: print "setting params", [i/100.0,j/100.0] - py_modrec.set_params([i/100.0,j/100.0]) - res = py_modrec.evaluate_residual(img_scale,False) + py_dml.set_params([i/100.0,j/100.0]) + res = py_dml.evaluate_residual(img_scale,False) f.write(str(res)+' ') f.write('\n') f.close() @@ -468,37 +468,37 @@ def residual_surface(vehicle,scale,views): # compute edge coverage def edge_coverage(vehicle,scale,views): opened = load_data(vehicle, scale, views) - py_modrec.set_mesh(geom_path+truth_model[vehicle]+"_poly.obj","poly") - py_modrec.set_parts(geom_path+truth_model[vehicle]+".parts") + py_dml.set_mesh(geom_path+truth_model[vehicle]+"_poly.obj","poly") + py_dml.set_parts(geom_path+truth_model[vehicle]+".parts") E = [] for i in range(40): - (m1,m2,total) = py_modrec.relative_coverage(float(i)/8.0) + (m1,m2,total) = py_dml.relative_coverage(float(i)/8.0) E.append( (float(i)/8.0, float(m1)/total, float(m2)/total) ) for i in range(40): print E[i][0], E[i][1], E[i][2] -def init_modrec(build_type): +def init_dml(build_type): sys.path.append("/projects/lems/bin/"+build_type+"/lib/") - global py_modrec - py_modrec = __import__("py_modrec") + global py_dml + py_dml = __import__("py_dml") if build_type == "Debug": print "Attach Debugger to", os.getpid() raw_input("Press Enter") print "--loading mesh parts and PCA parameters--" - py_modrec.set_vehicle_model("Dodecahedral") - py_modrec.set_pca(pca_path+"default_dodec.pca") - py_modrec.set_vehicle_model("Ferryman") - py_modrec.set_pca(pca_path+"default_ferryman.pca") - py_modrec.set_vehicle_model("Detailed1") - py_modrec.set_parts(pca_path+"default.parts") - py_modrec.set_pca(pca_path+"default1.pca") - py_modrec.set_vehicle_model("Detailed2") - py_modrec.set_parts(pca_path+"default.parts") - py_modrec.set_pca(pca_path+"default2.pca") - py_modrec.set_vehicle_model("Detailed3") - py_modrec.set_parts(pca_path+"default.parts") - py_modrec.set_pca(pca_path+"default3.pca") + py_dml.set_vehicle_model("Dodecahedral") + py_dml.set_pca(pca_path+"default_dodec.pca") + py_dml.set_vehicle_model("Ferryman") + py_dml.set_pca(pca_path+"default_ferryman.pca") + py_dml.set_vehicle_model("Detailed1") + py_dml.set_parts(pca_path+"default.parts") + py_dml.set_pca(pca_path+"default1.pca") + py_dml.set_vehicle_model("Detailed2") + py_dml.set_parts(pca_path+"default.parts") + py_dml.set_pca(pca_path+"default2.pca") + py_dml.set_vehicle_model("Detailed3") + py_dml.set_parts(pca_path+"default.parts") + py_dml.set_pca(pca_path+"default3.pca") # Call the main function if run from the command line @@ -555,10 +555,10 @@ def init_modrec(build_type): assert False, "unhandled option" - init_modrec(build_type) + init_dml(build_type) options.append(num_pc) - if not py_modrec.set_vehicle_model(model_type): + if not py_dml.set_vehicle_model(model_type): print "unable to set model type", model_type #fit_in_region(vehicle, scale,views) @@ -577,6 +577,6 @@ def init_modrec(build_type): elif func == "Track": track_vehicles(vehicle,video,start_frame,num_frames,options,model_type,track_with_silhouette) else: - init_modrec("Release") + init_dml("Release") diff --git a/modrec/modrec_vehicle_fit_multiview.cxx b/dml/dml_vehicle_fit_multiview.cxx similarity index 77% rename from modrec/modrec_vehicle_fit_multiview.cxx rename to dml/dml_vehicle_fit_multiview.cxx index aa106f5..f584b84 100644 --- a/modrec/modrec_vehicle_fit_multiview.cxx +++ b/dml/dml_vehicle_fit_multiview.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_fit_multiview.cxx +// This is dml/dml_vehicle_fit_multiview.cxx //========================================================================= //: // \file @@ -11,20 +11,20 @@ // //========================================================================= -#include "modrec_vehicle_fit_multiview.h" +#include "dml_vehicle_fit_multiview.h" //: Constructor -modrec_vehicle_fit_multiview::modrec_vehicle_fit_multiview() +dml_vehicle_fit_multiview::dml_vehicle_fit_multiview() : views_(1), sun_dir_(0.0,0.0,0.0) { } //: clear all the data and reset to the initial single frame setup -void modrec_vehicle_fit_multiview::reset() +void dml_vehicle_fit_multiview::reset() { views_.clear(); views_.resize(1); @@ -32,8 +32,9 @@ void modrec_vehicle_fit_multiview::reset() //: Assign an edge map at index \a idx -void modrec_vehicle_fit_multiview::set_edge_map(unsigned int idx, - const vil_image_view& edge_map) +void dml_vehicle_fit_multiview:: +set_edge_map(unsigned int idx, + const vil_image_view& edge_map) { if(idx >= views_.size()){ views_.resize(idx+1); @@ -44,8 +45,9 @@ void modrec_vehicle_fit_multiview::set_edge_map(unsigned int idx, //: Assign a camera at index \a idx -void modrec_vehicle_fit_multiview::set_camera(unsigned int idx, - const vpgl_perspective_camera& camera) +void dml_vehicle_fit_multiview:: +set_camera(unsigned int idx, + const vpgl_perspective_camera& camera) { if(idx >= views_.size()){ views_.resize(idx+1); @@ -55,7 +57,7 @@ void modrec_vehicle_fit_multiview::set_camera(unsigned int idx, //: Set the activity of index \a idx -void modrec_vehicle_fit_multiview::set_active(unsigned int idx, bool active) +void dml_vehicle_fit_multiview::set_active(unsigned int idx, bool active) { if(idx >= views_.size()){ views_.resize(idx+1); @@ -67,7 +69,7 @@ void modrec_vehicle_fit_multiview::set_active(unsigned int idx, bool active) //: Access the edge map at index \a idx // return the last edge map if the index is invalid const vil_image_view& -modrec_vehicle_fit_multiview::edge_map(unsigned int idx) const +dml_vehicle_fit_multiview::edge_map(unsigned int idx) const { if(idx >= views_.size()) return views_.back().edge_map; @@ -79,7 +81,7 @@ modrec_vehicle_fit_multiview::edge_map(unsigned int idx) const //: Access the camera at index \a idx // return the last camera if the index is invalid const vpgl_perspective_camera& -modrec_vehicle_fit_multiview::camera(unsigned int idx) const +dml_vehicle_fit_multiview::camera(unsigned int idx) const { if(idx >= views_.size()) return views_.back().camera; @@ -90,8 +92,8 @@ modrec_vehicle_fit_multiview::camera(unsigned int idx) const //: Access the vehicle projector at index \a idx // return the last projector if the index is invalid -const modrec_pca_vehicle_projector& -modrec_vehicle_fit_multiview::projector(unsigned int idx) const +const dml_pca_vehicle_projector& +dml_vehicle_fit_multiview::projector(unsigned int idx) const { if(idx >= views_.size()) return views_.back().projector; @@ -101,7 +103,7 @@ modrec_vehicle_fit_multiview::projector(unsigned int idx) const //: Return true if index \a idx is active -bool modrec_vehicle_fit_multiview::is_active(unsigned int idx) const +bool dml_vehicle_fit_multiview::is_active(unsigned int idx) const { if(idx >= views_.size()) return false; @@ -111,8 +113,9 @@ bool modrec_vehicle_fit_multiview::is_active(unsigned int idx) const //: Compute the edge map for index \a idx from the image \a img -void modrec_vehicle_fit_multiview::detect_and_set_edges(unsigned int idx, - const vil_image_view& img) +void dml_vehicle_fit_multiview:: +detect_and_set_edges(unsigned int idx, + const vil_image_view& img) { if(idx >= views_.size()){ views_.resize(idx+1); @@ -128,8 +131,8 @@ void modrec_vehicle_fit_multiview::detect_and_set_edges(unsigned int idx, //: Compute the terms for optimization from all active views // appends terms to the vector references passed in -void modrec_vehicle_fit_multiview:: -compute_all_opt_terms(const modrec_pca_vehicle& mesh, +void dml_vehicle_fit_multiview:: +compute_all_opt_terms(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -142,7 +145,7 @@ compute_all_opt_terms(const modrec_pca_vehicle& mesh, { if(!views_[idx].active) continue; - modrec_pca_vehicle_projector& mesh_projector = views_[idx].projector; + dml_pca_vehicle_projector& mesh_projector = views_[idx].projector; const vpgl_perspective_camera& camera = views_[idx].camera; const vil_image_view& edge_map = views_[idx].edge_map; @@ -171,8 +174,8 @@ compute_all_opt_terms(const modrec_pca_vehicle& mesh, } //: Compute the residuals of optimization from all active views. -void modrec_vehicle_fit_multiview:: -compute_all_residuals(const modrec_pca_vehicle& mesh, +void dml_vehicle_fit_multiview:: +compute_all_residuals(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, double& total_weight, @@ -182,7 +185,7 @@ compute_all_residuals(const modrec_pca_vehicle& mesh, { if(!views_[idx].active) continue; - modrec_pca_vehicle_projector& mesh_projector = views_[idx].projector; + dml_pca_vehicle_projector& mesh_projector = views_[idx].projector; const vpgl_perspective_camera& camera = views_[idx].camera; const vil_image_view& edge_map = views_[idx].edge_map; @@ -206,7 +209,7 @@ compute_all_residuals(const modrec_pca_vehicle& mesh, //: Default view constructor -modrec_vehicle_fit_multiview::view::view() +dml_vehicle_fit_multiview::view::view() : active(true), rel_scale(1.0) { vgl_point_3d c(5,5,5); @@ -217,17 +220,18 @@ modrec_vehicle_fit_multiview::view::view() //: Estimate the initial M-estimator scale from parameter standard deviations -double modrec_vehicle_fit_multiview::estimate_initial_scale(const modrec_pca_vehicle& mesh, - const vgl_vector_3d& translation, - const vgl_rotation_3d& rotation, - const vnl_vector& sigma) +double dml_vehicle_fit_multiview:: +estimate_initial_scale(const dml_pca_vehicle& mesh, + const vgl_vector_3d& translation, + const vgl_rotation_3d& rotation, + const vnl_vector& sigma) { double max_scale = 0.0; for(unsigned int idx=0; idx& camera = views_[idx].camera; mesh_projector.project(camera,mesh,rotation,translation,vgl_vector_3d(0,0,0),options_,num_pc_); @@ -240,7 +244,7 @@ double modrec_vehicle_fit_multiview::estimate_initial_scale(const modrec_pca_veh vcl_vector > > J(Jc); J.insert(J.end(), Jp.begin(), Jp.end()); - views_[idx].rel_scale = modrec_vehicle_fit::estimate_initial_scale(sigma,J); + views_[idx].rel_scale = dml_vehicle_fit::estimate_initial_scale(sigma,J); if(views_[idx].rel_scale > max_scale) max_scale = views_[idx].rel_scale; } diff --git a/modrec/modrec_vehicle_fit_multiview.h b/dml/dml_vehicle_fit_multiview.h similarity index 86% rename from modrec/modrec_vehicle_fit_multiview.h rename to dml/dml_vehicle_fit_multiview.h index e9d5e78..1a5fa0e 100644 --- a/modrec/modrec_vehicle_fit_multiview.h +++ b/dml/dml_vehicle_fit_multiview.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_fit_multiview.h -#ifndef modrec_vehicle_fit_multiview_h_ -#define modrec_vehicle_fit_multiview_h_ +// This is dml/dml_vehicle_fit_multiview.h +#ifndef dml_vehicle_fit_multiview_h_ +#define dml_vehicle_fit_multiview_h_ //========================================================================= //: // \file @@ -21,15 +21,15 @@ //========================================================================= -#include +#include //: Fit a PCA vehicle model with parts to multiple calibrated views -class modrec_vehicle_fit_multiview : public modrec_vehicle_fit +class dml_vehicle_fit_multiview : public dml_vehicle_fit { public: //: Constructor - modrec_vehicle_fit_multiview(); + dml_vehicle_fit_multiview(); //: clear all the data and reset to the initial single frame setup virtual void reset(); @@ -51,7 +51,7 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit const vpgl_perspective_camera& camera(unsigned int idx) const; //: Access the vehicle projector at index \a idx // return the last projector if the index is invalid - const modrec_pca_vehicle_projector& projector(unsigned int idx) const; + const dml_pca_vehicle_projector& projector(unsigned int idx) const; //: Return true if index \a idx is active bool is_active(unsigned int idx) const; @@ -59,7 +59,7 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit unsigned int num_views() const { return views_.size(); } //: Estimate the initial M-estimator scale from parameter standard deviations - virtual double estimate_initial_scale(const modrec_pca_vehicle& mesh, + virtual double estimate_initial_scale(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, const vnl_vector& sigma); @@ -71,7 +71,7 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit // Adds to the matrix \a M and vector \a b passed in. // Only recompute curve visiblity when \a compute_visibility is true. virtual void - compute_all_opt_terms(const modrec_pca_vehicle& mesh, + compute_all_opt_terms(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -82,7 +82,7 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit //: Compute the residuals of optimization from all active views. virtual void - compute_all_residuals(const modrec_pca_vehicle& mesh, + compute_all_residuals(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, double& total_weight, @@ -101,7 +101,7 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit //: the camera vpgl_perspective_camera camera; //: the vehicle projector class - modrec_pca_vehicle_projector projector; + dml_pca_vehicle_projector projector; //: the relative M-estimator scale compared to other views double rel_scale; @@ -117,4 +117,4 @@ class modrec_vehicle_fit_multiview : public modrec_vehicle_fit -#endif // modrec_vehicle_fit_multiview_h_ +#endif // dml_vehicle_fit_multiview_h_ diff --git a/modrec/modrec_vehicle_fit_video.cxx b/dml/dml_vehicle_fit_video.cxx similarity index 92% rename from modrec/modrec_vehicle_fit_video.cxx rename to dml/dml_vehicle_fit_video.cxx index ec0908d..17ba250 100644 --- a/modrec/modrec_vehicle_fit_video.cxx +++ b/dml/dml_vehicle_fit_video.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_fit_video.cxx +// This is dml/dml_vehicle_fit_video.cxx //========================================================================= //: // \file @@ -11,12 +11,12 @@ // //========================================================================= -#include "modrec_vehicle_fit_video.h" +#include "dml_vehicle_fit_video.h" #include #include #include #include -#include +#include #include #include #include @@ -26,10 +26,10 @@ #include //: update the tracker with the edge map -class modrec_edgemap_observer: public vpro_observer +class dml_edgemap_observer: public vpro_observer { public: - modrec_edgemap_observer(modrec_vehicle_fit_video& opt) + dml_edgemap_observer(dml_vehicle_fit_video& opt) : optimizer(opt) {} //: Called by the process when the data is ready @@ -47,7 +47,7 @@ class modrec_edgemap_observer: public vpro_observer } return true; } - modrec_vehicle_fit_video& optimizer; + dml_vehicle_fit_video& optimizer; }; @@ -56,7 +56,7 @@ class modrec_edgemap_observer: public vpro_observer //: Constructor -modrec_vehicle_fit_video::modrec_vehicle_fit_video() +dml_vehicle_fit_video::dml_vehicle_fit_video() : sun_dir_(0.0,0.0,0.0), tracker_(this), track_with_silhouette_(false) { vgl_point_3d c(5,5,5); @@ -65,19 +65,19 @@ modrec_vehicle_fit_video::modrec_vehicle_fit_video() camera_.look_at(vgl_homg_point_3d(0,0,0.5)); tracker_.set_camera(camera_); - tracker_.add_edgemap_observer(new modrec_edgemap_observer(*this)); + tracker_.add_edgemap_observer(new dml_edgemap_observer(*this)); } //: clear all the data and reset to the initial single frame setup -void modrec_vehicle_fit_video::reset() +void dml_vehicle_fit_video::reset() { } //: Assign an edge map -void modrec_vehicle_fit_video::set_edge_map(const vil_image_view& edge_map) +void dml_vehicle_fit_video::set_edge_map(const vil_image_view& edge_map) { edge_map_ = edge_map; projector_.resize(edge_map.ni(),edge_map.nj()); @@ -85,14 +85,14 @@ void modrec_vehicle_fit_video::set_edge_map(const vil_image_view& edge_ma //: Assign a vehicle silhouette -void modrec_vehicle_fit_video::set_silhouette(const vgl_polygon& sil) +void dml_vehicle_fit_video::set_silhouette(const vgl_polygon& sil) { silhouette_ = sil; } //: Assign a camera -void modrec_vehicle_fit_video::set_camera(const vpgl_perspective_camera& camera) +void dml_vehicle_fit_video::set_camera(const vpgl_perspective_camera& camera) { camera_ = camera; tracker_.set_camera(camera); @@ -100,7 +100,7 @@ void modrec_vehicle_fit_video::set_camera(const vpgl_perspective_camera& //: Set the sun direction for shadow casting -void modrec_vehicle_fit_video::set_sun_direction(const vgl_vector_3d& sun_dir) +void dml_vehicle_fit_video::set_sun_direction(const vgl_vector_3d& sun_dir) { sun_dir_ = sun_dir; tracker_.set_sun_direction(sun_dir); @@ -108,22 +108,22 @@ void modrec_vehicle_fit_video::set_sun_direction(const vgl_vector_3d& su //: set the video input stream -void modrec_vehicle_fit_video::set_istream(const vidl_istream_sptr& istream) +void dml_vehicle_fit_video::set_istream(const vidl_istream_sptr& istream) { tracker_.set_istream(istream); } //: enable or disable tracking using silhouette matching terms -void modrec_vehicle_fit_video::set_track_with_silhouette(bool val) +void dml_vehicle_fit_video::set_track_with_silhouette(bool val) { track_with_silhouette_ = val; } //: Assign the PCA vehicle model -void modrec_vehicle_fit_video:: -set_vehicle_model(const modrec_pca_vehicle& vehicle) +void dml_vehicle_fit_video:: +set_vehicle_model(const dml_pca_vehicle& vehicle) { vehicle_ = vehicle; tracker_.set_vehicle_model(vehicle); @@ -132,14 +132,14 @@ set_vehicle_model(const modrec_pca_vehicle& vehicle) //: Access the edge map const vil_image_view& -modrec_vehicle_fit_video::edge_map() const +dml_vehicle_fit_video::edge_map() const { return edge_map_; } //: Access the silhouette polygon const vgl_polygon& -modrec_vehicle_fit_video::silhouette() const +dml_vehicle_fit_video::silhouette() const { return silhouette_; } @@ -147,22 +147,22 @@ modrec_vehicle_fit_video::silhouette() const //: Access the camera const vpgl_perspective_camera& -modrec_vehicle_fit_video::camera() const +dml_vehicle_fit_video::camera() const { return camera_; } //: Access the vehicle projector -const modrec_pca_vehicle_projector& -modrec_vehicle_fit_video::projector() const +const dml_pca_vehicle_projector& +dml_vehicle_fit_video::projector() const { return projector_; } //: Compute the edge map from the image \a img -void modrec_vehicle_fit_video:: +void dml_vehicle_fit_video:: detect_and_set_edges(const vil_image_view& img) { // detect edges using the base class function @@ -173,8 +173,8 @@ detect_and_set_edges(const vil_image_view& img) //: Compute the terms for optimization from all active views // appends terms to the vector references passed in -void modrec_vehicle_fit_video:: -compute_all_opt_terms(const modrec_pca_vehicle& mesh, +void dml_vehicle_fit_video:: +compute_all_opt_terms(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -228,8 +228,8 @@ compute_all_opt_terms(const modrec_pca_vehicle& mesh, //: Compute the residuals of optimization from all active views. -void modrec_vehicle_fit_video:: -compute_all_residuals(const modrec_pca_vehicle& mesh, +void dml_vehicle_fit_video:: +compute_all_residuals(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, double& total_weight, @@ -245,7 +245,7 @@ compute_all_residuals(const modrec_pca_vehicle& mesh, //: Compute silhouette errors -void modrec_vehicle_fit_video:: +void dml_vehicle_fit_video:: compute_silhouette_errors(const vcl_vector >& pts, const vcl_vector >& norms, const vgl_polygon& silhouette, @@ -327,10 +327,11 @@ compute_silhouette_errors(const vcl_vector >& pts, //: Estimate the initial M-estimator scale from parameter standard deviations -double modrec_vehicle_fit_video::estimate_initial_scale(const modrec_pca_vehicle& mesh, - const vgl_vector_3d& translation, - const vgl_rotation_3d& rotation, - const vnl_vector& sigma) +double dml_vehicle_fit_video:: +estimate_initial_scale(const dml_pca_vehicle& mesh, + const vgl_vector_3d& translation, + const vgl_rotation_3d& rotation, + const vnl_vector& sigma) { projector_.project(camera_,mesh,rotation,translation,vgl_vector_3d(0,0,0),options_,num_pc_); @@ -341,12 +342,12 @@ double modrec_vehicle_fit_video::estimate_initial_scale(const modrec_pca_vehicle vcl_vector > > J(Jc); J.insert(J.end(), Jp.begin(), Jp.end()); - return modrec_vehicle_fit::estimate_initial_scale(sigma,J); + return dml_vehicle_fit::estimate_initial_scale(sigma,J); } //: Compute the optimization terms involving the silhouette and update M and b -double modrec_vehicle_fit_video:: +double dml_vehicle_fit_video:: compute_silhouette_opt_terms(vnl_matrix& M, vnl_vector& b) { @@ -422,8 +423,8 @@ compute_silhouette_opt_terms(vnl_matrix& M, //: Compute the prior terms and update M and b -double modrec_vehicle_fit_video:: -compute_prior(const modrec_pca_vehicle& mesh, +double dml_vehicle_fit_video:: +compute_prior(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -434,7 +435,7 @@ compute_prior(const modrec_pca_vehicle& mesh, prior_inv_covar_.rows() != M.rows()+2 ) { vcl_cerr << "prior data not the correct size, using default prior"<& soln, - modrec_pca_vehicle& mesh, + dml_pca_vehicle& mesh, vgl_vector_3d& translation, vgl_rotation_3d& rotation) { // apply the base class updates - modrec_vehicle_fit::apply_solution(soln,mesh,translation,rotation); + dml_vehicle_fit::apply_solution(soln,mesh,translation,rotation); if(soln.size() == num_params_+2){ t_velocity_ += soln[num_params_]; @@ -526,7 +527,7 @@ apply_solution(const vnl_vector& soln, //: Rotate the pose rows and columns of the covariance -vnl_matrix modrec_vehicle_fit_video:: +vnl_matrix dml_vehicle_fit_video:: rotate_covariance(const vgl_rotation_3d& rotation, const vnl_matrix& covar) const { @@ -573,8 +574,8 @@ rotate_covariance(const vgl_rotation_3d& rotation, //: Construct the fitting priors from the tracking state //: \note The state may have additional parameters to be stripped out, // and parameters may be in a different order. -void modrec_vehicle_fit_video:: -set_priors_from_track(const modrec_vehicle_state& state) +void dml_vehicle_fit_video:: +set_priors_from_track(const dml_vehicle_state& state) { unsigned int tvi = num_params_; unsigned int avi = num_params_+1; @@ -729,8 +730,8 @@ set_priors_from_track(const modrec_vehicle_state& state) //: Update the tracker covariance with the residual fitting covariance // The residual covariance needs to be rotated back to world orientation -void modrec_vehicle_fit_video:: -update_posterior_covariance(const modrec_pca_vehicle& mesh, +void dml_vehicle_fit_video:: +update_posterior_covariance(const dml_pca_vehicle& mesh, const vgl_vector_3d& t, const vgl_rotation_3d& R, vnl_matrix& covar, @@ -843,7 +844,7 @@ update_posterior_covariance(const modrec_pca_vehicle& mesh, //: Apply fitting to correct the predicted state bool -modrec_vehicle_fit_video::correct_state(modrec_vehicle_state& state) +dml_vehicle_fit_video::correct_state(dml_vehicle_state& state) { vgl_vector_3d t = state.translation; vgl_rotation_3d R = state.rotation; diff --git a/modrec/modrec_vehicle_fit_video.h b/dml/dml_vehicle_fit_video.h similarity index 84% rename from modrec/modrec_vehicle_fit_video.h rename to dml/dml_vehicle_fit_video.h index 4f86350..55a117c 100644 --- a/modrec/modrec_vehicle_fit_video.h +++ b/dml/dml_vehicle_fit_video.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_fit_video.h -#ifndef modrec_vehicle_fit_video_h_ -#define modrec_vehicle_fit_video_h_ +// This is dml/dml_vehicle_fit_video.h +#ifndef dml_vehicle_fit_video_h_ +#define dml_vehicle_fit_video_h_ //========================================================================= //: // \file @@ -20,18 +20,18 @@ //========================================================================= -#include -#include -#include +#include +#include +#include #include //: Fit a PCA vehicle model with parts to video -class modrec_vehicle_fit_video : public modrec_vehicle_fit +class dml_vehicle_fit_video : public dml_vehicle_fit { public: //: Constructor - modrec_vehicle_fit_video(); + dml_vehicle_fit_video(); //: clear all the data and reset to the initial single frame setup virtual void reset(); @@ -49,7 +49,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: set the video input stream void set_istream(const vidl_istream_sptr& istream); //: Assign the PCA vehicle model - void set_vehicle_model(const modrec_pca_vehicle& vehicle); + void set_vehicle_model(const dml_pca_vehicle& vehicle); //: enable or disable tracking using silhouette matching terms void set_track_with_silhouette(bool val); @@ -61,10 +61,10 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: Access the camera const vpgl_perspective_camera& camera() const; //: Access the vehicle projector - const modrec_pca_vehicle_projector& projector() const; + const dml_pca_vehicle_projector& projector() const; //: Apply fitting to correct the predicted state - bool correct_state(modrec_vehicle_state& state); + bool correct_state(dml_vehicle_state& state); //: advance the video and process on frame @@ -74,7 +74,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit void enable_tracking(bool enable) { tracker_.enable_tracking(enable); } //: Provide access to the tracker - modrec_vehicle_tracker& tracker() { return tracker_; } + dml_vehicle_tracker& tracker() { return tracker_; } //: Compute silhouette errors static void @@ -84,7 +84,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit vcl_vector& errors); //: Estimate the initial M-estimator scale from parameter standard deviations - virtual double estimate_initial_scale(const modrec_pca_vehicle& mesh, + virtual double estimate_initial_scale(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, const vnl_vector& sigma); @@ -95,7 +95,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit // Adds to the matrix \a M and vector \a b passed in. // Only recompute curve visiblity when \a compute_visibility is true. virtual void - compute_all_opt_terms(const modrec_pca_vehicle& mesh, + compute_all_opt_terms(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -106,7 +106,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: Compute the residuals of optimization from all active views. virtual void - compute_all_residuals(const modrec_pca_vehicle& mesh, + compute_all_residuals(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, double& total_weight, @@ -114,7 +114,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: Compute the prior terms and update M and b virtual double - compute_prior(const modrec_pca_vehicle& mesh, + compute_prior(const dml_pca_vehicle& mesh, const vgl_vector_3d& translation, const vgl_rotation_3d& rotation, vnl_matrix& M, @@ -133,11 +133,11 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: Construct the fitting priors from the tracking state //: \note The state may have additional parameters to be stripped out, // and parameters may be in a different order. - void set_priors_from_track(const modrec_vehicle_state& state); + void set_priors_from_track(const dml_vehicle_state& state); //: Update the tracker covariance with the residual fitting covariance // The residual covariance needs to be rotated back to world orientation - void update_posterior_covariance(const modrec_pca_vehicle& mesh, + void update_posterior_covariance(const dml_pca_vehicle& mesh, const vgl_vector_3d& t, const vgl_rotation_3d& R, vnl_matrix& covar, @@ -145,7 +145,7 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: Apply the solution vector to update the shape and pose parameters virtual void apply_solution(const vnl_vector& soln, - modrec_pca_vehicle& mesh, + dml_pca_vehicle& mesh, vgl_vector_3d& translation, vgl_rotation_3d& rotation); @@ -159,11 +159,11 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit //: the direction of sunlight for shadow casting vgl_vector_3d sun_dir_; //: the vehicle projector class - modrec_pca_vehicle_projector projector_; + dml_pca_vehicle_projector projector_; //: The deformable vehicle model - modrec_pca_vehicle vehicle_; + dml_pca_vehicle vehicle_; //: helper class for tracking - modrec_vehicle_tracker tracker_; + dml_vehicle_tracker tracker_; //: enable silhouette terms in tracking optimization bool track_with_silhouette_; @@ -185,4 +185,4 @@ class modrec_vehicle_fit_video : public modrec_vehicle_fit -#endif // modrec_vehicle_fit_video_h_ +#endif // dml_vehicle_fit_video_h_ diff --git a/modrec/modrec_vehicle_mesh.cxx b/dml/dml_vehicle_mesh.cxx similarity index 91% rename from modrec/modrec_vehicle_mesh.cxx rename to dml/dml_vehicle_mesh.cxx index 81192bc..309f797 100644 --- a/modrec/modrec_vehicle_mesh.cxx +++ b/dml/dml_vehicle_mesh.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_mesh.cxx +// This is dml/dml_vehicle_mesh.cxx // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -9,7 +9,7 @@ // \file -#include "modrec_vehicle_mesh.h" +#include "dml_vehicle_mesh.h" #include #include #include @@ -31,8 +31,8 @@ double get_param(const vcl_string& name, const vcl_map& param //: Read the vehicle parameters from a file -void modrec_read_vehicle_params(const vcl_string filename, - vcl_map& params) +void dml_read_vehicle_params(const vcl_string filename, + vcl_map& params) { vcl_ifstream fh(filename.c_str()); @@ -47,7 +47,7 @@ void modrec_read_vehicle_params(const vcl_string filename, //: Return the mean vehicle params -vcl_map modrec_read_vehicle_params() +vcl_map dml_read_vehicle_params() { vcl_map p; p["base_offset"] = 0.105309; @@ -86,26 +86,26 @@ vcl_map modrec_read_vehicle_params() //: Generate the complete vehicle mesh -void modrec_generate_vehicle(const vcl_map& params, - imesh_mesh& mesh) +void dml_generate_vehicle(const vcl_map& params, + imesh_mesh& mesh) { double r1 = get_param("wheel_rad",params); double r2 = r1+get_param("tire_thick",params); double ww = get_param("wheel_width",params); - vcl_auto_ptr verts(modrec_generate_vehicle_wheel_verts(r1,r2,ww)); - vcl_auto_ptr faces(modrec_generate_vehicle_wheel_faces()); - vcl_vector > texture(modrec_generate_vehicle_wheel_tex()); + vcl_auto_ptr verts(dml_generate_vehicle_wheel_verts(r1,r2,ww)); + vcl_auto_ptr faces(dml_generate_vehicle_wheel_faces()); + vcl_vector > texture(dml_generate_vehicle_wheel_tex()); imesh_mesh wheel_mesh_1(verts,faces); imesh_mesh wheel_mesh_2(wheel_mesh_1); imesh_mesh wheel_mesh_3(wheel_mesh_1); imesh_mesh wheel_mesh_4(wheel_mesh_1); - wheel_mesh_1.set_tex_coords(modrec_generate_vehicle_wheel_tex(1)); - wheel_mesh_2.set_tex_coords(modrec_generate_vehicle_wheel_tex(2)); - wheel_mesh_3.set_tex_coords(modrec_generate_vehicle_wheel_tex(3)); - wheel_mesh_4.set_tex_coords(modrec_generate_vehicle_wheel_tex(4)); + wheel_mesh_1.set_tex_coords(dml_generate_vehicle_wheel_tex(1)); + wheel_mesh_2.set_tex_coords(dml_generate_vehicle_wheel_tex(2)); + wheel_mesh_3.set_tex_coords(dml_generate_vehicle_wheel_tex(3)); + wheel_mesh_4.set_tex_coords(dml_generate_vehicle_wheel_tex(4)); double wb = get_param("wheel_base",params); double bw = get_param("body_width",params); @@ -121,14 +121,14 @@ void modrec_generate_vehicle(const vcl_map& params, vgl_vector_3d(-wb/2,-bw/2,r2)); - verts = (modrec_generate_vehicle_body_verts(params)); - faces = (modrec_generate_vehicle_body_faces()); + verts = (dml_generate_vehicle_body_verts(params)); + faces = (dml_generate_vehicle_body_faces()); mesh.set_vertices(verts); mesh.set_faces(faces); imesh_transform_inplace(mesh,vgl_vector_3d(0,0,r2+so)); - mesh.set_tex_coords(modrec_generate_vehicle_body_tex()); + mesh.set_tex_coords(dml_generate_vehicle_body_tex()); mesh.merge(wheel_mesh_1); mesh.merge(wheel_mesh_2); @@ -138,7 +138,7 @@ void modrec_generate_vehicle(const vcl_map& params, //: Generate the mesh faces for the vehicle body -vcl_auto_ptr modrec_generate_vehicle_body_faces() +vcl_auto_ptr dml_generate_vehicle_body_faces() { vcl_auto_ptr faces(new imesh_face_array); @@ -222,7 +222,7 @@ vcl_auto_ptr modrec_generate_vehicle_body_faces() //: Generate the mesh vertices for the vehicle body vcl_auto_ptr > -modrec_generate_vehicle_body_verts(const vcl_map& params) +dml_generate_vehicle_body_verts(const vcl_map& params) { vcl_auto_ptr > verts_ptr(new imesh_vertex_array<3>(127)); imesh_vertex_array<3>& verts = *verts_ptr; @@ -450,7 +450,7 @@ modrec_generate_vehicle_body_verts(const vcl_map& params) //: Generate the texture coords for the vehicle body vcl_vector > -modrec_generate_vehicle_body_tex() +dml_generate_vehicle_body_tex() { vcl_vector > tex(127,vgl_point_2d(0.5,0.5)); @@ -519,7 +519,7 @@ modrec_generate_vehicle_body_tex() //: Generate the mesh faces for the vehicle wheel (with \param rs radial samples) -vcl_auto_ptr modrec_generate_vehicle_wheel_faces(unsigned int rs) +vcl_auto_ptr dml_generate_vehicle_wheel_faces(unsigned int rs) { vcl_auto_ptr faces(new imesh_face_array); @@ -553,7 +553,7 @@ vcl_auto_ptr modrec_generate_vehicle_wheel_faces(unsigned // \params r2 is the tire outer radius // \params r3 is the tire width vcl_auto_ptr > -modrec_generate_vehicle_wheel_verts(double r1, double r2, double w, unsigned int rs) +dml_generate_vehicle_wheel_verts(double r1, double r2, double w, unsigned int rs) { vcl_auto_ptr > verts_ptr(new imesh_vertex_array<3>(2+rs*5)); @@ -580,7 +580,7 @@ modrec_generate_vehicle_wheel_verts(double r1, double r2, double w, unsigned int // if index == 0, center the wheel at the origin // else position the wheel in each of the four corners of the unit square vcl_vector > -modrec_generate_vehicle_wheel_tex(unsigned int index, unsigned int rs) +dml_generate_vehicle_wheel_tex(unsigned int index, unsigned int rs) { vcl_vector > tex(2+rs*5); @@ -617,27 +617,27 @@ modrec_generate_vehicle_wheel_tex(unsigned int index, unsigned int rs) // Dodecahedral mesh //: Generate the dodecahedral vehicle mesh -void modrec_generate_dodec_vehicle(const vcl_map& params, - imesh_mesh& mesh) +void dml_generate_dodec_vehicle(const vcl_map& params, + imesh_mesh& mesh) { double r1 = get_param("wheel_rad",params); double r2 = r1+get_param("tire_thick",params); double so = get_param("susp_offset",params); - vcl_auto_ptr verts(modrec_generate_dodec_vehicle_verts(params)); - vcl_auto_ptr faces(modrec_generate_dodec_vehicle_faces()); + vcl_auto_ptr verts(dml_generate_dodec_vehicle_verts(params)); + vcl_auto_ptr faces(dml_generate_dodec_vehicle_faces()); mesh.set_vertices(verts); mesh.set_faces(faces); imesh_transform_inplace(mesh,vgl_vector_3d(0,0,r2+so)); - //mesh.set_tex_coords(modrec_generate_dodec_vehicle_tex()); + //mesh.set_tex_coords(dml_generate_dodec_vehicle_tex()); } //: Generate the mesh vertices for the dodecahedral body vcl_auto_ptr > -modrec_generate_dodec_vehicle_verts(const vcl_map& params) +dml_generate_dodec_vehicle_verts(const vcl_map& params) { vcl_auto_ptr > verts_ptr(new imesh_vertex_array<3>(16)); imesh_vertex_array<3>& verts = *verts_ptr; @@ -793,7 +793,7 @@ modrec_generate_dodec_vehicle_verts(const vcl_map& params) //: Generate the mesh faces for the dodecahedral body vcl_auto_ptr -modrec_generate_dodec_vehicle_faces() +dml_generate_dodec_vehicle_faces() { vcl_auto_ptr faces(new imesh_face_array); @@ -835,15 +835,15 @@ modrec_generate_dodec_vehicle_faces() // "A Generic Deformable Model for Vehicle Recognition", BMVC 1995 //: Generate the ferryman vehicle mesh -void modrec_generate_ferryman_vehicle(const vcl_map& params, - imesh_mesh& mesh) +void dml_generate_ferryman_vehicle(const vcl_map& params, + imesh_mesh& mesh) { double r1 = get_param("wheel_rad",params); double r2 = r1+get_param("tire_thick",params); double so = get_param("susp_offset",params); - vcl_auto_ptr verts(modrec_generate_ferryman_vehicle_verts(params)); - vcl_auto_ptr faces(modrec_generate_ferryman_vehicle_faces()); + vcl_auto_ptr verts(dml_generate_ferryman_vehicle_verts(params)); + vcl_auto_ptr faces(dml_generate_ferryman_vehicle_faces()); mesh.set_vertices(verts); mesh.set_faces(faces); @@ -853,10 +853,10 @@ void modrec_generate_ferryman_vehicle(const vcl_map& params, //: Generate the mesh vertices for the Ferryman body vcl_auto_ptr > -modrec_generate_ferryman_vehicle_verts(const vcl_map& params) +dml_generate_ferryman_vehicle_verts(const vcl_map& params) { // the Dodecahedral model has a subset of the vertices in the Ferryman model - vcl_auto_ptr > verts_ptr(modrec_generate_dodec_vehicle_verts(params)); + vcl_auto_ptr > verts_ptr(dml_generate_dodec_vehicle_verts(params)); imesh_vertex_array<3>& verts = *verts_ptr; unsigned int start_idx = verts.size(); @@ -901,7 +901,7 @@ modrec_generate_ferryman_vehicle_verts(const vcl_map& params) //: Generate the mesh faces for the Ferryman body vcl_auto_ptr -modrec_generate_ferryman_vehicle_faces() +dml_generate_ferryman_vehicle_faces() { vcl_auto_ptr faces(new imesh_face_array); diff --git a/modrec/modrec_vehicle_mesh.h b/dml/dml_vehicle_mesh.h similarity index 64% rename from modrec/modrec_vehicle_mesh.h rename to dml/dml_vehicle_mesh.h index d816577..33d21c5 100644 --- a/modrec/modrec_vehicle_mesh.h +++ b/dml/dml_vehicle_mesh.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_mesh.h -#ifndef modrec_vehicle_mesh_h_ -#define modrec_vehicle_mesh_h_ +// This is dml/dml_vehicle_mesh.h +#ifndef dml_vehicle_mesh_h_ +#define dml_vehicle_mesh_h_ //: // \file @@ -23,36 +23,36 @@ //: Read the vehicle parameters from a file -void modrec_read_vehicle_params(const vcl_string filename, - vcl_map& params); +void dml_read_vehicle_params(const vcl_string filename, + vcl_map& params); //: Return the mean vehicle params -vcl_map modrec_read_vehicle_params(); +vcl_map dml_read_vehicle_params(); //: Generate the complete vehicle mesh -void modrec_generate_vehicle(const vcl_map& params, - imesh_mesh& mesh); +void dml_generate_vehicle(const vcl_map& params, + imesh_mesh& mesh); //: Generate the mesh faces for the vehicle body vcl_auto_ptr -modrec_generate_vehicle_body_faces(); +dml_generate_vehicle_body_faces(); //: Generate the mesh vertices for the vehicle body vcl_auto_ptr > -modrec_generate_vehicle_body_verts(const vcl_map& params); +dml_generate_vehicle_body_verts(const vcl_map& params); //: Generate the texture coords for the vehicle body vcl_vector > -modrec_generate_vehicle_body_tex(); +dml_generate_vehicle_body_tex(); //: Generate the mesh faces for the vehicle wheel (with \param rs radial samples) vcl_auto_ptr -modrec_generate_vehicle_wheel_faces(unsigned int rs = 16); +dml_generate_vehicle_wheel_faces(unsigned int rs = 16); //: Generate the mesh vertices for the vehicle wheel @@ -60,29 +60,29 @@ modrec_generate_vehicle_wheel_faces(unsigned int rs = 16); // \params r2 is the tire outer radius // \params r3 is the tire width vcl_auto_ptr > -modrec_generate_vehicle_wheel_verts(double r1, double r2, double w, unsigned int rs = 16); +dml_generate_vehicle_wheel_verts(double r1, double r2, double w, unsigned int rs = 16); //: Generate the texture coords for the vehicle wheel // if index == 0, center the wheel at the origin // else position the wheel in each of the four corners of the unit square vcl_vector > -modrec_generate_vehicle_wheel_tex(unsigned int index = 0, unsigned int rs = 16); +dml_generate_vehicle_wheel_tex(unsigned int index = 0, unsigned int rs = 16); // ============================================================================= // Dodecahedral mesh //: Generate the dodecahedral vehicle mesh -void modrec_generate_dodec_vehicle(const vcl_map& params, - imesh_mesh& mesh); +void dml_generate_dodec_vehicle(const vcl_map& params, + imesh_mesh& mesh); //: Generate the mesh vertices for the dodecahedral body vcl_auto_ptr > -modrec_generate_dodec_vehicle_verts(const vcl_map& params); +dml_generate_dodec_vehicle_verts(const vcl_map& params); //: Generate the mesh faces for the dodecahedral body vcl_auto_ptr -modrec_generate_dodec_vehicle_faces(); +dml_generate_dodec_vehicle_faces(); // ============================================================================= // Ferryman mesh @@ -90,16 +90,16 @@ modrec_generate_dodec_vehicle_faces(); // "A Generic Deformable Model for Vehicle Recognition", BMVC 1995 //: Generate the ferryman vehicle mesh -void modrec_generate_ferryman_vehicle(const vcl_map& params, - imesh_mesh& mesh); +void dml_generate_ferryman_vehicle(const vcl_map& params, + imesh_mesh& mesh); //: Generate the mesh vertices for the Ferryman body vcl_auto_ptr > -modrec_generate_ferryman_vehicle_verts(const vcl_map& params); +dml_generate_ferryman_vehicle_verts(const vcl_map& params); //: Generate the mesh faces for the Ferryman body vcl_auto_ptr -modrec_generate_ferryman_vehicle_faces(); +dml_generate_ferryman_vehicle_faces(); -#endif // modrec_vehicle_mesh_h_ +#endif // dml_vehicle_mesh_h_ diff --git a/modrec/modrec_vehicle_parts.cxx b/dml/dml_vehicle_parts.cxx similarity index 88% rename from modrec/modrec_vehicle_parts.cxx rename to dml/dml_vehicle_parts.cxx index d491b06..808fd11 100644 --- a/modrec/modrec_vehicle_parts.cxx +++ b/dml/dml_vehicle_parts.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_parts.cxx +// This is dml/dml_vehicle_parts.cxx // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -9,14 +9,14 @@ // \file -#include "modrec_vehicle_parts.h" +#include "dml_vehicle_parts.h" #include #include //: read the vehicle parts from a file vcl_map > -modrec_read_vehicle_parts(const vcl_string filename) +dml_read_vehicle_parts(const vcl_string filename) { vcl_map > parts; vcl_ifstream fh(filename.c_str()); @@ -60,8 +60,8 @@ modrec_read_vehicle_parts(const vcl_string filename) //: write the vehicle parts to a file void -modrec_write_vehicle_parts(const vcl_string filename, - const vcl_map >& parts) +dml_write_vehicle_parts(const vcl_string filename, + const vcl_map >& parts) { typedef vcl_map > pmap; vcl_ofstream fh(filename.c_str()); @@ -83,8 +83,8 @@ modrec_write_vehicle_parts(const vcl_string filename, //: write the vehicle parts as an SVG file -void modrec_write_svg(const vcl_string& file, - const vcl_map >& paths) +void dml_write_svg(const vcl_string& file, + const vcl_map >& paths) { vcl_ofstream fh(file.c_str()); fh << "\n" diff --git a/modrec/modrec_vehicle_parts.h b/dml/dml_vehicle_parts.h similarity index 59% rename from modrec/modrec_vehicle_parts.h rename to dml/dml_vehicle_parts.h index 52f1937..dfb5532 100644 --- a/modrec/modrec_vehicle_parts.h +++ b/dml/dml_vehicle_parts.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_parts.h -#ifndef modrec_vehicle_parts_h_ -#define modrec_vehicle_parts_h_ +// This is dml/dml_vehicle_parts.h +#ifndef dml_vehicle_parts_h_ +#define dml_vehicle_parts_h_ //: // \file @@ -25,19 +25,19 @@ //: read the vehicle parts from a file vcl_map > -modrec_read_vehicle_parts(const vcl_string filename); +dml_read_vehicle_parts(const vcl_string filename); //: write the vehicle parts to a file void -modrec_write_vehicle_parts(const vcl_string filename, - const vcl_map >& parts); +dml_write_vehicle_parts(const vcl_string filename, + const vcl_map >& parts); //: write the vehicle parts as an SVG file -void modrec_write_svg(const vcl_string& file, - const vcl_map >& paths); +void dml_write_svg(const vcl_string& file, + const vcl_map >& paths); -#endif // modrec_vehicle_parts_h_ +#endif // dml_vehicle_parts_h_ diff --git a/modrec/modrec_vehicle_state.cxx b/dml/dml_vehicle_state.cxx similarity index 88% rename from modrec/modrec_vehicle_state.cxx rename to dml/dml_vehicle_state.cxx index 7212d9a..69b7742 100644 --- a/modrec/modrec_vehicle_state.cxx +++ b/dml/dml_vehicle_state.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_state.cxx +// This is dml/dml_vehicle_state.cxx //========================================================================= //: // \file @@ -11,19 +11,19 @@ // //========================================================================= -#include "modrec_vehicle_state.h" +#include "dml_vehicle_state.h" #include #include //: global count of unique tracks -unsigned int modrec_vehicle_state::next_id = 0; +unsigned int dml_vehicle_state::next_id = 0; //: stack shape, pose, and velocity into a single state vector vnl_vector -modrec_vehicle_state::state_vector() const +dml_vehicle_state::state_vector() const { vnl_vector s(params.size()+8); s[0] = translation.x(); @@ -39,7 +39,7 @@ modrec_vehicle_state::state_vector() const //: extract pose, velocity, and shape from a single state vector void -modrec_vehicle_state::set_state(const vnl_vector& s) +dml_vehicle_state::set_state(const vnl_vector& s) { translation.set(s[0],s[1],s[2]); vnl_vector_fixed r(s.data_block()+3); @@ -52,7 +52,7 @@ modrec_vehicle_state::set_state(const vnl_vector& s) //: initialize the covariance matrix -void modrec_vehicle_state::init_covar(bool estimate_shape) +void dml_vehicle_state::init_covar(bool estimate_shape) { unsigned int num = 8; if(estimate_shape) @@ -69,10 +69,10 @@ void modrec_vehicle_state::init_covar(bool estimate_shape) //: predict the next state (after time t elapsed) using the circular motion model -modrec_vehicle_state -modrec_circ_motion_predict(const modrec_vehicle_state& s, double t) +dml_vehicle_state +dml_circ_motion_predict(const dml_vehicle_state& s, double t) { - modrec_vehicle_state st; + dml_vehicle_state st; st.last_translation = s.translation; st.last_rotation = s.rotation; st.num_frames = s.num_frames; @@ -156,7 +156,7 @@ modrec_circ_motion_predict(const modrec_vehicle_state& s, double t) //: predict the position only (after time t elapsed) using the circular motion model vgl_vector_3d -modrec_circ_motion_predict_position(const modrec_vehicle_state& s, double t) +dml_circ_motion_predict_position(const dml_vehicle_state& s, double t) { const double& va = s.a_velocity; const double& vt = s.t_velocity; @@ -172,9 +172,9 @@ modrec_circ_motion_predict_position(const modrec_vehicle_state& s, double t) //: read a tracking result file unsigned int -modrec_read_track_file(const vcl_string& filename, - vcl_string& vid_file, vcl_string& cam_file, vcl_string& model_type, - vcl_map >& state_map) +dml_read_track_file(const vcl_string& filename, + vcl_string& vid_file, vcl_string& cam_file, vcl_string& model_type, + vcl_map >& state_map) { vcl_ifstream ifs(filename.c_str()); @@ -195,7 +195,7 @@ modrec_read_track_file(const vcl_string& filename, unsigned int frame_number = 0; while(ifs >> frame_number) { - modrec_vehicle_state state; + dml_vehicle_state state; // read the unique id ifs >> state.unique_id; diff --git a/modrec/modrec_vehicle_state.h b/dml/dml_vehicle_state.h similarity index 73% rename from modrec/modrec_vehicle_state.h rename to dml/dml_vehicle_state.h index 8f556c6..6b82124 100644 --- a/modrec/modrec_vehicle_state.h +++ b/dml/dml_vehicle_state.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_state.h -#ifndef modrec_vehicle_state_h_ -#define modrec_vehicle_state_h_ +// This is dml/dml_vehicle_state.h +#ifndef dml_vehicle_state_h_ +#define dml_vehicle_state_h_ //========================================================================= //: // \file @@ -31,18 +31,18 @@ //: A structure to store complete vehicle state -class modrec_vehicle_state +class dml_vehicle_state { public: - modrec_vehicle_state() + dml_vehicle_state() : t_velocity(0), a_velocity(0), num_frames(0) {} - modrec_vehicle_state(const vnl_vector& p, - const vgl_rotation_3d& r, - const vgl_vector_3d& t, - double vt = 0.0, - double va = 0.0, - bool estimate_shape = true) + dml_vehicle_state(const vnl_vector& p, + const vgl_rotation_3d& r, + const vgl_vector_3d& t, + double vt = 0.0, + double va = 0.0, + bool estimate_shape = true) : params(p), rotation(r), translation(t), t_velocity(vt), a_velocity(va), num_frames(0), mean_params(p.size(),0.0) { @@ -94,18 +94,18 @@ class modrec_vehicle_state //: predict the next state (after time t elapsed) using the circular motion model -modrec_vehicle_state -modrec_circ_motion_predict(const modrec_vehicle_state& s, double t); +dml_vehicle_state +dml_circ_motion_predict(const dml_vehicle_state& s, double t); //: predict the position only (after time t elapsed) using the circular motion model vgl_vector_3d -modrec_circ_motion_predict_position(const modrec_vehicle_state& s, double t); +dml_circ_motion_predict_position(const dml_vehicle_state& s, double t); //: read a tracking result file unsigned int -modrec_read_track_file(const vcl_string& filename, - vcl_string& vid_file, vcl_string& cam_file, vcl_string& model_type, - vcl_map >& state_map); +dml_read_track_file(const vcl_string& filename, + vcl_string& vid_file, vcl_string& cam_file, vcl_string& model_type, + vcl_map >& state_map); -#endif // modrec_vehicle_state_h_ +#endif // dml_vehicle_state_h_ diff --git a/modrec/modrec_vehicle_track_init.cxx b/dml/dml_vehicle_track_init.cxx similarity index 95% rename from modrec/modrec_vehicle_track_init.cxx rename to dml/dml_vehicle_track_init.cxx index 8fb8020..fffeee8 100644 --- a/modrec/modrec_vehicle_track_init.cxx +++ b/dml/dml_vehicle_track_init.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_track_init.cxx +// This is dml/dml_vehicle_track_init.cxx //========================================================================= //: // \file @@ -11,8 +11,8 @@ // //========================================================================= -#include "modrec_vehicle_track_init.h" -#include +#include "dml_vehicle_track_init.h" +#include #include #include @@ -21,8 +21,8 @@ #include -modrec_vehicle_track_init:: -modrec_vehicle_track_init(const vpgl_perspective_camera& cam) +dml_vehicle_track_init:: +dml_vehicle_track_init(const vpgl_perspective_camera& cam) : camera_(cam) , init_params_(5), estimate_shape_(true) { // Initial Dodecahedral params @@ -79,7 +79,7 @@ modrec_vehicle_track_init(const vpgl_perspective_camera& cam) //: Set the camera -void modrec_vehicle_track_init:: +void dml_vehicle_track_init:: set_camera(const vpgl_perspective_camera& camera) { camera_ = camera; @@ -100,7 +100,7 @@ set_camera(const vpgl_perspective_camera& camera) //: Set the sun direction for shadow casting -void modrec_vehicle_track_init:: +void dml_vehicle_track_init:: set_sun_direction(const vgl_vector_3d& sun_dir) { sun_dir_ = sun_dir; @@ -108,8 +108,8 @@ set_sun_direction(const vgl_vector_3d& sun_dir) //: Set the vehicle model -void modrec_vehicle_track_init:: -set_vehicle(const modrec_pca_vehicle& vehicle) +void dml_vehicle_track_init:: +set_vehicle(const dml_pca_vehicle& vehicle) { vehicle_ = vehicle; @@ -138,7 +138,7 @@ set_vehicle(const modrec_pca_vehicle& vehicle) //: test the silhouette polygon to see if it is a plausible vehicle -bool modrec_vehicle_track_init:: +bool dml_vehicle_track_init:: silhouette_plausible(const vgl_polygon& silhouette) { double area = vgl_area(silhouette); @@ -161,7 +161,7 @@ silhouette_plausible(const vgl_polygon& silhouette) //: estimate the Z rotation angle from optical flow vectors -double modrec_vehicle_track_init:: +double dml_vehicle_track_init:: estimate_angle(const vcl_vector& flow) { // use a histogram to estimate the vehicle direction robustly @@ -206,7 +206,7 @@ estimate_angle(const vcl_vector& flow) //: adjust the 3-d translation \a t to align the silhouette centroid to \a c. -vgl_vector_3d modrec_vehicle_track_init:: +vgl_vector_3d dml_vehicle_track_init:: align_centroids(const vgl_point_2d& c, const vgl_rotation_3d& R) { @@ -234,7 +234,7 @@ align_centroids(const vgl_point_2d& c, //: compute the errors in silhouette alignment -vcl_vector modrec_vehicle_track_init:: +vcl_vector dml_vehicle_track_init:: silhouette_error(const vgl_polygon& silhouette, vcl_vector >& norms) { @@ -258,7 +258,7 @@ silhouette_error(const vgl_polygon& silhouette, } vcl_vector errors, dist; - modrec_vehicle_fit_video:: + dml_vehicle_fit_video:: compute_silhouette_errors(pts,norms,silhouette,errors); return errors; @@ -266,7 +266,7 @@ silhouette_error(const vgl_polygon& silhouette, //: compute the tranlation and mesh params to align the silhouettes -double modrec_vehicle_track_init:: +double dml_vehicle_track_init:: fit_to_silhouette(const vgl_polygon& silhouette, const vgl_rotation_3d& R, vgl_vector_3d& t) @@ -343,7 +343,7 @@ fit_to_silhouette(const vgl_polygon& silhouette, //: compute the median silhouette_error -double modrec_vehicle_track_init:: +double dml_vehicle_track_init:: median_error(const vgl_polygon& silhouette, const vgl_rotation_3d& R, vgl_vector_3d& t) @@ -374,7 +374,7 @@ median_error(const vgl_polygon& silhouette, } vcl_vector errors, dist; - modrec_vehicle_fit_video:: + dml_vehicle_fit_video:: compute_silhouette_errors(pts,norms,silhouette,errors); for(unsigned int i=0; i polygon_bbox(const vgl_polygon& poly) //: match observed silhouettes and flow vectors to existing states // return a vector of unmatched silhouettes vcl_vector > -modrec_vehicle_track_init:: +dml_vehicle_track_init:: match_silhouettes(const vcl_vector >& silhouettes, const vcl_vector& flow, - vcl_vector& states) + vcl_vector& states) { vcl_vector > remain_sils(silhouettes); @@ -501,10 +501,10 @@ match_silhouettes(const vcl_vector >& silhouettes, //: Process the silhouettes and flow and estimate initial states // Also merge in states predicted from the previous frame void -modrec_vehicle_track_init:: +dml_vehicle_track_init:: find_states(const vcl_vector >& silhouettes, const vcl_vector& flow, - vcl_vector& states) + vcl_vector& states) { // match observed silhouettes and flow vectors to existing states vcl_vector > remain_sils = @@ -573,7 +573,7 @@ find_states(const vcl_vector >& silhouettes, } if(best_k >= 0){ - states.push_back(modrec_vehicle_state(best_p,rotation,translation,5,0,true)); + states.push_back(dml_vehicle_state(best_p,rotation,translation,5,0,true)); states.back().silhouette = curr_sil; } } @@ -585,7 +585,7 @@ find_states(const vcl_vector >& silhouettes, double sil_area = vgl_area(mesh_projector_.silhouette_polygon()); double area_ratio = (sil_area > target_area) ? target_area/sil_area : sil_area/target_area; if(area_ratio > 0.70){ - states.push_back(modrec_vehicle_state(vehicle_.params(),rotation,t,5,0,false)); + states.push_back(dml_vehicle_state(vehicle_.params(),rotation,t,5,0,false)); states.back().silhouette = curr_sil; } } diff --git a/modrec/modrec_vehicle_track_init.h b/dml/dml_vehicle_track_init.h similarity index 83% rename from modrec/modrec_vehicle_track_init.h rename to dml/dml_vehicle_track_init.h index 7b752f3..7b65a70 100644 --- a/modrec/modrec_vehicle_track_init.h +++ b/dml/dml_vehicle_track_init.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_track_init.h -#ifndef modrec_vehicle_track_init_h_ -#define modrec_vehicle_track_init_h_ +// This is dml/dml_vehicle_track_init.h +#ifndef dml_vehicle_track_init_h_ +#define dml_vehicle_track_init_h_ //========================================================================= //: // \file @@ -21,27 +21,27 @@ #include -#include -#include -#include +#include +#include +#include //: Initialize vehicle tracks from foreground outlines and optical flow -class modrec_vehicle_track_init +class dml_vehicle_track_init { public: typedef vcl_pair,vgl_vector_2d > pv_pair; enum vehicle_model { DODECAHEDRAL, FERRYMAN, DETAILED1, DETAILED2, DETAILED3 }; - modrec_vehicle_track_init(const vpgl_perspective_camera& cam = - vpgl_perspective_camera()); + dml_vehicle_track_init(const vpgl_perspective_camera& cam = + vpgl_perspective_camera()); //: Set the camera void set_camera(const vpgl_perspective_camera& camera); //: Set the sun direction for shadow casting void set_sun_direction(const vgl_vector_3d& sun_dir); //: Set the vehicle model - void set_vehicle(const modrec_pca_vehicle& vehicle); + void set_vehicle(const dml_pca_vehicle& vehicle); //: enable or disable shape estimation void set_estimate_shape(bool val) { estimate_shape_ = val; } @@ -75,14 +75,14 @@ class modrec_vehicle_track_init vcl_vector > match_silhouettes(const vcl_vector >& silhouettes, const vcl_vector& flow, - vcl_vector& states); + vcl_vector& states); //: Process the silhouettes and flow and estimate initial states. // Also merge in states predicted from the previous frame void find_states(const vcl_vector >& silhouettes, const vcl_vector& flow, - vcl_vector& states); + vcl_vector& states); private: //: The active camera @@ -90,11 +90,11 @@ class modrec_vehicle_track_init //: the direction of sunlight for shadow casting vgl_vector_3d sun_dir_; //: The deformable vehicle model - modrec_pca_vehicle vehicle_; + dml_pca_vehicle vehicle_; //: The type of vehicle model vehicle_model vehicle_type_; //: A class to project the vehicle into images - modrec_pca_vehicle_projector mesh_projector_; + dml_pca_vehicle_projector mesh_projector_; //: parameters used for initialization of shape vcl_vector > > init_params_; @@ -111,4 +111,4 @@ class modrec_vehicle_track_init -#endif // modrec_vehicle_track_init_h_ +#endif // dml_vehicle_track_init_h_ diff --git a/modrec/modrec_vehicle_tracker.cxx b/dml/dml_vehicle_tracker.cxx similarity index 92% rename from modrec/modrec_vehicle_tracker.cxx rename to dml/dml_vehicle_tracker.cxx index fc32e79..4f960ec 100644 --- a/modrec/modrec_vehicle_tracker.cxx +++ b/dml/dml_vehicle_tracker.cxx @@ -1,4 +1,4 @@ -// This is modrec/modrec_vehicle_tracker.cxx +// This is dml/dml_vehicle_tracker.cxx //========================================================================= //: // \file @@ -11,12 +11,12 @@ // //========================================================================= -#include "modrec_vehicle_tracker.h" +#include "dml_vehicle_tracker.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -61,7 +61,7 @@ void vsl_b_write(vsl_b_ostream& os, const vpdt_mixture_of& dummy){} //: A metric for edgel distances -struct modrec_edgel_metric +struct dml_edgel_metric { //: the data type used for the metric tensor typedef vnl_vector_fixed covar_type; @@ -147,7 +147,7 @@ struct modrec_edgel_metric // \note if rho = 1/(num observations) then this just an online cumulative average void vpdt_update_gaussian(vpdt_gaussian, vnl_vector_fixed, - modrec_edgel_metric> & gaussian, + dml_edgel_metric> & gaussian, float rho, const vnl_vector_fixed& sample ) { @@ -180,7 +180,7 @@ void vpdt_update_gaussian(vpdt_gaussian, // converge to the minimum value parameter rather than zero. void vpdt_update_gaussian(vpdt_gaussian, vnl_vector_fixed, - modrec_edgel_metric>& gaussian, + dml_edgel_metric>& gaussian, float rho, const vnl_vector_fixed& sample, float min_var) @@ -695,12 +695,12 @@ class track_init_filter : public vpro_filter assert(input_type_id(1) == typeid(vcl_vector)); vcl_vector flow = input >(1); - assert(input_type_id(2) == typeid(vcl_vector)); - vcl_vector states = - input >(2); + assert(input_type_id(2) == typeid(vcl_vector)); + vcl_vector states = + input >(2); if(!tracking_enabled_){ - output(0, vcl_vector()); + output(0, vcl_vector()); return VPRO_VALID; } @@ -716,7 +716,7 @@ class track_init_filter : public vpro_filter } //: Helper class to initialize tracks - modrec_vehicle_track_init track_init_; + dml_vehicle_track_init track_init_; bool tracking_enabled_; }; @@ -739,7 +739,7 @@ float min_eigenvalue(float a, float b, float c){ class track_correct_filter : public vpro_filter { public: - track_correct_filter(modrec_vehicle_fit_video* optimizer) + track_correct_filter(dml_vehicle_fit_video* optimizer) : optimizer_(optimizer) {} //: Destructor @@ -749,9 +749,9 @@ class track_correct_filter : public vpro_filter vpro_signal execute() { - assert(input_type_id(0) == typeid(vcl_vector)); - vcl_vector states = - input >(0); + assert(input_type_id(0) == typeid(vcl_vector)); + vcl_vector states = + input >(0); for(int i=0; icorrect_state(states[i]) || states[i].params.inf_norm() > 1.0) @@ -767,7 +767,7 @@ class track_correct_filter : public vpro_filter return VPRO_VALID; } - modrec_vehicle_fit_video* optimizer_; + dml_vehicle_fit_video* optimizer_; }; @@ -784,13 +784,13 @@ class track_predict_filter : public vpro_filter vpro_signal execute() { - assert(input_type_id(0) == typeid(vcl_vector)); - vcl_vector states = - input >(0); + assert(input_type_id(0) == typeid(vcl_vector)); + vcl_vector states = + input >(0); - vcl_vector pstates; + vcl_vector pstates; for(unsigned int i=0; i()); + graph_["s_delay"] = new vpro_delay(1,vcl_vector()); graph_["trk_predict"] = new track_predict_filter(); graph_["trk_correct"] = new track_correct_filter(optimizer); @@ -965,7 +965,7 @@ modrec_vehicle_tracker::modrec_vehicle_tracker(modrec_vehicle_fit_video* optimiz } //: initialize the intensity background modeling processes -void modrec_vehicle_tracker::init_bgm_pro() +void dml_vehicle_tracker::init_bgm_pro() { float init_var = 6502.5f, g_thresh = 3.0f, min_stdev = 5.1f; int max_components=3, window_size=300; @@ -995,7 +995,7 @@ void modrec_vehicle_tracker::init_bgm_pro() //: initialize the edge background modeling processes -void modrec_vehicle_tracker::init_ebgm_pro() +void dml_vehicle_tracker::init_ebgm_pro() { float init_var = 0.1f, g_thresh = 3.0f, min_stdev = 0.1f; int max_components=3, window_size=300; @@ -1003,7 +1003,7 @@ void modrec_vehicle_tracker::init_ebgm_pro() typedef vpdt_gaussian, vnl_vector_fixed, - modrec_edgel_metric> gauss_type; + dml_edgel_metric> gauss_type; typedef gauss_type::field_type field_type; typedef vpdt_mixture_of mix_gauss_type; typedef vpdt_mog_lm_updater updater_type; @@ -1027,7 +1027,7 @@ void modrec_vehicle_tracker::init_ebgm_pro() //: Assign a camera -void modrec_vehicle_tracker::set_camera(const vpgl_perspective_camera& camera) +void dml_vehicle_tracker::set_camera(const vpgl_perspective_camera& camera) { track_init_filter* filter = dynamic_cast(graph_["track_init"].ptr()); if(filter){ @@ -1037,7 +1037,7 @@ void modrec_vehicle_tracker::set_camera(const vpgl_perspective_camera& c //: Set the sun direction for shadow casting -void modrec_vehicle_tracker::set_sun_direction(const vgl_vector_3d& sun_dir) +void dml_vehicle_tracker::set_sun_direction(const vgl_vector_3d& sun_dir) { track_init_filter* filter = dynamic_cast(graph_["track_init"].ptr()); if(filter){ @@ -1047,7 +1047,7 @@ void modrec_vehicle_tracker::set_sun_direction(const vgl_vector_3d& sun_ //: Assign the PCA vehicle model -void modrec_vehicle_tracker::set_vehicle_model(const modrec_pca_vehicle& vehicle) +void dml_vehicle_tracker::set_vehicle_model(const dml_pca_vehicle& vehicle) { track_init_filter* filter = dynamic_cast(graph_["track_init"].ptr()); if(filter){ @@ -1057,7 +1057,7 @@ void modrec_vehicle_tracker::set_vehicle_model(const modrec_pca_vehicle& vehicle //: set the video input stream -void modrec_vehicle_tracker::set_istream(const vidl_istream_sptr& istream) +void dml_vehicle_tracker::set_istream(const vidl_istream_sptr& istream) { vidl_source* source = dynamic_cast(graph_["source"].ptr()); if(source){ @@ -1067,7 +1067,7 @@ void modrec_vehicle_tracker::set_istream(const vidl_istream_sptr& istream) //: add an observer of input video frames -void modrec_vehicle_tracker::add_video_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_video_observer(const vpro_observer_sptr& obs) { assert(graph_["to_resource"].ptr()); graph_["to_resource"]->add_output_observer(0,obs); @@ -1075,7 +1075,7 @@ void modrec_vehicle_tracker::add_video_observer(const vpro_observer_sptr& obs) //: add an observer of the background detection image -void modrec_vehicle_tracker::add_bg_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_bg_observer(const vpro_observer_sptr& obs) { //assert(graph_["bg_detect"].ptr()); //graph_["bg_detect"]->add_output_observer(0,obs); @@ -1085,7 +1085,7 @@ void modrec_vehicle_tracker::add_bg_observer(const vpro_observer_sptr& obs) //: add an observer of detected vehicle silhouette polygons -void modrec_vehicle_tracker::add_silhouette_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_silhouette_observer(const vpro_observer_sptr& obs) { assert(graph_["blob_detect"].ptr()); graph_["blob_detect"]->add_output_observer(0,obs); @@ -1093,7 +1093,7 @@ void modrec_vehicle_tracker::add_silhouette_observer(const vpro_observer_sptr& o //: add an observer of detected vehicle hypotheses -void modrec_vehicle_tracker::add_hypotheses_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_hypotheses_observer(const vpro_observer_sptr& obs) { assert(graph_["track_init"].ptr()); graph_["track_init"]->add_output_observer(0,obs); @@ -1101,7 +1101,7 @@ void modrec_vehicle_tracker::add_hypotheses_observer(const vpro_observer_sptr& o //: add an observer of the vehicle tracks -void modrec_vehicle_tracker::add_track_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_track_observer(const vpro_observer_sptr& obs) { assert(graph_["trk_correct"].ptr()); graph_["trk_correct"]->add_output_observer(0,obs); @@ -1109,7 +1109,7 @@ void modrec_vehicle_tracker::add_track_observer(const vpro_observer_sptr& obs) //: add an observer of the edge map image -void modrec_vehicle_tracker::add_edgemap_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_edgemap_observer(const vpro_observer_sptr& obs) { assert(graph_["m_edge_map"].ptr()); graph_["m_edge_map"]->add_output_observer(0,obs); @@ -1117,7 +1117,7 @@ void modrec_vehicle_tracker::add_edgemap_observer(const vpro_observer_sptr& obs) //: add an observer of the optical flow -void modrec_vehicle_tracker::add_optical_flow_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_optical_flow_observer(const vpro_observer_sptr& obs) { assert(graph_["t_flow"].ptr()); graph_["t_flow"]->add_output_observer(0,obs); @@ -1125,7 +1125,7 @@ void modrec_vehicle_tracker::add_optical_flow_observer(const vpro_observer_sptr& //: add an observer of the point map image -void modrec_vehicle_tracker::add_pointmap_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_pointmap_observer(const vpro_observer_sptr& obs) { assert(graph_["min_eigval"].ptr()); graph_["min_eigval"]->add_output_observer(0,obs); @@ -1133,7 +1133,7 @@ void modrec_vehicle_tracker::add_pointmap_observer(const vpro_observer_sptr& obs //: add an observer of the points -void modrec_vehicle_tracker::add_point_observer(const vpro_observer_sptr& obs) +void dml_vehicle_tracker::add_point_observer(const vpro_observer_sptr& obs) { assert(graph_["klt_pts"].ptr()); graph_["klt_pts"]->add_output_observer(0,obs); @@ -1141,7 +1141,7 @@ void modrec_vehicle_tracker::add_point_observer(const vpro_observer_sptr& obs) //: enable tracking -void modrec_vehicle_tracker::enable_tracking(bool enable_track) +void dml_vehicle_tracker::enable_tracking(bool enable_track) { track_init_filter* track_init = dynamic_cast(graph_["track_init"].ptr()); if(track_init) @@ -1150,7 +1150,7 @@ void modrec_vehicle_tracker::enable_tracking(bool enable_track) //: enable processes for display -void modrec_vehicle_tracker::enable_display(bool enable_display) +void dml_vehicle_tracker::enable_display(bool enable_display) { optional_sink* opt_sink = dynamic_cast(graph_["disp_sink"].ptr()); if(opt_sink) @@ -1159,7 +1159,7 @@ void modrec_vehicle_tracker::enable_display(bool enable_display) //: enable or disable shape estimation -void modrec_vehicle_tracker::set_estimate_shape(bool val) +void dml_vehicle_tracker::set_estimate_shape(bool val) { track_init_filter* tif = dynamic_cast(graph_["track_init"].ptr()); assert(tif); diff --git a/modrec/modrec_vehicle_tracker.h b/dml/dml_vehicle_tracker.h similarity index 87% rename from modrec/modrec_vehicle_tracker.h rename to dml/dml_vehicle_tracker.h index db8aee8..a2c2d5f 100644 --- a/modrec/modrec_vehicle_tracker.h +++ b/dml/dml_vehicle_tracker.h @@ -1,6 +1,6 @@ -// This is modrec/modrec_vehicle_tracker.h -#ifndef modrec_vehicle_tracker_h_ -#define modrec_vehicle_tracker_h_ +// This is dml/dml_vehicle_tracker.h +#ifndef dml_vehicle_tracker_h_ +#define dml_vehicle_tracker_h_ //========================================================================= //: // \file @@ -23,16 +23,16 @@ #include #include #include -#include +#include // forward declarations -class modrec_vehicle_fit_video; +class dml_vehicle_fit_video; //: manager vehicle tracking processes -class modrec_vehicle_tracker +class dml_vehicle_tracker { public: - modrec_vehicle_tracker(modrec_vehicle_fit_video* optimizer); + dml_vehicle_tracker(dml_vehicle_fit_video* optimizer); //: Assign a camera void set_camera(const vpgl_perspective_camera& camera); @@ -41,7 +41,7 @@ class modrec_vehicle_tracker void set_sun_direction(const vgl_vector_3d& sun_dir); //: Assign the PCA vehicle model - void set_vehicle_model(const modrec_pca_vehicle& vehicle); + void set_vehicle_model(const dml_pca_vehicle& vehicle); //: set the video input stream void set_istream(const vidl_istream_sptr& istream); @@ -98,4 +98,4 @@ class modrec_vehicle_tracker -#endif // modrec_vehicle_tracker_h_ +#endif // dml_vehicle_tracker_h_ diff --git a/modrec/py_modrec.cxx b/dml/py_dml.cxx similarity index 81% rename from modrec/py_modrec.cxx rename to dml/py_dml.cxx index ac53199..3507027 100644 --- a/modrec/py_modrec.cxx +++ b/dml/py_dml.cxx @@ -1,7 +1,7 @@ -// This is modrec/py_modrec.cxx +// This is dml/py_dml.cxx //: // \file -// \brief The python interface for modrec +// \brief The python interface for dml // \author Matt Leotta (mleotta@lems.brown.edu) // \date 11/12/08 // @@ -13,7 +13,7 @@ #include "Python.h" #include -#include "py_modrec_manager.h" +#include "py_dml_manager.h" static PyObject * @@ -24,7 +24,7 @@ set_camera(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:set_camera", &frame, &filename)) return NULL; - bool ret = py_modrec_manager::instance()->set_camera(frame,filename); + bool ret = py_dml_manager::instance()->set_camera(frame,filename); return Py_BuildValue("b", ret); } @@ -37,7 +37,7 @@ set_image(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:set_image", &frame, &filename)) return NULL; - bool ret = py_modrec_manager::instance()->set_image(frame,filename); + bool ret = py_dml_manager::instance()->set_image(frame,filename); return Py_BuildValue("b", ret); } @@ -50,7 +50,7 @@ set_video(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:set_video", &filename)) return NULL; - bool ret = py_modrec_manager::instance()->set_video(filename); + bool ret = py_dml_manager::instance()->set_video(filename); return Py_BuildValue("b", ret); } @@ -59,7 +59,7 @@ set_video(PyObject *self, PyObject *args) static PyObject * reset_views(PyObject *self, PyObject *args) { - py_modrec_manager::instance()->reset_views(); + py_dml_manager::instance()->reset_views(); return Py_BuildValue("b", true); } @@ -71,7 +71,7 @@ set_parts(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:set_parts", &filename)) return NULL; - bool ret = py_modrec_manager::instance()->set_parts(filename); + bool ret = py_dml_manager::instance()->set_parts(filename); return Py_BuildValue("b", ret); } @@ -83,7 +83,7 @@ set_pca(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:set_pca", &filename)) return NULL; - bool ret = py_modrec_manager::instance()->set_pca(filename); + bool ret = py_dml_manager::instance()->set_pca(filename); return Py_BuildValue("b", ret); } @@ -97,7 +97,7 @@ set_mesh(PyObject *self, PyObject *args) return NULL; bool ret = false; - ret = py_modrec_manager::instance()->set_mesh(filename,partsname); + ret = py_dml_manager::instance()->set_mesh(filename,partsname); return Py_BuildValue("b", ret); } @@ -110,15 +110,15 @@ set_vehicle_model(PyObject *self, PyObject *args) return NULL; if(vcl_string(type) == "Detailed1") - py_modrec_manager::instance()->set_vehicle_model(py_modrec_manager::DETAILED1); + py_dml_manager::instance()->set_vehicle_model(py_dml_manager::DETAILED1); else if(vcl_string(type) == "Detailed2") - py_modrec_manager::instance()->set_vehicle_model(py_modrec_manager::DETAILED2); + py_dml_manager::instance()->set_vehicle_model(py_dml_manager::DETAILED2); else if(vcl_string(type) == "Detailed3") - py_modrec_manager::instance()->set_vehicle_model(py_modrec_manager::DETAILED3); + py_dml_manager::instance()->set_vehicle_model(py_dml_manager::DETAILED3); else if(vcl_string(type) == "Dodecahedral") - py_modrec_manager::instance()->set_vehicle_model(py_modrec_manager::DODECAHEDRAL); + py_dml_manager::instance()->set_vehicle_model(py_dml_manager::DODECAHEDRAL); else if(vcl_string(type) == "Ferryman") - py_modrec_manager::instance()->set_vehicle_model(py_modrec_manager::FERRYMAN); + py_dml_manager::instance()->set_vehicle_model(py_dml_manager::FERRYMAN); else return Py_BuildValue("b", false); @@ -134,9 +134,9 @@ set_fit_mode(PyObject *self, PyObject *args) return NULL; if(vcl_string(mode) == "video") - py_modrec_manager::instance()->set_fit_mode(true); + py_dml_manager::instance()->set_fit_mode(true); else if(vcl_string(mode) == "multiview") - py_modrec_manager::instance()->set_fit_mode(false); + py_dml_manager::instance()->set_fit_mode(false); else return Py_BuildValue("b", false); @@ -185,7 +185,7 @@ set_options(PyObject *self, PyObject *args) return NULL; } - py_modrec_manager::instance()->set_options(options,num_pc); + py_dml_manager::instance()->set_options(options,num_pc); return Py_BuildValue("b", true); } @@ -196,7 +196,7 @@ set_init_uncert(PyObject *self, PyObject *args) double uncert; if (!PyArg_ParseTuple(args, "d:set_init_uncert", &uncert)) return NULL; - py_modrec_manager::instance()->set_init_uncert(uncert); + py_dml_manager::instance()->set_init_uncert(uncert); return Py_BuildValue("b", true); } @@ -208,7 +208,7 @@ set_translation(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "(ddd):set_translation", &tx, &ty, &tz)) return NULL; - py_modrec_manager::instance()->set_translation(tx, ty, tz); + py_dml_manager::instance()->set_translation(tx, ty, tz); return Py_BuildValue("b", true); } @@ -220,7 +220,7 @@ set_rotation(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "(ddd):set_rotation", &rx, &ry, &rz)) return NULL; - py_modrec_manager::instance()->set_rotation(rx, ry, rz); + py_dml_manager::instance()->set_rotation(rx, ry, rz); return Py_BuildValue("b", true); } @@ -252,7 +252,7 @@ set_params(PyObject *self, PyObject *args) return NULL; } - py_modrec_manager::instance()->set_params(params); + py_dml_manager::instance()->set_params(params); return Py_BuildValue("b", true); } @@ -263,7 +263,7 @@ set_lambda(PyObject *self, PyObject *args) double lambda; if (!PyArg_ParseTuple(args, "d:set_lambda", &lambda)) return NULL; - py_modrec_manager::instance()->set_lambda(lambda); + py_dml_manager::instance()->set_lambda(lambda); return Py_BuildValue("b", true); } @@ -277,7 +277,7 @@ set_truth_mesh(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:set_truth_mesh", &filename, &type)) return NULL; - bool ret = py_modrec_manager::instance()->set_truth_mesh(filename); + bool ret = py_dml_manager::instance()->set_truth_mesh(filename); return Py_BuildValue("b", ret); } @@ -291,7 +291,7 @@ evaluate_residual(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "d|b:evaluate_residual", &scale, &compute_vis)) return NULL; - double error = py_modrec_manager::instance()->evaluate_residual(scale,compute_vis); + double error = py_dml_manager::instance()->evaluate_residual(scale,compute_vis); return Py_BuildValue("d", error); } @@ -300,7 +300,7 @@ evaluate_residual(PyObject *self, PyObject *args) static PyObject * compute_error(PyObject *self, PyObject *args) { - double error = py_modrec_manager::instance()->compute_error(); + double error = py_dml_manager::instance()->compute_error(); return Py_BuildValue("d", error); } @@ -311,7 +311,7 @@ fit_model(PyObject *self, PyObject *args) int max_itr = 20; if (!PyArg_ParseTuple(args, "|i:fit_model", &max_itr)) return NULL; - py_modrec_manager::instance()->fit_model(max_itr); + py_dml_manager::instance()->fit_model(max_itr); return Py_BuildValue("b", true); } @@ -324,7 +324,7 @@ write_svg_curves(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:write_svg_curves", &frame, &filename)) return NULL; - bool ret = py_modrec_manager::instance()->write_svg_curves(frame,filename); + bool ret = py_dml_manager::instance()->write_svg_curves(frame,filename); return Py_BuildValue("b", ret); } @@ -335,7 +335,7 @@ enable_tracking(PyObject *self, PyObject *args) bool enabled = 0; if (!PyArg_ParseTuple(args, "b:enable_tracking", &enabled)) return NULL; - py_modrec_manager::instance()->enable_tracking(enabled); + py_dml_manager::instance()->enable_tracking(enabled); return Py_BuildValue("b", true); } @@ -346,7 +346,7 @@ set_track_with_silhouette(PyObject *self, PyObject *args) bool val = false; if (!PyArg_ParseTuple(args, "b:set_track_with_silhouette", &val)) return NULL; - py_modrec_manager::instance()->set_track_with_silhouette(val); + py_dml_manager::instance()->set_track_with_silhouette(val); return Py_BuildValue("b", true); } @@ -357,7 +357,7 @@ video_seek(PyObject *self, PyObject *args) int frame = 0; if (!PyArg_ParseTuple(args, "|i:video_seek", &frame)) return NULL; - py_modrec_manager::instance()->video_seek(frame); + py_dml_manager::instance()->video_seek(frame); return Py_BuildValue("b", true); } @@ -365,14 +365,14 @@ video_seek(PyObject *self, PyObject *args) static PyObject * advance_video(PyObject *self, PyObject *args) { - bool ret = py_modrec_manager::instance()->advance_video(); + bool ret = py_dml_manager::instance()->advance_video(); return Py_BuildValue("b", ret); } static PyObject * get_current_frame(PyObject *self, PyObject *args) { - int ret = py_modrec_manager::instance()->current_frame(); + int ret = py_dml_manager::instance()->current_frame(); return Py_BuildValue("i", ret); } @@ -380,7 +380,7 @@ static PyObject * get_translation(PyObject *self, PyObject *args) { double tx,ty,tz; - py_modrec_manager::instance()->get_translation(tx,ty,tz); + py_dml_manager::instance()->get_translation(tx,ty,tz); return Py_BuildValue("(ddd)", tx,ty,tz); } @@ -388,7 +388,7 @@ static PyObject * get_rotation(PyObject *self, PyObject *args) { double rx,ry,rz; - py_modrec_manager::instance()->get_rotation(rx,ry,rz); + py_dml_manager::instance()->get_rotation(rx,ry,rz); return Py_BuildValue("(ddd)", rx,ry,rz); } @@ -400,8 +400,8 @@ get_params(PyObject *self, PyObject *args) return NULL; vcl_vector params; - py_modrec_manager::instance()->get_params(params); - unsigned num_params = py_modrec_manager::instance()->num_pc(); + py_dml_manager::instance()->get_params(params); + unsigned num_params = py_dml_manager::instance()->num_pc(); if(opt && vcl_string(opt) == "all") num_params = params.size(); @@ -416,22 +416,22 @@ static PyObject * get_vehicle_model(PyObject *self, PyObject *args) { vcl_string model; - py_modrec_manager::vehicle_model vm; - py_modrec_manager::instance()->get_vehicle_model(vm); + py_dml_manager::vehicle_model vm; + py_dml_manager::instance()->get_vehicle_model(vm); switch(vm){ - case py_modrec_manager::DODECAHEDRAL: + case py_dml_manager::DODECAHEDRAL: model = "Dodecahedral"; break; - case py_modrec_manager::FERRYMAN: + case py_dml_manager::FERRYMAN: model = "Ferryman"; break; - case py_modrec_manager::DETAILED1: + case py_dml_manager::DETAILED1: model = "Detailed1"; break; - case py_modrec_manager::DETAILED2: + case py_dml_manager::DETAILED2: model = "Detailed2"; break; - case py_modrec_manager::DETAILED3: + case py_dml_manager::DETAILED3: model = "Detailed3"; break; } @@ -441,13 +441,13 @@ get_vehicle_model(PyObject *self, PyObject *args) static PyObject * get_vehicle_states(PyObject *self, PyObject *args) { - const vcl_vector& states = - py_modrec_manager::instance()->get_vehicle_states(); + const vcl_vector& states = + py_dml_manager::instance()->get_vehicle_states(); PyObject* list = PyList_New(states.size()); for(unsigned int i=0; icompute_edgel_coverage(dist_thresh,ncm,nct,npm,npt); + py_dml_manager::instance()->compute_edgel_coverage(dist_thresh,ncm,nct,npm,npt); return Py_BuildValue("(iiii)", ncm,nct,npm,npt); } @@ -488,14 +488,14 @@ relative_coverage(PyObject *self, PyObject *args) return NULL; unsigned int nm,np,nt; - py_modrec_manager::instance()->compare_relative_coverage(dist_thresh,nm,np,nt); + py_dml_manager::instance()->compare_relative_coverage(dist_thresh,nm,np,nt); return Py_BuildValue("(iii)", nm,np,nt); } //: Define all the python functions -static PyMethodDef py_modrec_methods[] = { +static PyMethodDef py_dml_methods[] = { {"set_camera", set_camera, METH_VARARGS, "set_camera(i,path) loads a camera file to frame i"}, {"set_image", set_image, METH_VARARGS, @@ -564,7 +564,7 @@ static PyMethodDef py_modrec_methods[] = { PyMODINIT_FUNC -initpy_modrec(void) +initpy_dml(void) { - Py_InitModule("py_modrec", py_modrec_methods); + Py_InitModule("py_dml", py_dml_methods); } diff --git a/modrec/py_modrec_manager.cxx b/dml/py_dml_manager.cxx similarity index 83% rename from modrec/py_modrec_manager.cxx rename to dml/py_dml_manager.cxx index 3c8c52d..986334f 100644 --- a/modrec/py_modrec_manager.cxx +++ b/dml/py_dml_manager.cxx @@ -1,5 +1,5 @@ -// This is modrec/py_modrec_manager.cxx -#include "py_modrec_manager.h" +// This is dml/py_dml_manager.cxx +#include "py_dml_manager.h" // Copyright Matthew Leotta 2006 - 2010. // Distributed under the Boost Software License, Version 1.0. @@ -16,15 +16,15 @@ #include #include -#include -#include +#include +#include #include #include #include #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ class track_observer: public vpro_observer { public: - track_observer(py_modrec_manager& m) + track_observer(py_dml_manager& m) : manager_(m) {} //: Called by the process when the data is ready @@ -45,38 +45,38 @@ class track_observer: public vpro_observer { assert(data); if(data->info() == VPRO_VALID){ - assert(data->type_id() == typeid(vcl_vector)); - const vcl_vector& states = - data->data >(); + assert(data->type_id() == typeid(vcl_vector)); + const vcl_vector& states = + data->data >(); manager_.set_tracking_states(states); } return true; } - py_modrec_manager& manager_; + py_dml_manager& manager_; }; //=============================================================== //static manager instance -py_modrec_manager *py_modrec_manager::instance_ = 0; +py_dml_manager *py_dml_manager::instance_ = 0; //: The singleton pattern - only one instance of the manager can occur -py_modrec_manager *py_modrec_manager::instance() +py_dml_manager *py_dml_manager::instance() { if (!instance_) { - instance_ = new py_modrec_manager(); + instance_ = new py_dml_manager(); } - return py_modrec_manager::instance_; + return py_dml_manager::instance_; } //=============================================================== //: Constructor -py_modrec_manager::py_modrec_manager() +py_dml_manager::py_dml_manager() { init_mesh(); // default to multiview fitting mode @@ -86,7 +86,7 @@ py_modrec_manager::py_modrec_manager() //: Initialize the texture map for detailed meshes -void py_modrec_manager::init_mesh_tex(modrec_pca_vehicle& mesh) +void py_dml_manager::init_mesh_tex(dml_pca_vehicle& mesh) { assert(mesh.has_tex_coords()); @@ -103,10 +103,10 @@ void py_modrec_manager::init_mesh_tex(modrec_pca_vehicle& mesh) } -//: Build a default vehicle mesh from default parameters in modrec -void py_modrec_manager::init_mesh() +//: Build a default vehicle mesh from default parameters in dml +void py_dml_manager::init_mesh() { - modrec_generate_vehicle(modrec_read_vehicle_params(),detailed3_mesh_); + dml_generate_vehicle(dml_read_vehicle_params(),detailed3_mesh_); detailed1_mesh_ = detailed3_mesh_; imesh_quad_subdivide(detailed3_mesh_,detailed3_mesh_.faces().group_face_set("body")); @@ -131,11 +131,11 @@ void py_modrec_manager::init_mesh() mesh_ = &detailed3_mesh_; - modrec_generate_dodec_vehicle(modrec_read_vehicle_params(),dodec_mesh_); + dml_generate_dodec_vehicle(dml_read_vehicle_params(),dodec_mesh_); dodec_mesh_.compute_face_normals(); dodec_mesh_.build_edge_graph(); - modrec_generate_ferryman_vehicle(modrec_read_vehicle_params(),ferryman_mesh_); + dml_generate_ferryman_vehicle(dml_read_vehicle_params(),ferryman_mesh_); ferryman_mesh_.compute_face_normals(); ferryman_mesh_.build_edge_graph(); @@ -144,8 +144,8 @@ void py_modrec_manager::init_mesh() //: load a camera matrix for frame \a i -bool py_modrec_manager::set_camera(unsigned int frame, - const vcl_string& filename) +bool py_dml_manager::set_camera(unsigned int frame, + const vcl_string& filename) { vnl_double_3x4 M; norm_cam_ = false; @@ -232,7 +232,7 @@ bool py_modrec_manager::set_camera(unsigned int frame, //: compute the sun direction for shadow casting -void py_modrec_manager::compute_sun_direction() +void py_dml_manager::compute_sun_direction() { if(solar_lat_ == 0.0 && solar_lon_ == 0.0) sun_dir_ = vgl_vector_3d(0,0,-1); @@ -247,7 +247,7 @@ void py_modrec_manager::compute_sun_direction() } double alt,az; - modrec_solar_position(solar_day_, solar_utc_+rel_time, solar_lat_, solar_lon_, alt, az); + dml_solar_position(solar_day_, solar_utc_+rel_time, solar_lat_, solar_lon_, alt, az); double sag = solar_atn_ - az; sun_dir_ = vgl_vector_3d(-vcl_cos(sag)*vcl_cos(alt), -vcl_sin(sag)*vcl_cos(alt), @@ -259,7 +259,7 @@ void py_modrec_manager::compute_sun_direction() //: load an image file for frame \a i -bool py_modrec_manager::set_image(unsigned int frame, const vcl_string& filename) +bool py_dml_manager::set_image(unsigned int frame, const vcl_string& filename) { vil_image_resource_sptr img = vil_load_image_resource(filename.c_str()); if(!img) @@ -278,7 +278,7 @@ bool py_modrec_manager::set_image(unsigned int frame, const vcl_string& filename //: Open input video stream -bool py_modrec_manager::set_video(const vcl_string& filename) +bool py_dml_manager::set_video(const vcl_string& filename) { if(vul_file::exists(filename) && !vul_file::is_directory(filename)) istream_ = new vidl_ffmpeg_istream(filename); @@ -318,7 +318,7 @@ bool py_modrec_manager::set_video(const vcl_string& filename) //: clear all images and cameras -void py_modrec_manager::reset_views() +void py_dml_manager::reset_views() { vcl_cout << "clearing views"<reset(); @@ -326,15 +326,15 @@ void py_modrec_manager::reset_views() //: load the parts from a file -bool py_modrec_manager::set_parts(const vcl_string& filename) +bool py_dml_manager::set_parts(const vcl_string& filename) { - mesh_->set_parts(modrec_read_vehicle_parts(filename)); + mesh_->set_parts(dml_read_vehicle_parts(filename)); return true; } //: load the pca parameters from a file -bool py_modrec_manager::set_pca(const vcl_string& filename) +bool py_dml_manager::set_pca(const vcl_string& filename) { vnl_vector mean; vnl_vector std_devs; @@ -355,7 +355,7 @@ bool py_modrec_manager::set_pca(const vcl_string& filename) //: load the mesh and projected into PCA space -bool py_modrec_manager::set_mesh(const vcl_string& filename, +bool py_dml_manager::set_mesh(const vcl_string& filename, const vcl_string& partsfile) { imesh_mesh new_mesh; @@ -380,7 +380,7 @@ bool py_modrec_manager::set_mesh(const vcl_string& filename, if(partsfile == "") mesh_->set_params(mesh_->imesh_pca_mesh::project(mesh_->vertices())); else - mesh_->set_params(mesh_->project(mesh_->vertices(),modrec_read_vehicle_parts(partsfile))); + mesh_->set_params(mesh_->project(mesh_->vertices(),dml_read_vehicle_parts(partsfile))); } video_optimizer_.set_vehicle_model(*mesh_); @@ -390,7 +390,7 @@ bool py_modrec_manager::set_mesh(const vcl_string& filename, //: Choose the type of vehicle model from the enum -void py_modrec_manager::set_vehicle_model(vehicle_model vm) +void py_dml_manager::set_vehicle_model(vehicle_model vm) { switch(vm){ case DODECAHEDRAL: @@ -415,7 +415,7 @@ void py_modrec_manager::set_vehicle_model(vehicle_model vm) //: load the polyhedral approximation mesh -bool py_modrec_manager::set_poly_mesh(const vcl_string& filename) +bool py_dml_manager::set_poly_mesh(const vcl_string& filename) { if(!imesh_read(filename,poly_mesh_)){ vcl_cerr << "error, could not read mesh file: "<& options, - unsigned int num_pc) +void py_dml_manager::set_options(const vcl_vector& options, + unsigned int num_pc) { vcl_cout << "Enable "; if(options[1]) vcl_cout << "tx, "; @@ -446,21 +446,21 @@ void py_modrec_manager::set_options(const vcl_vector& options, //: set the scale of the initial uncertainty -void py_modrec_manager::set_init_uncert(double uncert) +void py_dml_manager::set_init_uncert(double uncert) { optimizer_->set_init_uncert(uncert); } //: enable or disable tracking with silhouette terms -void py_modrec_manager::set_track_with_silhouette(bool val) +void py_dml_manager::set_track_with_silhouette(bool val) { video_optimizer_.set_track_with_silhouette(val); } //: set the translation vector -void py_modrec_manager::set_translation(double tx, double ty, double tz) +void py_dml_manager::set_translation(double tx, double ty, double tz) { t_.set(tx,ty,tz); vcl_cout << "translation set to "<(vnl_vector_fixed(rx,ry,rz)); vcl_cout << "Rotation set to "<< R_.as_rodrigues() << vcl_endl; @@ -476,7 +476,7 @@ void py_modrec_manager::set_rotation(double rx, double ry, double rz) //: set the rotation vector -void py_modrec_manager::set_params(const vcl_vector& params) +void py_dml_manager::set_params(const vcl_vector& params) { vnl_vector p(params.size()); for(unsigned int i=0; i& params) //: set the regularization factor -void py_modrec_manager::set_lambda(double lambda) +void py_dml_manager::set_lambda(double lambda) { optimizer_->set_lambda(lambda); } //: set the vehicle tracking states -void py_modrec_manager::set_tracking_states(const vcl_vector& states) +void py_dml_manager::set_tracking_states(const vcl_vector& states) { vehicle_states_ = states; } //: Enable video mode (true), or multiview mode (false) -void py_modrec_manager::set_fit_mode(bool use_video) +void py_dml_manager::set_fit_mode(bool use_video) { if(use_video) { @@ -516,32 +516,32 @@ void py_modrec_manager::set_fit_mode(bool use_video) //: Is the fitting mode video (true) or multiview (false) -bool py_modrec_manager::is_fit_mode_video() const +bool py_dml_manager::is_fit_mode_video() const { return optimizer_ == &video_optimizer_; } //: fit the vehicle model to the data -void py_modrec_manager::fit_model(unsigned int max_itr) +void py_dml_manager::fit_model(unsigned int max_itr) { optimizer_->fit_model(max_itr,*mesh_,t_,R_); } //: write an svg file with the last projected curves in view \a i -bool py_modrec_manager::write_svg_curves(unsigned int i, - const vcl_string& filename) const +bool py_dml_manager::write_svg_curves(unsigned int i, + const vcl_string& filename) const { - const modrec_pca_vehicle_projector& projector = is_fit_mode_video() ? - video_optimizer_.projector() : - mv_optimizer_.projector(i); - return modrec_write_svg_curves(filename, projector); + const dml_pca_vehicle_projector& projector = is_fit_mode_video() ? + video_optimizer_.projector() : + mv_optimizer_.projector(i); + return dml_write_svg_curves(filename, projector); } //: load a mesh as the ground truth mesh -bool py_modrec_manager::set_truth_mesh(const vcl_string& filename) +bool py_dml_manager::set_truth_mesh(const vcl_string& filename) { if(!imesh_read(filename,truth_mesh_)){ vcl_cerr << "error, could not read truth mesh file: "<faces().group_face_set("body")); imesh_transform_inplace(body, R_, t_); @@ -587,21 +587,21 @@ double py_modrec_manager::compute_error() const //: return the number of principal components optimized -unsigned int py_modrec_manager::num_pc() const +unsigned int py_dml_manager::num_pc() const { return optimizer_->num_pc(); } //: enable or disable tracking -void py_modrec_manager::enable_tracking(bool enable_track) +void py_dml_manager::enable_tracking(bool enable_track) { video_optimizer_.enable_tracking(enable_track); } //: seek the video to the frame number -void py_modrec_manager::video_seek(int fnum) +void py_dml_manager::video_seek(int fnum) { if(istream_) istream_->seek_frame(fnum); @@ -633,7 +633,7 @@ void py_modrec_manager::video_seek(int fnum) //: advance the video to the next frame -bool py_modrec_manager::advance_video() +bool py_dml_manager::advance_video() { vpro_signal s = video_optimizer_.process_once(); compute_sun_direction(); @@ -644,7 +644,7 @@ bool py_modrec_manager::advance_video() //: return the current video frame number -int py_modrec_manager::current_frame() const +int py_dml_manager::current_frame() const { if(!istream_) return -1; @@ -654,14 +654,14 @@ int py_modrec_manager::current_frame() const //: evaluate the fitting residual at the current state and given scale -double py_modrec_manager::evaluate_residual(double scale, bool compute_visibility) +double py_dml_manager::evaluate_residual(double scale, bool compute_visibility) { return optimizer_->evaluate_residual(*mesh_,t_,R_,scale,compute_visibility); } //: get the translation vector -void py_modrec_manager::get_translation(double& tx, double& ty, double& tz) const +void py_dml_manager::get_translation(double& tx, double& ty, double& tz) const { tx = t_.x(); ty = t_.y(); @@ -670,7 +670,7 @@ void py_modrec_manager::get_translation(double& tx, double& ty, double& tz) cons //: get the rotation vector -void py_modrec_manager::get_rotation(double& rx, double& ry, double& rz) const +void py_dml_manager::get_rotation(double& rx, double& ry, double& rz) const { vnl_vector_fixed r = R_.as_rodrigues(); rx = r[0]; @@ -680,7 +680,7 @@ void py_modrec_manager::get_rotation(double& rx, double& ry, double& rz) const //: get the parameter vector -void py_modrec_manager::get_params(vcl_vector& params) const +void py_dml_manager::get_params(vcl_vector& params) const { const vnl_vector& p = mesh_->params(); params.resize(p.size()); @@ -690,7 +690,7 @@ void py_modrec_manager::get_params(vcl_vector& params) const //: get the type of vehicle model used -void py_modrec_manager::get_vehicle_model(vehicle_model& vm) +void py_dml_manager::get_vehicle_model(vehicle_model& vm) { if(mesh_ == &dodec_mesh_) vm = DODECAHEDRAL; @@ -706,15 +706,15 @@ void py_modrec_manager::get_vehicle_model(vehicle_model& vm) //: get the current vehicle tracking states -const vcl_vector& -py_modrec_manager::get_vehicle_states() const +const vcl_vector& +py_dml_manager::get_vehicle_states() const { return vehicle_states_; } //: compute the edgel coverage of the contours and part boundaries in the last projection -void py_modrec_manager:: +void py_dml_manager:: compute_edgel_coverage(double dist_thresh, unsigned int& num_contour_match, unsigned int& num_contour_total, @@ -744,7 +744,7 @@ namespace{ const vcl_vector > >& curves) { vcl_vector > edge_pos; - vcl_vector edgels; + vcl_vector edgels; const unsigned ni = edge_map.ni(); const unsigned nj = edge_map.nj(); for(unsigned int j=0; j v2 = e-p0; double s = dot_product(v,v2); @@ -828,7 +828,7 @@ namespace{ //: compute edge coverage for on-vehicle-edges for mesh and poly_mesh -void py_modrec_manager:: +void py_dml_manager:: compare_relative_coverage(double dist_thesh, unsigned int& num_match, unsigned int& num_poly_match, @@ -841,7 +841,7 @@ compare_relative_coverage(double dist_thesh, edge_map.deep_copy(mv_optimizer_.edge_map(i)); const unsigned int ni = edge_map.ni(), nj = edge_map.nj(); - modrec_pca_vehicle_projector projector(ni,nj); + dml_pca_vehicle_projector projector(ni,nj); projector.project(mv_optimizer_.camera(i),*mesh_,R_,t_); // clear edges off of the vehicle diff --git a/modrec/py_modrec_manager.h b/dml/py_dml_manager.h similarity index 85% rename from modrec/py_modrec_manager.h rename to dml/py_dml_manager.h index 729abec..e820466 100644 --- a/modrec/py_modrec_manager.h +++ b/dml/py_dml_manager.h @@ -1,6 +1,6 @@ -// This is modrec/py_modrec_manager.h -#ifndef py_modrec_manager_h_ -#define py_modrec_manager_h_ +// This is dml/py_dml_manager.h +#ifndef py_dml_manager_h_ +#define py_dml_manager_h_ //---------------------------------------------------------------------------- //: // \file @@ -17,18 +17,18 @@ //----------------------------------------------------------------------------- -#include -#include +#include +#include #include //: A manager for the gui -class py_modrec_manager +class py_dml_manager { public: enum vehicle_model { DODECAHEDRAL, FERRYMAN, DETAILED1, DETAILED2, DETAILED3 }; - static py_modrec_manager *instance(); + static py_dml_manager *instance(); //: load a camera matrix for frame \a i bool set_camera(unsigned int i, const vcl_string& filename); @@ -84,7 +84,7 @@ class py_modrec_manager void set_lambda(double lambda); //: set the states produced by the tracker - void set_tracking_states(const vcl_vector& states); + void set_tracking_states(const vcl_vector& states); //: Enable video mode (true), or multiview mode (false) void set_fit_mode(bool use_video); @@ -135,7 +135,7 @@ class py_modrec_manager void get_vehicle_model(vehicle_model& vm); //: get the current vehicle tracking states - const vcl_vector& get_vehicle_states() const; + const vcl_vector& get_vehicle_states() const; //: compute the edgel coverage of the contours and part boundaries in the last projection void compute_edgel_coverage(double dist_thresh, @@ -152,30 +152,30 @@ class py_modrec_manager private: - py_modrec_manager(); - ~py_modrec_manager() {} + py_dml_manager(); + ~py_dml_manager() {} void init_mesh(); //: Initialize the texture map for detailed meshes - void init_mesh_tex(modrec_pca_vehicle& mesh); + void init_mesh_tex(dml_pca_vehicle& mesh); - static py_modrec_manager *instance_; + static py_dml_manager *instance_; - modrec_vehicle_fit* optimizer_; - modrec_vehicle_fit_multiview mv_optimizer_; - modrec_vehicle_fit_video video_optimizer_; + dml_vehicle_fit* optimizer_; + dml_vehicle_fit_multiview mv_optimizer_; + dml_vehicle_fit_video video_optimizer_; - modrec_pca_vehicle *mesh_; + dml_pca_vehicle *mesh_; //: dodecahedral mesh - modrec_pca_vehicle dodec_mesh_; + dml_pca_vehicle dodec_mesh_; //: Ferryman's mesh - modrec_pca_vehicle ferryman_mesh_; + dml_pca_vehicle ferryman_mesh_; //: detailed mesh with parts at 3 resolutions - modrec_pca_vehicle detailed1_mesh_,detailed2_mesh_,detailed3_mesh_; + dml_pca_vehicle detailed1_mesh_,detailed2_mesh_,detailed3_mesh_; vgl_vector_3d t_; vgl_rotation_3d R_; - vcl_vector vehicle_states_; + vcl_vector vehicle_states_; //: the video stream vidl_istream_sptr istream_; @@ -199,4 +199,4 @@ class py_modrec_manager }; -#endif // py_modrec_manager_h_ +#endif // py_dml_manager_h_ diff --git a/dml/tests/CMakeLists.txt b/dml/tests/CMakeLists.txt new file mode 100644 index 0000000..9307b3b --- /dev/null +++ b/dml/tests/CMakeLists.txt @@ -0,0 +1,22 @@ + +# Copyright Matthew Leotta 2006 - 2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file ../../LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# dml/tests/CMakeLists.txt +# Tests for dml library + +ADD_EXECUTABLE( dml_test_all + test_driver.cxx + test_solar_position.cxx +) + +TARGET_LINK_LIBRARIES( dml_test_all dml testlib ) + + +ADD_TEST( dml_test_solar_position dml_test_all test_solar_position ) + +ADD_EXECUTABLE( dml_test_include test_include.cxx ) + +TARGET_LINK_LIBRARIES( dml_test_include dml ) diff --git a/modrec/tests/test_driver.cxx b/dml/tests/test_driver.cxx similarity index 100% rename from modrec/tests/test_driver.cxx rename to dml/tests/test_driver.cxx diff --git a/dml/tests/test_include.cxx b/dml/tests/test_include.cxx new file mode 100644 index 0000000..3867cd3 --- /dev/null +++ b/dml/tests/test_include.cxx @@ -0,0 +1,23 @@ +// Copyright Matthew Leotta 2006 - 2010. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file ../../LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() { return 0; } diff --git a/modrec/tests/test_solar_position.cxx b/dml/tests/test_solar_position.cxx similarity index 61% rename from modrec/tests/test_solar_position.cxx rename to dml/tests/test_solar_position.cxx index cee59bc..4a6eafb 100644 --- a/modrec/tests/test_solar_position.cxx +++ b/dml/tests/test_solar_position.cxx @@ -4,7 +4,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include @@ -15,23 +15,23 @@ MAIN( test_solar_position ) START ("Solar Position"); double alt,az; - modrec_solar_position(79, 17, // March 20th, 12:00 PM EST - 41.82608, -71.39991, // Latitude,Longitude of Brown University - alt, az); + dml_solar_position(79, 17, // March 20th, 12:00 PM EST + 41.82608, -71.39991, // Latitude,Longitude of Brown University + alt, az); // These results are not expected to be extremely precise TEST_NEAR("altitude", alt, 0.82885686, 1e-4); TEST_NEAR("azimuth", az, 3.1862731, 1e-4); - modrec_solar_position(79, 14, // March 20th, 9:00 AM EST - 41.82608, -71.39991, // Latitude,Longitude of Brown University - alt, az); + dml_solar_position(79, 14, // March 20th, 9:00 AM EST + 41.82608, -71.39991, // Latitude,Longitude of Brown University + alt, az); // These results are not expected to be extremely precise TEST_NEAR("altitude", alt, 0.56443948, 1e-4); TEST_NEAR("azimuth", az, 2.1952751, 1e-4); - modrec_solar_position(79, 20, // March 20th, 3:00 PM EST - 41.82608, -71.39991, // Latitude,Longitude of Brown University - alt, az); + dml_solar_position(79, 20, // March 20th, 3:00 PM EST + 41.82608, -71.39991, // Latitude,Longitude of Brown University + alt, az); // These results are not expected to be extremely precise TEST_NEAR("altitude", alt, 0.52726397, 1e-4); TEST_NEAR("azimuth", az, 4.1434116, 1e-4); diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 2d9c55b..3d84146 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -68,7 +68,7 @@ IF(wxWidgets_FOUND) WXWIDGETS_ADD_RESOURCES(pca_vehicle_wxgui_sources pca_vehicle.xrc) ADD_EXECUTABLE(pca_vehicle_wxgui WIN32 MACOSX_BUNDLE ${pca_vehicle_wxgui_sources}) - TARGET_LINK_LIBRARIES(pca_vehicle_wxgui vgui_wx bgui3d bgui imesh modrec vidl_gui vil gl2ps vpgl_algo) + TARGET_LINK_LIBRARIES(pca_vehicle_wxgui vgui_wx bgui3d bgui imesh dml vidl_gui vil gl2ps vpgl_algo) ENDIF(VXL_VGUI_WX_FOUND) diff --git a/gui/pca_vehicle_frame.cxx b/gui/pca_vehicle_frame.cxx index 26257f1..e91edd3 100644 --- a/gui/pca_vehicle_frame.cxx +++ b/gui/pca_vehicle_frame.cxx @@ -809,8 +809,8 @@ void pca_vehicle_frame::run_track_results(wxCommandEvent& event) vcl_string filename = static_cast(file_dialog.GetPath().mb_str(wxConvUTF8)); vcl_string vid_file, cam_file, model_type; - vcl_map > state_map; - unsigned int start_frame = modrec_read_track_file(filename,vid_file,cam_file,model_type,state_map); + vcl_map > state_map; + unsigned int start_frame = dml_read_track_file(filename,vid_file,cam_file,model_type,state_map); // load video file vidl_istream_sptr is = new vidl_ffmpeg_istream(vid_file); diff --git a/gui/pca_vehicle_manager.cxx b/gui/pca_vehicle_manager.cxx index cabcb4a..3cdf506 100644 --- a/gui/pca_vehicle_manager.cxx +++ b/gui/pca_vehicle_manager.cxx @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include @@ -63,10 +63,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -105,9 +105,9 @@ class hypothesis_observer: public vpro_observer { assert(data); if(data->info() == VPRO_VALID){ - assert(data->type_id() == typeid(vcl_vector)); - const vcl_vector& states = - data->data >(); + assert(data->type_id() == typeid(vcl_vector)); + const vcl_vector& states = + data->data >(); for(unsigned int i=0; iinfo() == VPRO_VALID){ - assert(data->type_id() == typeid(vcl_vector)); - const vcl_vector& states = - data->data >(); + assert(data->type_id() == typeid(vcl_vector)); + const vcl_vector& states = + data->data >(); manager_.set_tracking_states(states); } @@ -530,7 +530,7 @@ bool pca_vehicle_manager::is_fit_mode_video() const //: Initialize the texture map for detailed meshes -void pca_vehicle_manager::init_mesh_tex(modrec_pca_vehicle& mesh) +void pca_vehicle_manager::init_mesh_tex(dml_pca_vehicle& mesh) { if(mesh.has_tex_coords()) { @@ -551,10 +551,10 @@ void pca_vehicle_manager::init_mesh_tex(modrec_pca_vehicle& mesh) } -//: Build a default vehicle mesh from default parameters in modrec +//: Build a default vehicle mesh from default parameters in dml void pca_vehicle_manager::init_mesh() { - modrec_generate_vehicle(modrec_read_vehicle_params(),detailed3_mesh_); + dml_generate_vehicle(dml_read_vehicle_params(),detailed3_mesh_); detailed1_mesh_ = detailed3_mesh_; imesh_quad_subdivide(detailed3_mesh_,detailed3_mesh_.faces().group_face_set("body")); @@ -578,11 +578,11 @@ void pca_vehicle_manager::init_mesh() mesh_ = &detailed3_mesh_; - modrec_generate_dodec_vehicle(modrec_read_vehicle_params(),dodec_mesh_); + dml_generate_dodec_vehicle(dml_read_vehicle_params(),dodec_mesh_); dodec_mesh_.compute_face_normals(); dodec_mesh_.build_edge_graph(); - modrec_generate_ferryman_vehicle(modrec_read_vehicle_params(),ferryman_mesh_); + dml_generate_ferryman_vehicle(dml_read_vehicle_params(),ferryman_mesh_); ferryman_mesh_.compute_face_normals(); ferryman_mesh_.build_edge_graph(); @@ -825,7 +825,7 @@ bool pca_vehicle_manager::save_3d_parts(const vcl_string& filename) const //: Save the projected contours as SVG bool pca_vehicle_manager::save_svg(const vcl_string& filename) const { - return modrec_write_svg_curves(filename, mesh_projector_); + return dml_write_svg_curves(filename, mesh_projector_); } @@ -904,7 +904,7 @@ void pca_vehicle_manager::compute_sun_direction() } double alt,az; - modrec_solar_position(solar_day_, solar_utc_+rel_time, solar_lat_, solar_lon_, alt, az); + dml_solar_position(solar_day_, solar_utc_+rel_time, solar_lat_, solar_lon_, alt, az); double sag = solar_atn_ - az; sun_dir_ = vgl_vector_3d(-vcl_cos(sag)*vcl_cos(alt), -vcl_sin(sag)*vcl_cos(alt), @@ -947,7 +947,7 @@ bool pca_vehicle_manager::load_mesh(const vcl_string& meshfile, mesh_->set_params(mesh_->imesh_pca_mesh::project(mesh_->vertices())); else mesh_->set_params(mesh_->project(mesh_->vertices(), - modrec_read_vehicle_parts(partsfile))); + dml_read_vehicle_parts(partsfile))); draw_parts(); } video_optimizer_.set_vehicle_model(*mesh_); @@ -973,7 +973,7 @@ bool pca_vehicle_manager::load_truth_mesh(const vcl_string& filename) //: Vehicle surface parts bool pca_vehicle_manager::load_parts(const vcl_string& filename) { - mesh_->set_parts(modrec_read_vehicle_parts(filename)); + mesh_->set_parts(dml_read_vehicle_parts(filename)); video_optimizer_.set_vehicle_model(*mesh_); draw_parts(); @@ -1352,7 +1352,7 @@ void pca_vehicle_manager::draw_texmap_parts() tex_parts_tab_->set_point_radius(3.0); tex_parts_tab_->set_foreground(0.0f,1.0f,0.0f); - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector >& parts_uv = mesh_->parts_bary(); for(unsigned int i=0; iis_visible("Vehicle Detection")) return; @@ -1455,11 +1455,11 @@ void pca_vehicle_manager::draw_hypothesis(const modrec_vehicle_state& state) //: draw the current vehicle tracking states void pca_vehicle_manager::draw_current_states() { - typedef vcl_map >::const_iterator map_itr; + typedef vcl_map >::const_iterator map_itr; map_itr fitr = state_map_.find(current_frame()); if(fitr == state_map_.end() || fitr->second.empty()) return; - const vcl_vector& states = fitr->second; + const vcl_vector& states = fitr->second; proj_tab_->clear(); proj_tab_->set_line_width(2.0); @@ -1491,7 +1491,7 @@ void pca_vehicle_manager::draw_current_states() //: set the vehicle tracking states -void pca_vehicle_manager::set_tracking_states(const vcl_vector& states) +void pca_vehicle_manager::set_tracking_states(const vcl_vector& states) { if(states.empty()) return; @@ -1501,7 +1501,7 @@ void pca_vehicle_manager::set_tracking_states(const vcl_vector >& state_map) +void pca_vehicle_manager::set_state_map(const vcl_map >& state_map) { state_map_ = state_map; } @@ -1514,7 +1514,7 @@ void pca_vehicle_manager::build_parts_node() assert(mesh_->has_half_edges()); parts_node_->removeAllChildren(); - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector >& parts_uv = mesh_->parts_bary(); const vcl_vector > >& parts3d = mesh_->parts_3d(); const vcl_vector >& normals = mesh_->faces().normals(); @@ -1940,13 +1940,13 @@ void pca_vehicle_manager::compute_vis_edgels() return; vis_edgels_.clear(); - vcl_vector medgels = modrec_find_all_edgels(edge_map); + vcl_vector medgels = dml_find_all_edgels(edge_map); - vcl_sort(medgels.begin(), medgels.end(), modrec_edgel_strength_less); + vcl_sort(medgels.begin(), medgels.end(), dml_edgel_strength_less); for(unsigned int i=0; i(m.strength(), @@ -2002,7 +2002,7 @@ void pca_vehicle_manager::fit_model(unsigned int num_itr) double last_residual = vcl_numeric_limits::infinity(); vnl_vector soln(optimizer_->num_params(),0.0); - modrec_write_svg_curves("curves_init.svg",mesh_projector_); + dml_write_svg_curves("curves_init.svg",mesh_projector_); for(unsigned int k=0; k > >& parts_idx = mesh_projector_.parts_indices(); - typedef modrec_pca_vehicle::uv_point uv_point; + typedef dml_pca_vehicle::uv_point uv_point; const vcl_vector >& parts_uv = mesh_->parts_bary(); for(unsigned int i=0; i #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -197,7 +197,7 @@ class pca_vehicle_manager void update_mesh_param(unsigned int i, double param); //: Access the vehicle mesh - const modrec_pca_vehicle& mesh() const { return *mesh_; } + const dml_pca_vehicle& mesh() const { return *mesh_; } //: Access the camera const vpgl_perspective_camera& camera() const; @@ -235,23 +235,23 @@ class pca_vehicle_manager bool handle_message(const vgui_message& m); //: draw a hypothesized vehicle shape and pose - void draw_hypothesis(const modrec_vehicle_state& state); + void draw_hypothesis(const dml_vehicle_state& state); //: draw the current vehicle tracking states void draw_current_states(); //: set the vehicle tracking states - void set_tracking_states(const vcl_vector& states); + void set_tracking_states(const vcl_vector& states); //: set the history of vehicle tracking states indexed over frame number - void set_state_map(const vcl_map >& state_map); + void set_state_map(const vcl_map >& state_map); private: void draw_texmap(); void draw_texmap_parts(); void draw_parts(); //: Initialize the texture map for detailed meshes - void init_mesh_tex(modrec_pca_vehicle& mesh); + void init_mesh_tex(dml_pca_vehicle& mesh); void init_mesh(); void build_mesh_node(); void update_mesh_node(); @@ -272,22 +272,22 @@ class pca_vehicle_manager SoSeparator* parts_node_; SoTransform* mesh_xform_; - modrec_pca_vehicle* mesh_; - modrec_pca_vehicle_projector mesh_projector_; + dml_pca_vehicle* mesh_; + dml_pca_vehicle_projector mesh_projector_; //: dodecahedral mesh - modrec_pca_vehicle dodec_mesh_; + dml_pca_vehicle dodec_mesh_; //: Ferryman's mesh - modrec_pca_vehicle ferryman_mesh_; + dml_pca_vehicle ferryman_mesh_; //: detailed mesh with parts at 3 resolutions - modrec_pca_vehicle detailed1_mesh_, detailed2_mesh_, detailed3_mesh_; + dml_pca_vehicle detailed1_mesh_, detailed2_mesh_, detailed3_mesh_; //: recorded tracking states indexed by frame number - vcl_map > state_map_; + vcl_map > state_map_; //: the ground truth vehiclde mesh - modrec_pca_vehicle truth_mesh_; + dml_pca_vehicle truth_mesh_; vidl_istream_sptr istream_; int frame_number_; @@ -307,9 +307,9 @@ class pca_vehicle_manager double solar_utc_; double solar_atn_; - modrec_vehicle_fit* optimizer_; - modrec_vehicle_fit_multiview mv_optimizer_; - modrec_vehicle_fit_video video_optimizer_; + dml_vehicle_fit* optimizer_; + dml_vehicle_fit_multiview mv_optimizer_; + dml_vehicle_fit_video video_optimizer_; vcl_vector > vis_edgels_; diff --git a/modrec/CMakeLists.txt b/modrec/CMakeLists.txt deleted file mode 100644 index b633571..0000000 --- a/modrec/CMakeLists.txt +++ /dev/null @@ -1,70 +0,0 @@ - -# Copyright Matthew Leotta 2006 - 2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file ../LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# modrec/CMakeLists.txt - - -include_directories( ${VXL_GEL_INCLUDE_DIR}/mrc ) -include_directories( ${VXL_RPL_INCLUDE_DIR} ) -include_directories( ${VXL_BRL_INCLUDE_DIR}/bbas ) - -set(modrec_sources - modrec_proj_cost_func.cxx modrec_proj_cost_func.h - modrec_proj_lsqr_cost_func.cxx modrec_proj_lsqr_cost_func.h - - modrec_vehicle_mesh.cxx modrec_vehicle_mesh.h - modrec_vehicle_parts.cxx modrec_vehicle_parts.h - modrec_vehicle_fit.cxx modrec_vehicle_fit.h - modrec_vehicle_fit_multiview.cxx modrec_vehicle_fit_multiview.h - modrec_vehicle_fit_video.cxx modrec_vehicle_fit_video.h - modrec_vehicle_state.cxx modrec_vehicle_state.h - modrec_vehicle_tracker.cxx modrec_vehicle_tracker.h - modrec_vehicle_track_init.cxx modrec_vehicle_track_init.h - modrec_pca_vehicle.cxx modrec_pca_vehicle.h - modrec_pca_vehicle_projector.cxx modrec_pca_vehicle_projector.h - - modrec_solar_position.cxx modrec_solar_position.h - - modrec_edgel.cxx modrec_edgel.h -) - -add_library(modrec ${modrec_sources}) - -target_link_libraries(modrec vpro vpro_filters bbgm rrel imesh_algo vpgl vil_algo klt) - -if( BUILD_TESTING ) - add_subdirectory(tests) -endif() - -# Make the Python Module for running experiemnts -include( ${VXL_CMAKE_DIR}/NewCMake/FindPython.cmake ) -if( PYTHON_FOUND ) - include_directories( ${PYTHON_INCLUDE_PATH} ) - - set(py_modrec_sources - py_modrec.cxx - py_modrec_manager.cxx py_modrec_manager.h - ) - - add_library(py_modrec MODULE ${py_modrec_sources}) - - if(WIN32) - #library has to have different name depending on debug or release version. - set_target_properties(py_modrec PROPERTIES OUTPUT_NAME py_modrec DEBUG_POSTFIX _d SUFFIX .pyd) - endif(WIN32) - set_target_properties(py_modrec PROPERTIES PREFIX "") - - target_link_libraries(py_modrec modrec) - - if (PYTHON_DEBUG_LIBRARIES) - target_link_libraries( py_modrec debug ${PYTHON_DEBUG_LIBRARY}) - endif(PYTHON_DEBUG_LIBRARIES ) - - if(PYTHON_LIBRARIES) - target_link_libraries( py_modrec optimized ${PYTHON_LIBRARY}) - endif(PYTHON_LIBRARIES) -endif( PYTHON_FOUND ) - diff --git a/modrec/tests/CMakeLists.txt b/modrec/tests/CMakeLists.txt deleted file mode 100644 index 5f805e6..0000000 --- a/modrec/tests/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -# Copyright Matthew Leotta 2006 - 2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file ../../LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -# modrec/tests/CMakeLists.txt -# Tests for modrec library - -ADD_EXECUTABLE( modrec_test_all - test_driver.cxx - test_solar_position.cxx -) - -TARGET_LINK_LIBRARIES( modrec_test_all modrec testlib ) - - -ADD_TEST( modrec_test_solar_position modrec_test_all test_solar_position ) - -ADD_EXECUTABLE( modrec_test_include test_include.cxx ) - -TARGET_LINK_LIBRARIES( modrec_test_include modrec ) diff --git a/modrec/tests/test_include.cxx b/modrec/tests/test_include.cxx deleted file mode 100644 index 51373e8..0000000 --- a/modrec/tests/test_include.cxx +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright Matthew Leotta 2006 - 2010. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file ../../LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int main() { return 0; }