Commit 9c9cebb7 authored by Andrey Filippov's avatar Andrey Filippov

Added viewer for raw binary images from C/GPU

parent 33cdb962
...@@ -641,6 +641,7 @@ private Panel panel1, ...@@ -641,6 +641,7 @@ private Panel panel1,
addButton("JCUDA TEST", panelClt_GPU); addButton("JCUDA TEST", panelClt_GPU);
addButton("TF TEST", panelClt_GPU); addButton("TF TEST", panelClt_GPU);
addButton("Rig8 gpu", panelClt_GPU, color_conf_process); addButton("Rig8 gpu", panelClt_GPU, color_conf_process);
addButton("ShowGPU", panelClt_GPU, color_conf_process);
add(panelClt_GPU); add(panelClt_GPU);
} }
...@@ -4584,6 +4585,13 @@ private Panel panel1, ...@@ -4584,6 +4585,13 @@ private Panel panel1,
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
getPairImages2Gpu(); getPairImages2Gpu();
return; return;
/* ======================================================================== */
} else if (label.equals("ShowGPU")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
showImageFromGPU();
return;
//
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("RIG extrinsics")) { } else if (label.equals("RIG extrinsics")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
...@@ -5129,6 +5137,12 @@ private Panel panel1, ...@@ -5129,6 +5137,12 @@ private Panel panel1,
return true; return true;
} }
public boolean showImageFromGPU(){
// TWO_QUAD_CLT.showImageFromGPU();
TwoQuadCLT.showImageFromGPU();
return true;
}
public boolean getPairImages2Gpu() { public boolean getPairImages2Gpu() {
if (!prepareRigImages()) return false; if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath(); String configPath=getSaveCongigPath();
......
...@@ -22,13 +22,16 @@ ...@@ -22,13 +22,16 @@
*/ */
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
...@@ -912,6 +915,57 @@ public class TwoQuadCLT { ...@@ -912,6 +915,57 @@ public class TwoQuadCLT {
return results; return results;
} }
public static void showImageFromGPU() {
int width = 2592+8;
int height = 1936+8;
int l = width*height;
String path = "/home/eyesis/workspace-python3/nvidia_dct8x8/clt/main_chn0.rbg";
String [] titles= {"R","B","G"};
float [] img_rbg = getFloatsFromFile(path);
float [][] img = new float [3][l];
for(int nc = 0; nc < 3; nc++) {
System.arraycopy(img_rbg, l * nc, img[nc], 0 ,l);
}
(new showDoubleFloatArrays()).showArrays(
img,
width,
height,
true,
"RBG",
titles);
}
public static float [] getFloatsFromFile(String filepath) {
float [] fdata = null;
try {
FileInputStream inFile = new FileInputStream(filepath);
// DataInputStream din = new DataInputStream(inFile);
FileChannel inChannel = inFile.getChannel();
int cl = (int) inChannel.size();
ByteBuffer buffer = ByteBuffer.allocateDirect(cl); //1024*1024*60);
buffer.order(ByteOrder.LITTLE_ENDIAN);
buffer.clear();
inChannel.read(buffer);
buffer.flip();
FloatBuffer fb = buffer.asFloatBuffer();
fdata = new float[fb.limit()];
fb.get(fdata);
// fdata = fb.array();
inFile.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fdata;
}
public void saveFloatKernels(String file_prefix, public void saveFloatKernels(String file_prefix,
double [][][][][][] clt_kernels, double [][][][][][] clt_kernels,
double [][][] image_data, double [][][] image_data,
......
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