Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Cannot get camera list by android NDK

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #22567

    NgapWei

    <div class=”post-text”>

    Trying to build an app with Qt5.12.3 and opencv4.1.2(android prebuild version from the [opencv release page][1]). But cannot get camera list by “ACameraManager_getCameraIdList”.

    • Mobile : Sony xperia XA1 Ultra
    • Qt: 5.12.3
    • NDK : r19c
    • minimum target: 24
    • maximum target: 28
    • Android library link to : libcamera2ndk.so and libmediandk.so, I link to the libs of api 28, not 24(android-28\arch-arm\usr\lib)
    • permissions:
    • arch : armeabi-v7a

    Extra so files I add into the project

    contains(ANDROID_TARGET_ARCH, armeabi-v7a) {
    ANDROID_EXTRA_LIBS = \
    C:/Users/yyyy/programs/Qt/android_camera/../../../3rdLibs/Android/android-ndk-r19c-windows-x86_64/android-ndk-r19c/platforms/android-28/arch-arm/usr/lib/libcamera2ndk.so \
    C:/Users/yyyy/programs/Qt/android_camera/../../../3rdLibs/Android/android-ndk-r19c-windows-x86_64/android-ndk-r19c/platforms/android-28/arch-arm/usr/lib/libmediandk.so \
    C:/Users/yyyy/programs/Qt/android_camera/../../../3rdLibs/opencv/opencv_4.1.2-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_java4.so
    }

     

    Source codes:

     

    #include <QApplication>
    #include <FelgoApplication>
    
    #include <QQmlApplicationEngine>
    
    #ifdef Q_OS_ANDROID
    
    #include <android/log.h>
    
    #include <camera/NdkCameraManager.h>
    
    #include <QDebug>
    
    //without this handler, debug message cannot print
    void myMessageHandler(
    QtMsgType type,
    const QMessageLogContext& context,
    const QString& msg
    )
    {
        const char*const applicationName="android_camera";
    
        QString report=msg;
        if (context.file && !QString(context.file).isEmpty()) {
           report+=" in file ";
           report+=QString(context.file);
           report+=" line ";
           report+=QString::number(context.line);
        }
        if (context.function && !QString(context.function).isEmpty()) {
            report+=+" function ";
            report+=QString(context.function);
        }
        const char*const local=report.toLocal8Bit().constData();
        switch (type) {
        case QtDebugMsg:
            __android_log_write(ANDROID_LOG_DEBUG,applicationName,local);
        break;
        case QtInfoMsg:
            __android_log_write(ANDROID_LOG_INFO,applicationName,local);
        break;
        case QtWarningMsg:
            __android_log_write(ANDROID_LOG_WARN,applicationName,local);
        break;
        case QtCriticalMsg:
            __android_log_write(ANDROID_LOG_ERROR,applicationName,local);
        break;
        case QtFatalMsg:
        default:
            __android_log_write(ANDROID_LOG_FATAL,applicationName,local);
            abort();
        }
    }
    
    #endif
    
    
    int main(int argc, char *argv[]){
    QApplication app(argc, argv);
    
    #ifdef Q_OS_ANDROID
    qInstallMessageHandler(myMessageHandler);
    #endif
    
    FelgoApplication felgo;
    felgo.setPreservePlatformFonts(true);
    
    QQmlApplicationEngine engine;
    
    felgo.initialize(&engine);
    felgo.setLicenseKey(PRODUCT_LICENSE_KEY);
    felgo.setMainQmlFileName(QStringLiteral("qml/Main.qml"));
    
    engine.load(QUrl(felgo.mainQmlFileName()));
    
    qInfo()<<__func__<<"create camera manager";
    ACameraManager *camera_manager_ = ACameraManager_create();
    if(camera_manager_){
    qInfo()<<__func__<<"get camera ids";
    ACameraIdList *camera_ids = nullptr;
    auto const status = ACameraManager_getCameraIdList(camera_manager_, &camera_ids);
    qInfo()<<__func__<<"can get camera ids:"<<(camera_ids != nullptr)<<", status:"<<status;
    if(camera_ids){
        qInfo()<<__func__<<"camera number:"<<camera_ids->numCameras;
    }
    }else{
        qInfo()<<__func__<<"cannot create camera manager";
    }
    
    return app.exec();
    }

     

    Edit : Edit : Error code returned by ACameraManager_getCameraIdList is -870323804, none of the value of NdkCameraError.h looks like that, weird

    #22575

    Alex
    Felgo Team

    Hi,

    does this also happen with a plain Qt Quick project, without using Felgo? Then you could also post this question in the official Qt forums where you might find more people also using OpenCV together with Qt.

    Cheers,
    Alex

    #22580

    NgapWei

    Thanks, tried with QWidget and android ndk only, still give me weird error codes “-866653748”.

    I post it on

     

    Have no idea how to solve this issue, would give up on native api of c and use the java api first

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded