Skip to content

Commit

Permalink
small changes to the console tab editing. TODO: add resolution and pi…
Browse files Browse the repository at this point in the history
…cture extension. Fixxed bug in history file with saturation time displaying 0
  • Loading branch information
degoossez committed Jun 11, 2014
1 parent 9e614ed commit 4cdfbd8
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 95 deletions.
Binary file modified bin/OVSR.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
1 change: 1 addition & 0 deletions bin/classes/.gitignore
@@ -1 +1,2 @@
/com
/.gitignore
Binary file modified bin/classes/com/denayer/ovsr/MainActivity.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/OpenCL$1.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/OpenCL$2.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/OpenCL.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/RsScript$1.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/RsScript$2.class
Binary file not shown.
Binary file modified bin/classes/com/denayer/ovsr/RsScript.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
18 changes: 0 additions & 18 deletions jni/OVSR.cpp
Expand Up @@ -301,15 +301,6 @@ void initOpenCL
(*env).CallVoidMethod(thisObject, setConsoleOutput, JavaString);
return;
}
/*
* Call the setConsoleOutput function.
*/
jclass MyJavaClass = (*env).FindClass("com/denayer/ovsr/OpenCL");
if (!MyJavaClass){
LOGD("METHOD NOT FOUND");
return;} /* method not found */
jmethodID setConsoleOutput = (*env).GetMethodID(MyJavaClass, "setConsoleOutput", "(Ljava/lang/String;)V");
(*env).CallVoidMethod(thisObject, setConsoleOutput, JavaString);
/*
* Step 6: Extract kernel from the built program.
*/
Expand Down Expand Up @@ -509,15 +500,6 @@ void initOpenCLFromInput
(*env).CallVoidMethod(thisObject, setConsoleOutput, JavaString);
return;
}
/*
* Call the setConsoleOutput function.
*/
jclass MyJavaClass = (*env).FindClass("com/denayer/ovsr/OpenCL");
if (!MyJavaClass){
LOGD("Method not found in OVSR.cpp on line 500");
return;} /* method not found */
jmethodID setConsoleOutput = (*env).GetMethodID(MyJavaClass, "setConsoleOutput", "(Ljava/lang/String;)V");
(*env).CallVoidMethod(thisObject, setConsoleOutput, JavaString);

fileName = env->GetStringUTFChars(kernelName, 0);
char result[100]; // array to hold the result.
Expand Down
Binary file modified libs/armeabi-v7a/libOVSR.so
Binary file not shown.
Binary file modified obj/local/armeabi-v7a/libOVSR.so
Binary file not shown.
Binary file modified obj/local/armeabi-v7a/objs-debug/OVSR/OVSR.o
Binary file not shown.
6 changes: 0 additions & 6 deletions src/com/denayer/ovsr/MainActivity.java
Expand Up @@ -911,12 +911,6 @@ public void onClick(DialogInterface dialog, int id) {
createToast("No OpenCL support!",false);
}
}
if(TimeView.getText()!="0")
{
String Method="OpenCL";
if(RenderScriptButton.isChecked()) Method="RenderScript";
LogFileObject.writeToFile("\n" + Method + " : " + fileName + " : " + TimeView.getText(), "LogFile.txt",false);
}
}
} );
final AlertDialog dialogFilterBox = builderFilterBox.create();
Expand Down
84 changes: 65 additions & 19 deletions src/com/denayer/ovsr/OpenCL.java
Expand Up @@ -19,6 +19,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.bytedeco.javacpp.avcodec;
Expand Down Expand Up @@ -49,6 +51,8 @@ public class OpenCL extends Object {
String kernelName = "";
private OnUpdateProcessBar mGUIUpdater = null;
static int dev_type;
static LogFile LogFileObject;

/*! \brief The OpenCL constructor.
*
* The constructor takes two arguments. Loads the available OpenCL library
Expand All @@ -59,8 +63,10 @@ public class OpenCL extends Object {
* @param imageView is the ImageView to put the result in
*/
public OpenCL(Context context, ImageView imageView) {
mContext = context; //<-- fill it with the Context you passed
mContext = context;
outputButton = imageView;
LogFileObject = new LogFile(mContext);

try {
//Odroid lib
System.load("/system/vendor/lib/libPVROCL.so");
Expand Down Expand Up @@ -100,9 +106,10 @@ public OpenCL(Context context, ImageView imageView) {
}
}
public OpenCL (Context context, ImageView imageView, OnUpdateProcessBar listener) {
mContext = context; //<-- fill it with the Context you passed
mContext = context;
outputButton = imageView;
mGUIUpdater = listener;
LogFileObject = new LogFile(mContext);
}
/*! \brief Returns a boolean to be able to check OpenCL support in the main code
*
Expand Down Expand Up @@ -205,8 +212,9 @@ public void OpenCLEdge ()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Edge",estimatedTime);
}
/*! \brief This function will be called when the Inverse button is clicked.
*
Expand All @@ -227,8 +235,10 @@ public void OpenCLInverse ()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Inverse",estimatedTime);

}
/*! \brief This function will be called when the Sharpen button is clicked.
*
Expand All @@ -249,8 +259,10 @@ public void OpenCLSharpen ()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Sharpen",estimatedTime);

}
/*! \brief This function will be called when the mediaan button is clicked.
*
Expand All @@ -272,8 +284,10 @@ public void OpenCLMediaan ()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Median",estimatedTime);

}
/*! \brief This function will be called when the Blur button is clicked.
*
Expand All @@ -294,8 +308,10 @@ public void OpenCLBlur ()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Blur",estimatedTime);

}
/*! \brief This function will be called when the saturatie button is clicked.
*
Expand Down Expand Up @@ -368,8 +384,10 @@ private void saturate()
shutdownOpenCL();
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
LogFile MyFile = new LogFile(mContext);
MyFile.writeToPublicFile(String.valueOf(estimatedTime), "TestResultsVideo.txt");
setTimeToLog(estimatedTime);

setHistory("Saturation",estimatedTime);

}
/*! \brief This function will copy a file from the assets folder specified by the argument to the execdir of the application.
*
Expand Down Expand Up @@ -409,6 +427,30 @@ public void setTimeFromJNI(float time)
v.setText(String.valueOf(time) + " ms");

}
/*! \brief The setTimeToLog function sets a value to the GUI in the log window.
*
*@param time is the time that has to be placed in the log field
*/
public void setTimeToLog(long time)
{
View rootView = ((Activity)mContext).getWindow().getDecorView().findViewById(android.R.id.content);
TextView v = (TextView) rootView.findViewById(R.id.timeview);
v.setText(String.valueOf(time) + " ms");

}
/*! \brief The setTimeToLog function adds a line with information to the history file
*
*@param filterName the name of the executed filter
*@param time the time needed to execute the filter
*/
public void setHistory(String filterName,long time)
{
String Method="RenderScript";
SimpleDateFormat formatter = new SimpleDateFormat("yyMMddHHmmss");
Date now = new Date();
String fileName = "RenderScript/" + filterName + formatter.format(now);
LogFileObject.writeToFile("\n" + Method + " : " + fileName + " : " + String.valueOf(time) + " ms", "LogFile.txt",false);
}
/*! \brief The setConsoleOutput function allows the native code to set a value to the GUI in the console window.
*
*@param ErrorLog is the error log that has to be placed in the console view.
Expand Down Expand Up @@ -442,8 +484,6 @@ public String getTemplate()
Log.e("login activity", "Can not read file: " + e.toString());
e.printStackTrace();
}


return template;
}
/*! \brief This function gives the kernelName a value.
Expand All @@ -459,12 +499,18 @@ public void setKernelName(String name) {
*/
public void codeFromFile(final String code)
{
long startTime = System.nanoTime();
initOpenCLFromInput(code, kernelName,dev_type);
nativeImage2DOpenCL(
bmpOrig,
bmpOpenCL
);
shutdownOpenCL();

long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
setTimeToLog(estimatedTime);
setHistory("Run time compiled",estimatedTime);
}
public void OpenCLVideo(String[] arg)
{
Expand Down Expand Up @@ -540,9 +586,8 @@ public void OpenCLVideo(String[] arg)
recorder.record(image);
counter++;
mGUIUpdater.updateProcessBar(String.valueOf(counter));
}

shutdownOpenCL();
}
shutdownOpenCL();
recorder.stop();
grabber.stop();
mGUIUpdater.updateProcessBar("Done");
Expand All @@ -552,6 +597,7 @@ public void OpenCLVideo(String[] arg)
long estimatedTime = System.nanoTime() - startTime;
estimatedTime = TimeUnit.NANOSECONDS.toMillis(estimatedTime);
Log.d("Time:",Long.toString(estimatedTime));
setTimeToLog(estimatedTime);
}
public interface OnUpdateProcessBar {
public void updateProcessBar(String message);
Expand Down

0 comments on commit 4cdfbd8

Please sign in to comment.