diff --git a/liboptv/src/multimed.c b/liboptv/src/multimed.c index 2551cef8..ed0da014 100644 --- a/liboptv/src/multimed.c +++ b/liboptv/src/multimed.c @@ -111,32 +111,28 @@ double multimed_r_nlay (Calibration *cal, mm_np *mm, vec3d pos) { } } - -/* trans_Cam_Point() creates the shifted points for each position X,Y,Z - Using Exterior and Interior parameters and the Glass vector of the variable - window position and the two vectors that point to the crossing point +/* trans_Cam_Point() projects global-coordinate points of the camera and an + image points on the glass surface separating those points. - Arguments: - Exterior structure 'ex' - multimedia paramaters mm - Glass parameters gl - 3D space position pos - Returns: - Pointer to ex_t Exterior parameters after shift - vector of doubles for shifted position pos_t - vector of 3 doubles of cross_p - vector of 3 doubles of cross_c, both used for back projection -*/ -void trans_Cam_Point(Exterior ex - , mm_np mm - , Glass gl - , vec3d pos - , Exterior *ex_t - , vec3d pos_t - , double cross_p[3] - , double cross_c[3]){ - -/* Beat Luethi June 07: I change the stuff to a system perpendicular to the interface */ + Input arguments: + Exterior ex - holding global-coordinates camera position. + mm_np mm - holding glass thickness. + Glass gl - holding the glass position in global-coordinates as a + glass-normal vector. + vec3d pos - the global coordinates of the observed point. + + Output arguments: + Exterior ex_t - only the primary point fields are used, and are set + to the glass/Z axis intersection. + double cross_p[3] - the observed point projection coordinates in global + coordinates. + double cross_c[3] - same for the camera position. Since the camera point + is projected on the other side of the glass, it'll have a small + difference in Z value from ``cross_p``. +*/ +void trans_Cam_Point(Exterior ex, mm_np mm, Glass gl, vec3d pos, + Exterior *ex_t, vec3d pos_t, double cross_p[3], double cross_c[3]) +{ double dist_cam_glas,dist_point_glas,dist_o_glas; //glas inside at water int row, col; vec3d glass_dir, primary_pt, renorm_glass, temp; @@ -345,17 +341,13 @@ double get_mmf_from_mmlut (Calibration *cal, vec3d pos){ double X,Y,Z; vec3d temp; - vec_copy(temp,pos); - - rw = cal->mmlut.rw; + rw = cal->mmlut.rw; - temp[2] -= cal->mmlut.origin[2]; + vec_subt(pos, cal->mmlut.origin, temp); sz = temp[2]/rw; iz = (int) sz; sz -= iz; - temp[0] -= cal->mmlut.origin[0]; - temp[1] -= cal->mmlut.origin[1]; R = norm(temp[0], temp[1], 0); sr = R/rw; diff --git a/liboptv/tests/check_multimed.c b/liboptv/tests/check_multimed.c index 32e98d2f..d0f3dbbe 100644 --- a/liboptv/tests/check_multimed.c +++ b/liboptv/tests/check_multimed.c @@ -317,6 +317,7 @@ START_TEST(test_trans_Cam_Point) { /* input */ vec3d pos = {100.0, 100.0, 0.0}; + double sep_norm = vec_norm(pos); Exterior test_Ex = { 0.0, 0.0, 100.0, @@ -352,25 +353,25 @@ START_TEST(test_trans_Cam_Point) trans_Cam_Point(test_Ex, test_mm, test_G, pos, &Ex_t, pos_t, cross_p, cross_c); - ck_assert_msg( fabs(pos_t[0] - 141.421356) < EPS && + ck_assert_msg( fabs(pos_t[0] - sep_norm) < EPS && fabs(pos_t[1] - 0.0) < EPS && - fabs(pos_t[2] + 50.000000) < EPS, - "Expected 141.421356 0.000000 -50.000000 but found %10.8f %10.8f %10.8f\n", - pos_t[0],pos_t[1],pos_t[2]); + fabs(pos_t[2] + test_G.vec_z) < EPS, + "Expected %g 0.000000 %g but found %10.8f %10.8f %10.8f\n", + sep_norm, -test_G.vec_z, pos_t[0],pos_t[1],pos_t[2]); - ck_assert_msg( fabs(cross_p[0] - 100.0) < EPS && - fabs(cross_p[1] - 100.0) < EPS && - fabs(cross_p[2] - 50.0) < EPS, - "Expected 100.0 100.0 50.000 but found %10.8f %10.8f %10.8f\n", \ - cross_p[0],cross_p[1],cross_p[2]); - - ck_assert_msg(fabs(cross_c[0] + 0.0) < EPS && - fabs(cross_c[1] + 0.0) < EPS && - fabs(cross_c[2] - 55.0) < EPS, - "Expected 0.000000 0.000000 55.000000 but found %10.8f %10.8f %10.8f\n", \ + ck_assert_msg( fabs(cross_p[0] - pos[0]) < EPS && + fabs(cross_p[1] - pos[1]) < EPS && + fabs(cross_p[2] - test_G.vec_z) < EPS, + "Expected %g %g %g but found %10.8f %10.8f %10.8f\n", \ + pos[0], pos[1], test_G.vec_z, cross_p[0],cross_p[1],cross_p[2]); + + ck_assert_msg(fabs(cross_c[0] + test_Ex.x0) < EPS && + fabs(cross_c[1] + test_Ex.y0) < EPS && + fabs(cross_c[2] - (test_G.vec_z + test_mm.d[0])) < EPS, + "Expected %g %g %g but found %10.8f %10.8f %10.8f\n", \ + -test_Ex.x0, -test_Ex.y0, test_G.vec_z + test_mm.d[0], cross_c[0],cross_c[1],cross_c[2]); - ck_assert_msg ( (fabs(correct_Ex_t.x0 - Ex_t.x0) < EPS) && (fabs(correct_Ex_t.y0 - Ex_t.y0) < EPS) && (fabs(correct_Ex_t.z0 - Ex_t.z0) < EPS),