Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing android opencv is fixed #5885

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,28 @@ matrix:
language: android
dist: trusty
sudo: required
env: TARGET="android" NDK_DIR="android-ndk-r15c"
env: TARGET="android" NDK_DIR="android-ndk-r15c" GRADLE_TARGET="compileArm7DebugSources"
android:
components:
- build-tools-25.0.2
- android-19
cache:
directories:
- ~/.gradle
- ~/android-ndk-r15c

- os: linux
language: android
dist: trusty
sudo: required
env: TARGET="android" NDK_DIR="android-ndk-r15c" GRADLE_TARGET="compileX86DebugSources"
android:
components:
- build-tools-25.0.2
- android-19
cache:
directories:
- ~/.gradle
# - ~/.ccache
- ~/android-ndk-r15c


Expand Down
39 changes: 18 additions & 21 deletions examples/android/androidOpenCVExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ void ofApp::setup(){
ofSetOrientation(OF_ORIENTATION_90_LEFT);
// this makes the camera directly return grayscale image, faster!
grabber.setPixelFormat(OF_PIXELS_MONO);
grabber.setup(320,240);
gray.allocate(grabber.getWidth(),grabber.getHeight());
bg.allocate(grabber.getWidth(),grabber.getHeight());
//diff.allocate(grabber.getWidth(),grabber.getHeight());
//contourFinder.allocate(grabber.getWidth(),grabber.getHeight());
one_second_time = ofGetSystemTime();
grabber.setup(1280, 720);
gray.allocate((int) grabber.getWidth(), (int) grabber.getHeight());
bg.allocate((int) grabber.getWidth(), (int) grabber.getHeight());
one_second_time =0;
camera_fps = 0;
frames_one_sec = 0;
captureBg = true;
Expand All @@ -23,41 +21,40 @@ void ofApp::update(){
grabber.update();
if(grabber.isFrameNew()){
frames_one_sec++;
if( ofGetSystemTime() - one_second_time >= 1000){
if(ofGetElapsedTimef() - one_second_time >= 1.0){
camera_fps = frames_one_sec;
frames_one_sec = 0;
one_second_time = ofGetSystemTime();
one_second_time = ofGetElapsedTimef();
}
gray.setFromPixels(grabber.getPixels());
if(captureBg){
bg = gray;
captureBg = false;
}

//gray.absDiff(bg);
gray.threshold(80);
contourFinder.findContours(gray,10,grabber.getWidth()*grabber.getHeight()/3,10,true,true);
contourFinder.findContours(gray,grabber.getWidth()*grabber.getHeight()/20,grabber.getWidth()*grabber.getHeight()/3,10,true,true);
}
}

//--------------------------------------------------------------
void ofApp::draw(){
ofSetHexColor(0xFFFFFF);
gray.draw(5,5);
contourFinder.draw(5,5);
ofSetColor(0x000000);
ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate()),330,10);
ofDrawBitmapString("camera fps: " + ofToString(camera_fps),330,30);
ofSetColor(255, 255, 255);
gray.draw(0,0, 1920, 1080);
contourFinder.draw(0,0, 1920, 1080);
ofSetColor(255, 0, 255);
ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate()),100,10);
ofDrawBitmapString("camera fps: " + ofToString(camera_fps),100,30);
}

//--------------------------------------------------------------
void ofApp::keyPressed (int key){
void ofApp::keyPressed (int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
Expand Down Expand Up @@ -128,4 +125,4 @@ void ofApp::okPressed(){
//--------------------------------------------------------------
void ofApp::cancelPressed(){

}
}
8 changes: 4 additions & 4 deletions examples/android/androidOpenCVExample/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ofApp : public ofxAndroidApp{

bool captureBg;

int one_second_time;
int camera_fps;
int frames_one_sec;
float one_second_time;
float camera_fps;
float frames_one_sec;

};
};
20 changes: 11 additions & 9 deletions libs/openFrameworksCompiled/project/android/common-functions.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def addonPaths(ofRoot){


def parseAddonConfig(String addon, String param, String abi, defaultVal = []){
println "Parse addonconfig "+addon+"/addon_config.mk"
def ret = defaultVal

def file = new File(addon+"/addon_config.mk")
Expand All @@ -67,7 +66,7 @@ def parseAddonConfig(String addon, String param, String abi, defaultVal = []){
def group = (stripLine =~ /^(\w+)\s*(\+?=)\s*(.+)$/)
if(group.hasGroup() && group.size() == 1 && group[0].size() == 4){
if(group[0][1] == param) {
def _p = group[0][3].replaceAll("%", "**/*")
def _p = group[0][3].replaceAll("%", "*")
if (group[0][2] == '=') {
ret = [_p]
} else {
Expand Down Expand Up @@ -98,7 +97,7 @@ def addonSources(String root, String abi=""){
ret += addon+'/'+path
}
}
println "\n\n Addon sources "+ret
println "\n\n ADDON_SOURCES "+ret+"\n\n"

return ret
}
Expand All @@ -124,7 +123,7 @@ def addonSourcesExclude(String root, String abi=""){
}

// ret += "**/dlib/include/*"
println "\n exclude "+ret+"\n\n"
println "\n EXCLUDE "+ret+"\n\n"
return ret
}

Expand All @@ -142,11 +141,10 @@ def addonLdFlags(abi, ofRoot){
def f = new File(addon+"/"+path)
if(f.exists()) {
ret += f.toString();
println f.toString();
}
}
}

println "\n ADDON_LIBS "+ret+"\n\n"
return ret
}

Expand Down Expand Up @@ -200,6 +198,7 @@ def addonCppFlags(abi, ofRoot){
return "-I${folder}".toString()
}*/
}
println "\n ADDON_CFLAGS "+ret+"\n\n"
return ret
}

Expand Down Expand Up @@ -230,7 +229,7 @@ def addonJavaDependencies(root,abi=""){
}
}
}

println "\n JAVA_LIBS "+ret+"\n\n"
return ret
}

Expand Down Expand Up @@ -291,15 +290,14 @@ def coreCppFlags(abi, ofRoot){
def ofSource = ofRoot + 'libs/openFrameworks'
def libs = ofRoot + 'libs'

return ["-std=c++14",
def ret = ["-std=c++14",
"-Wall",
"-frtti",
"-fexceptions",
"-nostdlib ",
"-fno-short-enums",
"-ffunction-sections",
"-fdata-sections",

"-I${file(ofSource)}".toString(),
"-I${file(ofSource+"/3d")}".toString(),
"-I${file(ofSource+"/app")}".toString(),
Expand Down Expand Up @@ -343,6 +341,10 @@ def coreCppFlags(abi, ofRoot){
"-I${file(libs+'/libs/glu/include_android')}".toString()

]

println "\n CPP_FLAGS "+ret+"\n\n"

return ret;
}

def addonLdLibs(abi, ofRoot){
Expand Down
20 changes: 12 additions & 8 deletions scripts/ci/android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
set -ev
ROOT=${TRAVIS_BUILD_DIR:-"$( cd "$(dirname "$0")/../../.." ; pwd -P )"}
export ANDROID_NDK_HOME=$(cd ~/$NDK_DIR && pwd)
source $ROOT/scripts/ci/ccache.sh

if [ -z ${GRADLE_TARGET+x} ]; then
GRADLE_TARGET=compileArm7DebugSources
fi

gradle wrapper --gradle-version 3.3

~/projectGenerator/projectGenerator_linux -p"android" -o"$ROOT" $ROOT/examples/android/androidEmptyExample
#~/projectGenerator/projectGenerator_linux -p"android" -o"$ROOT" $ROOT/examples/android/androidOpenCVExample
#~/projectGenerator/projectGenerator_linux -p"android" -o"$ROOT" $ROOT/examples/android/androidImageExample
~/projectGenerator/projectGenerator_linux -p"android" -o"$ROOT" $ROOT/examples/android/androidOpenCVExample
~/projectGenerator/projectGenerator_linux -p"android" -o"$ROOT" $ROOT/examples/android/androidAssimpExample

echo "ANDROID_NDK_HOME: $ANDROID_NDK_HOME"
echo "org.gradle.caching=true" > $ROOT/examples/android/androidEmptyExample/gradle.properties
# echo "ccache.path=/usr/local/bin/ccache" >> $ROOT/examples/android/androidEmptyExample/local.properties
# echo "ndk.dir=~/${NDK_DIR}" >> $ROOT/examples/android/androidEmptyExample/local.properties
./gradlew -b $ROOT/examples/android/androidEmptyExample/build.gradle compileArm7DebugSources
#./gradlew -b $ROOT/examples/android/androidOpenCVExample/build.gradle compileArm7DebugSources
#./gradlew -b $ROOT/examples/android/androidImageExample/build.gradle compileArm7DebugSources
echo "org.gradle.caching=true" > $ROOT/examples/android/androidOpenCVExample/gradle.properties
echo "org.gradle.caching=true" > $ROOT/examples/android/androidAssimpExample/gradle.properties

./gradlew -b $ROOT/examples/android/androidEmptyExample/build.gradle $GRADLE_TARGET
./gradlew -b $ROOT/examples/android/androidOpenCVExample/build.gradle $GRADLE_TARGET
./gradlew -b $ROOT/examples/android/androidAssimpExample/build.gradle $GRADLE_TARGET