Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Milestone 3: Synthetic Optimization #11

Open
wants to merge 18 commits into
base: camera_class_and_detections
Choose a base branch
from

Conversation

chris24sahadeo
Copy link
Member

Write an application that uses the ceres-solver optimization library to compute the camera’s intrinsic parameters, camera’s poses, and the fiducial poses. The optimization will use the following data

Input Data:

  • AprilTag detection data. (YAML files from milestone 1)

Variable Parameters (Each parameter will need an initial guess)

  • Camera Intrinsics
  • camera_T_world (for each image)
  • world_T_target (for each fiducial target)

Constants:

  • The size of each fiducial target.

Switching back to  "camera_class_and_detections"
To make changes to mileston
...but I don't know why...

Transform hacks required.

NB: pixel points no longer casted to int in camera.yaml
and this time on purpose!!!

Thanks to Vijay's, Kiran's and Sarika's input.

Major refactoring required before PR.
Need to test with real data.
Need to introduce code to deal with models.
Need to code YAML output.
Need to fix camera yaml output.
Included <camera_calibration_parsers/parse.h>

Still some code refactoring to be done.
Added:
- Outputting of optimized data to YAML files.
@chris24sahadeo chris24sahadeo requested a review from sarika93 July 31, 2019 19:51
Following optimization, pixel coordinates of corner
points are recalculated and added to YAML output.
@chris24sahadeo chris24sahadeo requested a review from shivrar August 13, 2019 14:15
Copy link

@shivrar shivrar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First half finished. Will review from rviz_simulator/src/camera_calibration_optimizer.cpp tomorrow.

@@ -165,22 +185,54 @@ include_directories(include
## add_executable(one_marker src/one_marker.cpp)
## target_link_libraries(one_marker ${catkin_LIBRARIES})

FIND_PACKAGE(yaml-cpp REQUIRED)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this FIND_PACKAGE different than the calls above? If not, you should just use one version and also group these above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address all CMakeList.txt-related comments in a separate PR after milestone 3 is merged, since the CMakeList.txt file from milestone 2 is the same file in milestone 3 (which is a branch of 2) and changing the file in one branch and merging with the other may result in merge conflicts.

FIND_PACKAGE(yaml-cpp REQUIRED)


# simulate
add_executable(simulate
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Maybe for readability group all similar declarations together. Example:

add_executable(exe1 path_to_exe1)
add_executable(exe2 path_to_exe2)
...
add_library(lib1  lib1_files)
add_library(lib2 lib2_files)

target_link_libraries(exe1 lib1 other_addtional_libs ...)
target_link_libraries(exe2 lib2  lib1 other_addtional_libs ...)

@@ -216,4 +268,4 @@ target_link_libraries(simulate
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
# )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new line here

@@ -1,21 +1,37 @@
# CERES
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should look at removing any irrelevant or stale comments.

rviz_simulator/README.md Outdated Show resolved Hide resolved
rviz_simulator/src/camera.cpp Outdated Show resolved Hide resolved
rviz_simulator/src/camera.cpp Outdated Show resolved Hide resolved
detections_out << YAML::Value << YAML::BeginSeq; // detections sequence

// processing all camera_T_target transforms
for (int i = 0; i < this->world_T_targets_.size(); i++)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the iterating options of a vector to iterate over the targets
either
https://en.cppreference.com/w/cpp/container/vector

Suggested change
for (int i = 0; i < this->world_T_targets_.size(); i++)
for (Eigen::Affine3d world_T_target : this->world_T_targets_)

or
http://www.cplusplus.com/reference/vector/vector/begin/

Suggested change
for (int i = 0; i < this->world_T_targets_.size(); i++)
for (std::vector<Eigen::Affine3d>::iterator it = this->world_T_targets_.begin() ; it != this->world_T_targets_.end(); ++it)

for (int i = 0; i < this->world_T_targets_.size(); i++)
{
// getting camera_T_target
Eigen::Affine3d camera_T_target = world_T_camera.inverse() * this->world_T_targets_[i];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the iterator above this can become Eigen::Affine3d camera_T_target = world_T_camera.inverse() * (*it);
or something like this

differences.push_back(corners[1] - corners[3]);
differences.push_back(corners[0] - corners[2]);

for (int i = 0; i < differences.size(); i++)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar note to iterate through the vectors from above.

Copy link

@shivrar shivrar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments In line but looks like you have the right idea for stuff.

for (YAML::const_iterator target_iterator = targets_node["targets"].begin();
target_iterator != targets_node["targets"].end(); ++target_iterator)
{
const YAML::Node& target_node = *target_iterator;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This declaration infers that the value in target_iterator is of const value and since we are treating this value as read_only we should just use the target_iterator alone.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: Just realized that this is okay to do but I think you should use the iterator instead of introducing a new variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to make the code simpler/more readable, will consider changing it.

Target target;

// targetID
target.targetID = target_node["targetID"].as<int>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change above:

Suggested change
target.targetID = target_node["targetID"].as<int>();
target.targetID = target_iterator->operator[]("targetID").as<int>();

or

Suggested change
target.targetID = target_node["targetID"].as<int>();
target.targetID = (*target_iterator)["targetID"].as<int>();

rviz_simulator/src/camera_calibration_optimizer.cpp Outdated Show resolved Hide resolved
rviz_simulator/src/camera_calibration_optimizer.cpp Outdated Show resolved Hide resolved
@shivrar shivrar changed the base branch from master to camera_class_and_detections August 16, 2019 19:14
Copy link
Member Author

@chris24sahadeo chris24sahadeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed Shivan's comments


where the `detections_directory_name` is a directory of camera, targets and detection yaml files in the `rviz_simulator` package directory.

The output is written to a folder labelled "`optimized`" which is created in the `detections_directory_name` folder.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...wut?

rviz_simulator/src/camera.cpp Outdated Show resolved Hide resolved
for (YAML::const_iterator target_iterator = targets_node["targets"].begin();
target_iterator != targets_node["targets"].end(); ++target_iterator)
{
const YAML::Node& target_node = *target_iterator;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to make the code simpler/more readable, will consider changing it.

rviz_simulator/src/camera_calibration_optimizer.cpp Outdated Show resolved Hide resolved
rviz_simulator/src/camera_calibration_optimizer.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants