camera_calibration icon indicating copy to clipboard operation
camera_calibration copied to clipboard

Feature Request: Export Target Deformation Info

Open abrock opened this issue 3 years ago • 3 comments

I'm interested in measuring the deformation of a printed target.

Could you export that in a file in the report directory? For example for every point of the target one line x1 y1 z1 x2 y2 z2 where (x1,y1,z1) are the initial coordinates assuming a perfectly planar target with no deformations and (x2,y2,z2) the estimated positions.

abrock avatar May 13 '21 17:05 abrock

I think that there is already a file points.yaml among the state files that contains the optimized (deformed) pattern point positions, and it should be simple to compute the original point positions from the pattern definition YAML file. See FeatureDetectorTaggedPattern::GetCorners() and PatternData::IsValidFeatureCoord() in /applications/camera_calibration/src/camera_calibration/feature_detection/feature_detector_tagged_pattern.cc/h for how to obtain the feature positions as integers (without scaling). So I think that the required information is already present and relatively easy to access.

puzzlepaint avatar May 16 '21 20:05 puzzlepaint

Thank you for the information. I tried to add the functionality I'd like to the SavePointsAndIndexMapping function but FeatureDetectorTaggedPattern::GetCorners is not static and I couldn't figure out where to get an instance from. I ran a debugger with a breakpoint in the contructor of FeatureDetectorTaggedPattern and it didn't trigger. Could you give me a rough idea where to start adding the functionality? I'd also like to get 3D feature points for every image used.

abrock avatar May 19 '21 00:05 abrock

This is where the feature detector is constructed (it is only allocated if needed): https://github.com/puzzlepaint/camera_calibration/blob/846bb5282a23b68e9fd7f3d240f7c979a016dea6/applications/camera_calibration/src/camera_calibration/main.cc#L462

This then builds the map from feature IDs to positions using GetCorners() (if image directories are given): https://github.com/puzzlepaint/camera_calibration/blob/846bb5282a23b68e9fd7f3d240f7c979a016dea6/applications/camera_calibration/src/camera_calibration/calibration.cc#L1266

It should be possible to use this mapping after this has been called. This map is also saved in the dataset files as the "known geometries": https://github.com/puzzlepaint/camera_calibration/blob/846bb5282a23b68e9fd7f3d240f7c979a016dea6/applications/camera_calibration/src/camera_calibration/io/calibration_io.cc#L113

It could be an option to load them from these files and then associate them with the optimized point positions based on the feature ID. This should not require modifying the camera calibration code.

The features for each image are also saved in the dataset files: https://github.com/puzzlepaint/camera_calibration/blob/846bb5282a23b68e9fd7f3d240f7c979a016dea6/applications/camera_calibration/src/camera_calibration/io/calibration_io.cc#L104

puzzlepaint avatar May 20 '21 11:05 puzzlepaint