Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm4 committed Oct 27, 2023
2 parents af8fd92 + 87e3254 commit 055dcd5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 18 deletions.
2 changes: 2 additions & 0 deletions apps/app_demo_slproject/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* Install **cmake** if the IDE states it as missing.
* Build the project with **Hammer button** or with **Build > Make Project (Ctrl-F9)**
* The app can only run on real but not on virtual devices because the prebuilt OpenCV libraries (_lib/prebuilt/Android) are only built for the arm architectures armeabi-v7a and arm64-v8a. To run the app in a virtual device you would have to build OpenCV also for Android on the x86 architecture.
* Your connected device must be enabled for development. See development settings under the system settings. Also the device must allow USB Debugging under the development settings.
* After successful build you can start the app on a USB-connected device by clicking the **green start button**.
* If your device is not listed in the **Deployment Targets** dialog please check again your USB driver. In some cases, you have to download the appropriate driver from the device manufacturer.

(Note: You can't build the release version)
11 changes: 5 additions & 6 deletions apps/app_demo_slproject/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ android {
assets.srcDirs = ['src/main/assets']
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildTypes {
release {
minifyEnabled false
Expand All @@ -59,6 +53,11 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
}
ndkVersion '21.4.7075529'
namespace 'ch.bfh.cpvrlab'
lint {
abortOnError false
checkReleaseBuilds false
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.bfh.cpvrlab"
android:versionCode="2"
android:versionName="3.0.000">

Expand Down
2 changes: 1 addition & 1 deletion apps/app_demo_slproject/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:8.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
3 changes: 3 additions & 0 deletions apps/app_demo_slproject/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ org.gradle.daemon=true
org.gradle.warning.mode=all
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
18 changes: 14 additions & 4 deletions cmake/DownloadPrebuilts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1019,9 +1019,14 @@ elseif ("${SYSTEM_NAME_UPPER}" STREQUAL "ANDROID") #----------------------------
#set(OpenCV_VERSION "3.4.1")
set(OpenCV_PREBUILT_DIR "andV8_opencv_${OpenCV_VERSION}")
set(OpenCV_DIR "${PREBUILT_PATH}/${OpenCV_PREBUILT_DIR}")
set(OpenCV_LINK_DIR "${OpenCV_DIR}/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}")
set(OpenCV_INCLUDE_DIR "${OpenCV_DIR}/include")

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(OpenCV_LINK_DIR "${OpenCV_DIR}/Debug/${ANDROID_ABI}")
else ()
set(OpenCV_LINK_DIR "${OpenCV_DIR}/Release/${ANDROID_ABI}")
endif ()

set(OpenCV_LINK_LIBS
${OpenCV_LINK_LIBS}
cpufeatures
Expand Down Expand Up @@ -1075,7 +1080,12 @@ elseif ("${SYSTEM_NAME_UPPER}" STREQUAL "ANDROID") #----------------------------
set(g2o_PREBUILT_DIR "andV8_g2o")
set(g2o_DIR "${PREBUILT_PATH}/${g2o_PREBUILT_DIR}")
set(g2o_INCLUDE_DIR "${g2o_DIR}/include")
set(g2o_LINK_DIR "${g2o_DIR}/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}")

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(g2o_LINK_DIR "${g2o_DIR}/Debug/${ANDROID_ABI}")
else ()
set(g2o_LINK_DIR "${g2o_DIR}/Release/${ANDROID_ABI}")
endif ()

foreach (lib ${g2o_LINK_LIBS})
add_library(${lib} SHARED IMPORTED)
Expand Down Expand Up @@ -1160,15 +1170,15 @@ elseif ("${SYSTEM_NAME_UPPER}" STREQUAL "ANDROID") #----------------------------
add_library(MediaPipe::MediaPipe SHARED IMPORTED)
set_target_properties(MediaPipe::MediaPipe
PROPERTIES
IMPORTED_LOCATION_RELEASE "${MediaPipe_DIR}/release/libmediapipe.so"
IMPORTED_LOCATION "${MediaPipe_DIR}/release/libmediapipe.so"
IMPORTED_LOCATION_DEBUG "${MediaPipe_DIR}/debug/libmediapipe.so"
INTERFACE_INCLUDE_DIRECTORIES "${MediaPipe_DIR}/include"
)

add_library(MediaPipe::OpenCV_Java4 SHARED IMPORTED)
set_target_properties(MediaPipe::OpenCV_Java4
PROPERTIES
IMPORTED_LOCATION_RELEASE "${MediaPipe_DIR}/release/libopencv_java4.so"
IMPORTED_LOCATION "${MediaPipe_DIR}/release/libopencv_java4.so"
IMPORTED_LOCATION_DEBUG "${MediaPipe_DIR}/debug/libopencv_java4.so"
)

Expand Down
9 changes: 4 additions & 5 deletions modules/cv/source/CVImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,11 @@ void CVImage::load(const string& filename,

// load the image format as stored in the file

SLIOBuffer buffer = SLFileStorage::readIntoBuffer(filename, IOK_image);
CVMat inputMat = CVMat(1, (int)buffer.size, CV_8UC1, buffer.data);

#ifndef __EMSCRIPTEN__
_cvMat = cv::imdecode(inputMat, cv::ImreadModes::IMREAD_UNCHANGED);
_cvMat = cv::imread(filename, cv::ImreadModes::IMREAD_UNCHANGED);
#else
SLIOBuffer buffer = SLFileStorage::readIntoBuffer(filename, IOK_image);

unsigned char* encodedData = buffer.data;
int size = (int)buffer.size;
int width;
Expand All @@ -401,9 +400,9 @@ void CVImage::load(const string& filename,
stbi_hdr_to_ldr_gamma(1.0f);
unsigned char* data = stbi_load_from_memory(encodedData, size, &width, &height, &numChannels, 0);
_cvMat = CVMat(height, width, CV_8UC(numChannels), data);
#endif

SLFileStorage::deleteBuffer(buffer);
#endif

if (!_cvMat.data)
{
Expand Down

0 comments on commit 055dcd5

Please sign in to comment.