| 86 | } |
| 87 | |
| 88 | bool initializer::initialize(data::frame &curr_frm) |
| 89 | { |
| 90 | |
| 91 | switch (setup_type_) |
| 92 | { |
| 93 | case camera::setup_type_t::Monocular: |
| 94 | { |
| 95 | // construct an initializer if not constructed |
| 96 | if (state_ == initializer_state_t::NotReady) |
| 97 | { |
| 98 | create_initializer(curr_frm); |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | // try to initialize |
| 103 | if (!try_initialize_for_monocular(curr_frm)) |
| 104 | { |
| 105 | // failed |
| 106 | return false; |
| 107 | } |
| 108 | |
| 109 | // create new map if succeeded, which means we found first two image to initialize the map |
| 110 | create_map_for_monocular(curr_frm); |
| 111 | break; |
| 112 | } |
| 113 | case camera::setup_type_t::Stereo: |
| 114 | case camera::setup_type_t::RGBD: |
| 115 | { |
| 116 | state_ = initializer_state_t::Initializing; |
| 117 | |
| 118 | // try to initialize |
| 119 | if (!try_initialize_for_stereo(curr_frm)) |
| 120 | { |
| 121 | // failed |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | // create new map if succeeded |
| 126 | create_map_for_stereo(curr_frm); |
| 127 | break; |
| 128 | } |
| 129 | default: |
| 130 | { |
| 131 | throw std::runtime_error("Undefined camera setup"); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // check the state is succeeded or not |
| 136 | if (state_ == initializer_state_t::Succeeded) |
| 137 | { |
| 138 | init_frm_id_ = curr_frm.id_; |
| 139 | return true; |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | return false; |
| 144 | } |
| 145 | } |
no outgoing calls
no test coverage detected