bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.53k stars 1.58k forks source link

Problems with linking, Image stitching #2124

Open ankhafizov opened 11 months ago

ankhafizov commented 11 months ago

Greetings! I found this library the most convinient wa for image stitching since this function did not implemented in traditional org.opencv. Btw, I am writing an app for android

Meanwhile, I encountered the folowwing error with stitching while other functions work correctly: image

Probably it is connected with installation process. So my gradle:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.digtp.minearologyscanner'
    compileSdk 34

    defaultConfig {
        applicationId "com.digtp.minearologyscanner"
        minSdk 28
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

configurations {
    javacpp
}

task javacppExtract(type: Copy) {
    dependsOn configurations.javacpp

    from { configurations.javacpp.collect { zipTree(it) } }
    include "lib/**"
    into "$buildDir/javacpp/"
    android.sourceSets.main.jniLibs.srcDirs += ["$buildDir/javacpp/lib/"]

    tasks.getByName('preBuild').dependsOn javacppExtract
}

dependencies {
    implementation 'androidx.core:core-ktx:1.12.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
    implementation project(path: ':opencv')
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.9'
    javacpp group: 'org.bytedeco', name: 'openblas-platform', version: '0.3.23-1.5.9'
    javacpp group: 'org.bytedeco', name: 'opencv-platform', version: '4.7.0-1.5.9'
    javacpp group: 'org.bytedeco', name: 'ffmpeg-platform', version: '6.0-1.5.9'
}
saudet commented 11 months ago

There's a working sample project here, if that's what you're looking for: https://github.com/bytedeco/sample-projects/tree/master/JavaCV-android-example

ankhafizov commented 11 months ago

I am looking for ny insights how to tackle my problem with, i.e. stitching and linking ro opencl (screenshot above). As I see, the graddle file is similar to https://github.com/bytedeco/sample-projects/blob/master/JavaCV-android-example/app/build.gradle

saudet commented 11 months ago

The errors about OpenCL are just warnings, you can ignore them.

ankhafizov commented 11 months ago

Thank you a lot! Really, the crash of my app was because of the RAM memory lack when 16 images was put to Stitcher simultaneously. Crashed without any callback. Probably, callback for memory exception will be a greate feature