Can't import some packages in JavaCV

104 views
Skip to first unread message

Tamada

unread,
Nov 7, 2022, 8:12:24 AM11/7/22
to javacv
I'm trying to create a facial recognition app based on this example(https://github.com/bytedeco/javacv/blob/master/samples/OpenCVFaceRecognizer.java) and using javacv 1.5.x, but some imports don't work. Here problems with those imports:
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.DoublePointer;

import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_face.*;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;


I decided to figure it out then, to start with an example(https://github.com/bytedeco/gradle-javacpp/blob/master/samples/javacv-demo/src/main/java/org/bytedeco/javacv/samples/Demo.java) using gradle-javacpp, to take imports from there, but they don't work either. In this case i have problem with following packages:
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_calib3d.*;
import static org.bytedeco.opencv.global.opencv_objdetect.*;


Also I don't have packages displayed inside org.bytedeco.opencv. So there is a problem and with these imports as well

import org.bytedeco.opencv.opencv_core.*;
import org.bytedeco.opencv.opencv_imgproc.*;
import org.bytedeco.opencv.opencv_calib3d.*;
import org.bytedeco.opencv.opencv_objdetect.*;


my top-level build.gradle:

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


app/build.gradle:

plugins {
    id 'com.android.application'
    id 'org.bytedeco.gradle-javacpp-platform' version '1.5.8'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.findyourselfinthephoto"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        //coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/native-image/**/**.json'
        exclude 'META-INF/native-image/*.json'
        exclude 'META-INF/native-image/**'
        //pickFirst 'nd4j-native.properties'
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'com.github.martipello:MultiImageView:1.0.8.2' //MultiImageView(PhotoCollage)

    implementation 'com.squareup.okhttp3:okhttp:4.10.0' //get-requests
    implementation 'com.sezinkarli:random-user-agent-generator:1.3' //random user-agent

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //implementation project(path: ':OpenCVLibrary')

    implementation 'com.github.onimur:handle-path-oz:1.0.7' //handle real path

    implementation 'org.bytedeco:javacv-platform:1.5.8'
    implementation 'org.bytedeco:opencv-platform:4.6.0-1.5.8'
    implementation 'org.bytedeco:opencv-platform-gpu:4.6.0-1.5.8'
    implementation 'org.bytedeco:ffmpeg-platform:5.1.2-1.5.8'
    implementation 'org.bytedeco:ffmpeg-platform-gpl:5.1.2-1.5.8'
}


settings.gradle:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io'} //for MultiImageView
    }
}
rootProject.name = "FindYourselfInThePhoto"
include ':app'
//include ':OpenCVLibrary'

Samuel Audet

unread,
Nov 9, 2022, 4:57:42 AM11/9/22
to jav...@googlegroups.com, Tamada
On 11/7/22 21:17, Tamada wrote:
> my top-level build.gradle:

Adding dependencies there won't add them to your Android project. You'll
need to add them to app/build.gradle as per the instructions here:
https://github.com/bytedeco/gradle-javacpp#the-platform-plugin

Samuel
Reply all
Reply to author
Forward
0 new messages