Generate new transformations parameters for each frame to follow the smoothed trajectory
| 237 | |
| 238 | // Generate new transformations parameters for each frame to follow the smoothed trajectory |
| 239 | std::map<size_t,TransformParam> CVStabilization::GenNewCamPosition(std::map <size_t,CamTrajectory> &smoothed_trajectory){ |
| 240 | std::map <size_t,TransformParam> new_prev_to_cur_transform; |
| 241 | |
| 242 | // Accumulated frame to frame transform |
| 243 | double a = 0; |
| 244 | double x = 0; |
| 245 | double y = 0; |
| 246 | |
| 247 | for(size_t i=0; i < prev_to_cur_transform.size(); i++) { |
| 248 | x += prev_to_cur_transform[i].dx; |
| 249 | y += prev_to_cur_transform[i].dy; |
| 250 | a += prev_to_cur_transform[i].da; |
| 251 | |
| 252 | // target - current |
| 253 | double diff_x = smoothed_trajectory[i + start].x - x; |
| 254 | double diff_y = smoothed_trajectory[i + start].y - y; |
| 255 | double diff_a = smoothed_trajectory[i + start].a - a; |
| 256 | |
| 257 | double dx = prev_to_cur_transform[i].dx + diff_x; |
| 258 | double dy = prev_to_cur_transform[i].dy + diff_y; |
| 259 | double da = prev_to_cur_transform[i].da + diff_a; |
| 260 | |
| 261 | // Add transformation data to map |
| 262 | new_prev_to_cur_transform[i + start] = TransformParam(dx, dy, da); |
| 263 | } |
| 264 | return new_prev_to_cur_transform; |
| 265 | } |
| 266 | |
| 267 | // Save stabilization data to protobuf file |
| 268 | bool CVStabilization::SaveStabilizedData(){ |
nothing calls this directly
no test coverage detected