Commit dc4e1f60 authored by Andrey Filippov's avatar Andrey Filippov

updated tested GPU image conversion with selectable kernel source

parent ed43abc2
......@@ -85,6 +85,7 @@ public class EyesisCorrectionParameters {
public boolean equirectangular= true;
public boolean zcorrect= true;
public boolean saveSettings = true;
public String tile_processor_gpu = ""; // absolute path to tile_processor_gpu project or empty to use default GPU kernels
public String [] sourcePaths= {};
// public String [] sourceSetPaths= {}; // 2019 - directories with image sets
......@@ -909,6 +910,9 @@ public class EyesisCorrectionParameters {
gd.addTab ("File paths", "Select files and directories paths (common to main and optional auxiliary)");
gd.addMessage ("============ Common to the main and optional auxiliary camera============");
gd.addStringField ("GPU tile_processor_gpu project absolute path", this.tile_processor_gpu, 60,
"Keep empty to use default GPU kernels");
gd.addCheckbox ("Select GPU directory", false);
gd.addCheckbox ("Save current settings with results", this.saveSettings); // 1
gd.addStringField ("Source files directory", this.sourceDirectory, 60); // 2
......@@ -1022,9 +1026,9 @@ public class EyesisCorrectionParameters {
gd.showDialog();
if (gd.wasCanceled()) return false;
this.tile_processor_gpu = gd.getNextString(); if (gd.getNextBoolean()) selectGPUSourceDirectory(false, false);
this.saveSettings= gd.getNextBoolean(); // 1
this.saveSettings= gd.getNextBoolean(); // 1
this.sourceDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSourceDirectory(false, false); // 3
this.use_set_dirs = gd.getNextBoolean();
......@@ -1760,6 +1764,17 @@ public class EyesisCorrectionParameters {
if (dir!=null) this.sourceDirectory=dir;
return dir;
}
public String selectGPUSourceDirectory(boolean smart, boolean newAllowed) { // normally newAllowed=false
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"GPU kernel development project", // title
"Select GPU project directory", // button
null, // filter
this.tile_processor_gpu); // this.sourceDirectory);
if (dir!=null) this.tile_processor_gpu=dir;
return dir;
}
public String selectSensorDirectory(boolean smart, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
......
......@@ -5784,7 +5784,7 @@ private Panel panel1,
}
if (GPU_TILE_PROCESSOR == null) {
try {
GPU_TILE_PROCESSOR = new GPUTileProcessor();
GPU_TILE_PROCESSOR = new GPUTileProcessor(CORRECTION_PARAMETERS.tile_processor_gpu);
} catch (Exception e) {
System.out.println("Failed to initialize GPU class");
// TODO Auto-generated catch block
......
......@@ -240,7 +240,7 @@ public class GPUTileProcessor {
return new PointerWithAddress(p).getAddress();
}
public GPUTileProcessor() throws IOException
public GPUTileProcessor(String cuda_project_directory) throws IOException
{
// From code by Marco Hutter - http://www.jcuda.org
// Enable exceptions and omit all subsequent error checks
......@@ -276,7 +276,15 @@ public class GPUTileProcessor {
"#define IMCLT_TILES_PER_BLOCK " + IMCLT_TILES_PER_BLOCK+"\n";
for (String src_file:GPU_KERNEL_FILES) {
File file = new File(classLoader.getResource(src_file).getFile());
File file = null;
if ((cuda_project_directory == null) || (cuda_project_directory == "")) {
file = new File(classLoader.getResource(src_file).getFile());
System.out.println("Loading resource "+file);
} else {
File src_dir = new File(cuda_project_directory, "src");
file = new File(src_dir.getPath(), src_file);
System.out.println("Loading resource "+file);
}
System.out.println(file.getAbsolutePath());
String cuFileName = file.getAbsolutePath(); // /home/eyesis/workspace-python3/nvidia_dct8x8/src/dtt8x8.cuh";// "dtt8x8.cuh";
String sourceFile = readFileAsString(cuFileName); // readResourceAsString(cuFileName);
......
......@@ -206,8 +206,6 @@ public class JCuda_ImageJ_Example_Plugin implements PlugInFilter
*/
private static String readResourceAsString(String name)
{
int a = 0;
Class ccc = JCuda_ImageJ_Example_Plugin.class;
InputStream inputStream =
JCuda_ImageJ_Example_Plugin.class.getResourceAsStream(name);
if (inputStream == null)
......
......@@ -1920,6 +1920,7 @@ public class TwoQuadCLT {
String [] rgb_titles = {"red","blue","green"};
int out_width = GPUTileProcessor.IMG_WIDTH + GPUTileProcessor.DTT_SIZE;
int out_height = GPUTileProcessor.IMG_HEIGHT + GPUTileProcessor.DTT_SIZE;
/*
for (int ncam = 0; ncam < iclt_fimg.length; ncam++) {
String title=name+"-RBG"+String.format("%02d", ncam);
......@@ -1931,7 +1932,7 @@ public class TwoQuadCLT {
title,
rgb_titles);
}
*/
ImagePlus [] imps_RGB = new ImagePlus[iclt_fimg.length];
for (int ncam = 0; ncam < iclt_fimg.length; ncam++) {
String title=name+"-"+String.format("%02d", ncam);
......@@ -2081,9 +2082,12 @@ public class TwoQuadCLT {
double_stacks_main[i][2][j]*=0.5; // Scale green 0.5 to compensate more pixels than R,B
}
}
for (int i = 0; i < double_stacks_aux.length; i++){
for (int j =0 ; j < double_stacks_aux[i][0].length; j++){
double_stacks_aux[i][2][j]*=0.5; // Scale green 0.5 to compensate more pixels than R,B
if (double_stacks_aux[i].length > 2) { // skip for monochrome, only if color
for (int j =0 ; j < double_stacks_aux[i][0].length; j++){
double_stacks_aux[i][2][j]*=0.5; // Scale green 0.5 to compensate more pixels than R,B
}
}
}
quadCLT_main.setTiles (imp_quad_main[0], // set global tp.tilesX, tp.tilesY
......
This diff is collapsed.
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