Commit e24b8d2f authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Started conversion from quad-camera configuration

parent 3c58184f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import com.elphel.imagej.tileprocessor.CorrVector;
import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.GeometryCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
@@ -93,6 +94,7 @@ import jcuda.nvrtc.JNvrtc;
import jcuda.nvrtc.nvrtcProgram;

public class GPUTileProcessor {
	static int CORR_VECTOR_MAX_LENGTH =19; // TODO: update to fit for 16-sensor
	String LIBRARY_PATH = "/usr/local/cuda/targets/x86_64-linux/lib/libcudadevrt.a"; // linux
	static String GPU_RESOURCE_DIR =              "kernels";
	static String [] GPU_KERNEL_FILES = {"dtt8x8.cuh","TileProcessor.cuh"};
@@ -799,7 +801,9 @@ public class GPUTileProcessor {
        	cuMemAlloc(gpu_geometry_correction,      GeometryCorrection.arrayLength(num_cams) * Sizeof.FLOAT);
        	cuMemAlloc(gpu_rByRDist,                 RBYRDIST_LEN *  Sizeof.FLOAT);
        	cuMemAlloc(gpu_rot_deriv,                5*num_cams*3*3 * Sizeof.FLOAT);
        	cuMemAlloc(gpu_correction_vector,        GeometryCorrection.CorrVector.LENGTH * Sizeof.FLOAT);
//        	cuMemAlloc(gpu_correction_vector,        CorrVector.LENGTH * Sizeof.FLOAT);
        	cuMemAlloc(gpu_correction_vector,        CORR_VECTOR_MAX_LENGTH * Sizeof.FLOAT); // update CORR_VECTOR_LENGTH to fit 
        	

            // Set task array
        	cuMemAlloc(gpu_tasks,      tilesX * tilesY * TPTASK_SIZE * Sizeof.FLOAT);
@@ -947,7 +951,7 @@ public class GPUTileProcessor {
 * Copy extrinsic correction vector to the GPU memory
 * @param cv correction vector
 */
        public void setExtrinsicsVector(GeometryCorrection.CorrVector cv) {
        public void setExtrinsicsVector(CorrVector cv) {
        	double [] dcv = cv.toFullRollArray();
        	float []  fcv = new float [dcv.length];
        	for (int i = 0; i < dcv.length; i++) {
+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class ElphelJp4Reader extends ImageIOReader{
			try {
				url = new URL(id);
			} catch (MalformedURLException e) {
				LOGGER.warn("Bad URL1: " + id);
//				LOGGER.warn("Bad URL1: " + id); // will try direct file, not an error
			}
			if (url != null) {
				LOGGER.debug("Starting initFile() method, read "+ id +" to memory first");
+15 −15
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;

//import GeometryCorrection.CorrVector;
//import CorrVector;
import Jama.Matrix;
import ij.ImagePlus;
import ij.ImageStack;
@@ -2363,7 +2363,7 @@ B = |+dy0 -dy1 -2*dy3 |
			int solveCorr_debug =  ((clt_parameters.lym_iter == 1) && (clt_parameters.ly_par_sel != 0))? 2 : debugLevel;


			GeometryCorrection.CorrVector corr_vector = solveCorr (
			CorrVector corr_vector = solveCorr (
					clt_parameters.lylw_inf_en,      // boolean use_disparity,     // if true will ignore disparity data even if available (was false)
					clt_parameters.lylw_aztilt_en,// boolean use_aztilts,       // Adjust azimuths and tilts excluding disparity
					clt_parameters.lylw_diff_roll_en,// boolean use_diff_rolls,    // Adjust differential rolls (3 of 4 angles)
@@ -2373,7 +2373,7 @@ B = |+dy0 -dy1 -2*dy3 |
					clt_parameters.lylw_par_sel,     // int     manual_par_sel,    // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
					mismatch_list,                          // ArrayList<Mismatch> mismatch_list,
					qc.geometryCorrection,                  // GeometryCorrection geometryCorrection,
					qc.geometryCorrection.getCorrVector(),  // GeometryCorrection.CorrVector corr_vector,
					qc.geometryCorrection.getCorrVector(),  // CorrVector corr_vector,
					old_new_rms,                            // double [] old_new_rms, // should be double[2]
//					2); // debugLevel); // 2); // 1); // int debugLevel)
					solveCorr_debug); // debugLevel); // 2); // 1); // int debugLevel)
@@ -2926,7 +2926,7 @@ B = |+dy0 -dy1 -2*dy3 |
			double [] old_new_rms = new double[1];
			boolean apply_extrinsic = true;
			int solveCorr_debug =  ((clt_parameters.lym_iter == 1) && (clt_parameters.ly_par_sel != 0))? 2 : debugLevel;
			GeometryCorrection.CorrVector corr_vector = solveCorr (
			CorrVector corr_vector = solveCorr (
					clt_parameters.lylw_inf_en,      // boolean use_disparity,     // if true will ignore disparity data even if available (was false)
					clt_parameters.lylw_aztilt_en,// boolean use_aztilts,       // Adjust azimuths and tilts excluding disparity
					clt_parameters.lylw_diff_roll_en,// boolean use_diff_rolls,    // Adjust differential rolls (3 of 4 angles)
@@ -2937,7 +2937,7 @@ B = |+dy0 -dy1 -2*dy3 |
					mismatch_list,                          // ArrayList<Mismatch> mismatch_list,
					qc.geometryCorrection,                  // GeometryCorrection geometryCorrection,
///					geometryCorrection_main, //  GeometryCorrection geometryCorrection_main, // if is aux camera using main cameras' coordinates. Disparity is still in aux camera pixels
					qc.geometryCorrection.getCorrVector(),  // GeometryCorrection.CorrVector corr_vector,
					qc.geometryCorrection.getCorrVector(),  // CorrVector corr_vector,
					old_new_rms,                            // double [] old_new_rms, // should be double[2]
//					2); // debugLevel); // 2); // 1); // int debugLevel)
					solveCorr_debug); // debugLevel); // 2); // 1); // int debugLevel)
@@ -3063,7 +3063,7 @@ B = |+dy0 -dy1 -2*dy3 |
			boolean [] par_mask,
			ArrayList<Mismatch> mismatch_list,
			GeometryCorrection geometryCorrection,
			GeometryCorrection.CorrVector corr_vector,
			CorrVector corr_vector,
			int debugLevel)
	{
		boolean dbg_images = debugLevel>1;
@@ -3214,7 +3214,7 @@ B = |+dy0 -dy1 -2*dy3 |
			boolean [] par_mask,
			ArrayList<Mismatch> mismatch_list,
			GeometryCorrection geometryCorrection,
			GeometryCorrection.CorrVector corr_vector,
			CorrVector corr_vector,
			int debugLevel)
	{
		int num_pars = 0;
@@ -3227,8 +3227,8 @@ B = |+dy0 -dy1 -2*dy3 |
			double [] sym_par_m = sym_par_0.clone();
			sym_par_p[sym_par] += 0.5 * delta;
			sym_par_m[sym_par] -= 0.5 * delta;
			GeometryCorrection.CorrVector corr_p = geometryCorrection.getCorrVector(sym_par_p, par_mask);
			GeometryCorrection.CorrVector corr_m = geometryCorrection.getCorrVector(sym_par_m, par_mask);
			CorrVector corr_p = geometryCorrection.getCorrVector(sym_par_p, par_mask);
			CorrVector corr_m = geometryCorrection.getCorrVector(sym_par_m, par_mask);
			double [] mv_p = debug_mv_from_sym(
					mismatch_list,
					geometryCorrection,
@@ -3261,7 +3261,7 @@ B = |+dy0 -dy1 -2*dy3 |
//			boolean [] par_mask,
			ArrayList<Mismatch> mismatch_list,
			GeometryCorrection geometryCorrection,
			GeometryCorrection.CorrVector corr_vector,
			CorrVector corr_vector,
			int debugLevel)
	{
		double [][] dMismatch_dXY = (new Mismatch()).get_dMismatch_dXY(); // just a static array
@@ -3463,7 +3463,7 @@ B = |+dy0 -dy1 -2*dy3 |
		return w;
	}

	public GeometryCorrection.CorrVector  solveCorr (
	public CorrVector  solveCorr (
			boolean use_disparity,     // adjust disparity-related extrinsics
			boolean use_aztilts,       // Adjust azimuths and tilts excluding disparity
			boolean use_diff_rolls,    // Adjust differential rolls (3 of 4 angles)
@@ -3474,7 +3474,7 @@ B = |+dy0 -dy1 -2*dy3 |
	  		int     manual_par_sel,    // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
			ArrayList<Mismatch> mismatch_list,
			GeometryCorrection geometryCorrection,
			GeometryCorrection.CorrVector corr_vector,
			CorrVector corr_vector,
			double [] old_new_rms, // should be double[2]
			int debugLevel)
	{
@@ -3502,7 +3502,7 @@ B = |+dy0 -dy1 -2*dy3 |
				par_mask,           // boolean [] par_mask,
				mismatch_list,      // ArrayList<Mismatch> mismatch_list,
				geometryCorrection, // GeometryCorrection geometryCorrection,
				corr_vector,        // GeometryCorrection.CorrVector corr_vector)
				corr_vector,        // CorrVector corr_vector)
				debugLevel);		// int debugLevel)

//		debugLevel = 2;
@@ -3558,7 +3558,7 @@ B = |+dy0 -dy1 -2*dy3 |
					par_mask,           // boolean [] par_mask,
					mismatch_list,      // ArrayList<Mismatch> mismatch_list,
					geometryCorrection, // GeometryCorrection geometryCorrection,
					corr_vector,        // GeometryCorrection.CorrVector corr_vector)
					corr_vector,        // CorrVector corr_vector)
					debugLevel);		// int debugLevel)

			dbg_xy =              doubleNaN(dbg_titles_xy.length,                            dbg_length); // jacobian dmv/dsym
@@ -3630,7 +3630,7 @@ B = |+dy0 -dy1 -2*dy3 |
		}
		//if (par_mask[0]) drslt[0] *= -1.0; //FIXME: Find actual bug, sym[0] corrects in opposite way

		GeometryCorrection.CorrVector rslt = geometryCorrection.getCorrVector(drslt, par_mask);
		CorrVector rslt = geometryCorrection.getCorrVector(drslt, par_mask);
		if (debugLevel > -3){ // change to >0) {
			System.out.println("solveCorr() rslt (increment):");
			System.out.println(rslt.toString());
+1064 −0

File added.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Diff line number Diff line
@@ -668,7 +668,9 @@ public class ErsCorrection extends GeometryCorrection {
		XYZ_he =               gc.XYZ_he;     // all cameras coordinates transformed to eliminate heading and elevation (rolls preserved)
		XYZ_her =              gc.XYZ_her; // = null; // XYZ of the lenses in a corrected CCS (adjusted for to elevation, heading,  common_roll)
		rXY =                  gc.rXY; // =     null; // XY pairs of the in a normal plane, relative to disparityRadius
		rXY_ideal =            gc.rXY_ideal; // = {{-0.5, -0.5}, {0.5,-0.5}, {-0.5, 0.5}, {0.5,0.5}};
		
//		rXY_ideal =            gc.rXY_ideal; // = {{-0.5, -0.5}, {0.5,-0.5}, {-0.5, 0.5}, {0.5,0.5}};
		set_rXY_ideal(gc.get_rXY_ideal()); //)
		cameraRadius =         gc.cameraRadius; // =0; // average distance from the "mass center" of the sensors to the sensors
		disparityRadius =      gc.disparityRadius; //  150.0; // distance between cameras to normalize disparity units to. sqrt(2)*disparityRadius for quad camera (~=150mm)?
		rByRDist =             gc.rByRDist; // =null;
@@ -689,7 +691,8 @@ public class ErsCorrection extends GeometryCorrection {
			XYZ_he =    clone2d(XYZ_he);
			XYZ_her =   clone2d(XYZ_her);
			rXY =       clone2d(rXY);
			rXY_ideal = clone2d(rXY_ideal);
//			rXY_ideal = clone2d(rXY_ideal);
			set_rXY_ideal(clone2d(gc.get_rXY_ideal())); //)
			rByRDist =  clone1d(rByRDist); // probably it is not needed
			extrinsic_corr = extrinsic_corr.clone(); 
			if (rigOffset!=null) rigOffset = rigOffset.clone();
Loading