Commit 82ae5d53 authored by Andrey Filippov's avatar Andrey Filippov

preparing macro tiles for optical flow with CLT

parent ca22efc3
...@@ -397,6 +397,8 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -397,6 +397,8 @@ public class ErsCorrection extends GeometryCorrection {
public void setupERS() public void setupERS()
{ {
double ers_sign = 1.0; // -1.0; // invert all corrections to opposite?
ers_xyz= new double [pixelCorrectionHeight][3]; ers_xyz= new double [pixelCorrectionHeight][3];
ers_xyz_dt= new double [pixelCorrectionHeight][3]; ers_xyz_dt= new double [pixelCorrectionHeight][3];
ers_quaternion = new Quaternion [pixelCorrectionHeight]; ers_quaternion = new Quaternion [pixelCorrectionHeight];
...@@ -414,12 +416,12 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -414,12 +416,12 @@ public class ErsCorrection extends GeometryCorrection {
Quaternion quat_center2 = new Quaternion (0.0,ers_watr_center_d2t[1], ers_watr_center_d2t[0], ers_watr_center_d2t[2]); // angular velocity 1/s :tilt, az, roll Quaternion quat_center2 = new Quaternion (0.0,ers_watr_center_d2t[1], ers_watr_center_d2t[0], ers_watr_center_d2t[2]); // angular velocity 1/s :tilt, az, roll
// integration to the bottom of the image // integration to the bottom of the image
double dt = line_time; double dt = ers_sign*line_time;
double [] wxy0 = ers_wxyz_center.clone(); double [] wxy0 = ers_wxyz_center.clone();
double [] wxy1 = ers_wxyz_center_dt.clone(); double [] wxy1 = ers_wxyz_center_dt.clone();
double [] wxy2 = ers_wxyz_center_d2t.clone(); double [] wxy2 = ers_wxyz_center_d2t.clone();
// bottom half rotations // bottom half rotations
dt = line_time; dt = ers_sign*line_time;
Quaternion q0 = quat_center0.multiply(1.0); // clone() orientation Quaternion q0 = quat_center0.multiply(1.0); // clone() orientation
Quaternion q1 = quat_center1.multiply(1.0); // clone() angular velocity (pure) Quaternion q1 = quat_center1.multiply(1.0); // clone() angular velocity (pure)
Quaternion q2 = quat_center2.multiply(1.0); // clone() angular accelerations (pure) Quaternion q2 = quat_center2.multiply(1.0); // clone() angular accelerations (pure)
...@@ -432,7 +434,7 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -432,7 +434,7 @@ public class ErsCorrection extends GeometryCorrection {
q1 = q1_next; q1 = q1_next;
} }
// top half-frame rotations // top half-frame rotations
dt = -line_time; dt = -ers_sign*line_time;
q0 = quat_center0.multiply(1.0); // clone() orientation q0 = quat_center0.multiply(1.0); // clone() orientation
q1 = quat_center1.multiply(1.0); // clone() angular velocity (pure) q1 = quat_center1.multiply(1.0); // clone() angular velocity (pure)
q2 = quat_center2.multiply(1.0); // clone() angular accelerations (pure) q2 = quat_center2.multiply(1.0); // clone() angular accelerations (pure)
...@@ -470,7 +472,7 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -470,7 +472,7 @@ public class ErsCorrection extends GeometryCorrection {
wxy1[i] = wxy1_next; wxy1[i] = wxy1_next;
} }
} }
dt = -line_time; dt = -ers_sign*line_time;
wxy0 = ers_wxyz_center.clone(); wxy0 = ers_wxyz_center.clone();
wxy1 = ers_wxyz_center_dt.clone(); wxy1 = ers_wxyz_center_dt.clone();
for (int h = cent_h; h >= 0; h--) { for (int h = cent_h; h >= 0; h--) {
...@@ -502,10 +504,9 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -502,10 +504,9 @@ public class ErsCorrection extends GeometryCorrection {
public double [] getImageCoordinatesERS( public double [] getImageCoordinatesERS(
QuadCLT cameraQuadCLT, // camera station that got image to be to be matched QuadCLT cameraQuadCLT, // camera station that got image to be to be matched
double px, // pixel coordinate X in the reference view
double px, // pixel coordinate X in this camera view double py, // pixel coordinate Y in the reference view
double py, // pixel coordinate Y in this camera view double disparity, // this reference disparity
double disparity, // this view disparity
boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear
double [] reference_xyz, // this view position in world coordinates (typically zero3) double [] reference_xyz, // this view position in world coordinates (typically zero3)
double [] reference_atr, // this view orientation relative to world frame (typically zero3) double [] reference_atr, // this view orientation relative to world frame (typically zero3)
...@@ -540,14 +541,14 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -540,14 +541,14 @@ public class ErsCorrection extends GeometryCorrection {
if (xyzw[2] > 0) { if (xyzw[2] > 0) {
return null; // can not match object behind the camera return null; // can not match object behind the camera
} }
ErsCorrection ers_other = this; ErsCorrection ers_camera = this;
if (cameraQuadCLT != null) { if (cameraQuadCLT != null) {
ers_other = cameraQuadCLT.getErsCorrection(); ers_camera = cameraQuadCLT.getErsCorrection();
} }
if (camera_xyz == null) camera_xyz = ers_other.camera_xyz; if (camera_xyz == null) camera_xyz = ers_camera.camera_xyz;
if (camera_atr == null) camera_atr = ers_other.camera_atr; if (camera_atr == null) camera_atr = ers_camera.camera_atr;
double [] pXpYD = ers_other.getImageCoordinatesERS( // USED in lwir double [] pXpYD = ers_camera.getImageCoordinatesERS( // USED in lwir
xyzw, xyzw,
distortedCamera, distortedCamera,
camera_xyz, // camera center in world coordinates camera_xyz, // camera center in world coordinates
...@@ -557,6 +558,63 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -557,6 +558,63 @@ public class ErsCorrection extends GeometryCorrection {
return pXpYD; return pXpYD;
} }
public double [] getImageCoordinatesReferenceERS(
QuadCLT cameraQuadCLT, // camera station that got image to be to be matched
double px, // pixel coordinate X in this camera view
double py, // pixel coordinate Y in this camera view
double disparity, // this view disparity
boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear
double [] reference_xyz, // this view position in world coordinates (typically zero3)
double [] reference_atr, // this view orientation relative to world frame (typically zero3)
boolean distortedCamera, // camera view is distorted (false - rectilinear)
double [] camera_xyz, // camera center in world coordinates
double [] camera_atr, // camera orientation relative to world frame
double line_err) // threshold error in scan lines (1.0)
{
if (reference_xyz == null) reference_xyz = this.camera_xyz;
if (reference_atr == null) reference_atr = this.camera_atr;
ErsCorrection ers_camera = this;
if (cameraQuadCLT != null) {
ers_camera = cameraQuadCLT.getErsCorrection();
}
if (camera_xyz == null) camera_xyz = ers_camera.camera_xyz;
if (camera_atr == null) camera_atr = ers_camera.camera_atr;
// Find world coordinates of the camera pixel
double [] xyzw = ers_camera.getWorldCoordinatesERS( // {x - left,y - up, z (0 at camera, negative away), 1} for real, {x,y,z,0} - for infinity
px,
py,
disparity,
distortedView, // correct distortion (will need corrected background too !)
camera_xyz, // camera center in world coordinates
camera_atr); // camera orientation relative to world frame
if (xyzw == null) {
return null;
}
if (xyzw[3] == 0.0) { // infinity
/*
if (xyzw[2] > 0) {
for (int i = 0; i < 3; i++) {
xyzw[i] = -xyzw[i];
}
}
*/
}
if (xyzw[2] > 0) {
return null; // can not match object behind the camera
}
double [] pXpYD = ers_camera.getImageCoordinatesERS( // USED in lwir
xyzw,
distortedCamera,
reference_xyz, // camera center in world coordinates
reference_atr, // camera orientation relative to world frame
line_err); // threshold error in scan lines (1.0)
return pXpYD;
}
/** /**
* Get real world coordinates from pixel coordinates and nominal disparity * Get real world coordinates from pixel coordinates and nominal disparity
......
...@@ -8262,17 +8262,20 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8262,17 +8262,20 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow( OpticalFlow opticalFlow = new OpticalFlow(
threadsMax, // int threadsMax, // maximal number of threads to launch threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus); updateStatus); // boolean updateStatus);
int margin = 4; // extra margins over 16x16 tiles to accommodate distorted destination tiles // int margin = 4; // extra margins over 16x16 tiles to accommodate distorted destination tiles
/*
double tolerance_absolute = 0.25; // absolute disparity half-range in each tile double tolerance_absolute = 0.25; // absolute disparity half-range in each tile
double tolerance_relative = 0.2; // relative disparity half-range in each tile double tolerance_relative = 0.2; // relative disparity half-range in each tile
double center_occupancy = 0.25; // fraction of remaining tiles in the center 8x8 area (<1.0) double center_occupancy = 0.25; // fraction of remaining tiles in the center 8x8 area (<1.0)
int num_passes = 100; int num_passes = 100;
double max_change = 0.005 ; double max_change = 0.005 ;
*/
for (int i = 1; i < quadCLTs.length; i++) { for (int i = 1; i < quadCLTs.length; i++) {
QuadCLT qPrev = (i > 0) ? quadCLTs[i - 1] : null; QuadCLT qPrev = (i > 0) ? quadCLTs[i - 1] : null;
/*
double [][][] source_tiles = opticalFlow.prepareReferenceTiles( double [][][] source_tiles = opticalFlow.prepareReferenceTiles(
quadCLTs[i], // final QuadCLT qthis, quadCLTs[i], // final QuadCLT qthis,
// margin, // final int margin, // extra margins over 16x16 tiles to accommodate distorted destination tiles // margin, // final int margin, // extra margins over 16x16 tiles to accommodate distorted destination tiles
...@@ -8289,7 +8292,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8289,7 +8292,7 @@ if (debugLevel > -100) return true; // temporarily !
num_passes, // final int num_passes, num_passes, // final int num_passes,
max_change, // final double max_change, max_change, // final double max_change,
2); // final int debug_level) 2); // final int debug_level)
*/
double [][][] pair_sets = double [][][] pair_sets =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment