Skip to content

Commit 2d27dd7

Browse files
committed
added epipolar test to final stage of rectified correspondences cross init
1 parent c078c10 commit 2d27dd7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/core/DICe_Schema.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,14 +3429,32 @@ Schema::initialize_cross_correlation(Teuchos::RCP<Triangulation> tri,
34293429
std::vector<cv::Point2f> dist_unrect_disp_points;
34303430
unrectify_and_distort(undist_rect_disp_points,dist_unrect_disp_points,M2,D2,R2,P2);
34313431

3432-
// save off the displacements in the original image coordinates
3432+
// save off the displacements in the original image coordinates and check epipolar error
3433+
float epi_dist_tol = 0.5f;
3434+
if(tri->avg_epipolar_error()!=0.0){
3435+
epi_dist_tol = 3.0*tri->avg_epipolar_error();
3436+
}
3437+
34333438
for(int_t local_id=0;local_id<local_num_subsets();++local_id){
34343439
local_field_value(local_id,SUBSET_DISPLACEMENT_X_FS) = dist_unrect_disp_points[local_id].x - local_field_value(local_id,SUBSET_COORDINATES_X_FS);
34353440
local_field_value(local_id,SUBSET_DISPLACEMENT_Y_FS) = dist_unrect_disp_points[local_id].y - local_field_value(local_id,SUBSET_COORDINATES_Y_FS);
3441+
const float a = local_field_value(local_id,EPI_A_FS);
3442+
const float b = local_field_value(local_id,EPI_B_FS);
3443+
const float c = local_field_value(local_id,EPI_C_FS);
3444+
const float stereo_x = local_field_value(local_id,SUBSET_COORDINATES_X_FS) + local_field_value(local_id,SUBSET_DISPLACEMENT_X_FS);
3445+
const float stereo_y = local_field_value(local_id,SUBSET_COORDINATES_Y_FS) + local_field_value(local_id,SUBSET_DISPLACEMENT_Y_FS);
3446+
std::vector<scalar_t> sx(1,stereo_x);
3447+
std::vector<scalar_t> sy(1,stereo_y);
3448+
tri->undistort_points(sx,sy,1); // right camera
3449+
const float dist = (std::abs(a*sx[0]+b*sy[0]+c)/std::sqrt(a*a+b*b));
3450+
DEBUG_MSG("Schema::initialize_cross_correlation(): epipolar error for subset " << local_id << ": "<< dist);
3451+
if(dist>epi_dist_tol){
3452+
local_field_value(local_id,SIGMA_FS) = -1.0;
3453+
local_field_value(local_id,MATCH_FS) = -1;
3454+
DEBUG_MSG("Schema::initialize_cross_correlation(): failed epipolar distance threshold");
3455+
}
34363456
}
34373457

3438-
// TODO CHECK THE EPIPOLAR ERROR LIKE BELOW?
3439-
34403458
// reset the ref image (so that the previous image gets updated.
34413459
set_ref_image(left_image_string);
34423460

0 commit comments

Comments
 (0)