โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

error when starting android kivy app using mediapipe

this is my first entry here means i am also thankful for any advice on how i can improve my postings here.

I am working on an app written in python which i want to build also for Android devices.For this purpose i have:

  1. Setup an Ubuntu 20.4 VM
  2. Installed and configured buildozer
  3. Written the app with the kivy framework

Building Android APK files with this setup works quit fine for smaller kivy apps with only basic functionalities and dependencies. Unfortunately i also need Googles pose estimation Mediapipe https://mediapipe.dev/.

When i try to run the App on my Android device

Samsung Galaxy S10+ : CPU Architecture ARMv8-A / arm64-v8a

i receive the following error:

Logfile

[11-28 19:27:08.240 14013:30612 I/python] ImportError: dlopen failed: "/data/user/0/sens.app.sensaiapp/files/app/_python_bundle/site-packages/mediapipe/python/_framework_bindings.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)

Respective Entry in the Buildozer config file:

requirements = python3,kivy,opencv,pandas,numpy,mediapipe,android

(str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86

android.arch = arm64-v8a

I have also tried to build mediapipe according to the following guidelines: https://github.com/jiuqiant/mediapipe_python_aarch64/blob/main/README.md

Unfortunately this didnt solve the issue and i couldnt find any related issues online so i am stuck now.

Means i would be really thankfull if anyone has faced the same issue and give me a hint towards the right solution.Let me know if there is further information i need to provide to draw the full picture for you.

Thanks in advance!

How can I use the camera feature with MediaPipe in Flutter?

I am developing an artificial intelligence application and need to integrate it into a mobile app. I require the use of a MediaPipe camera integration for this mobile app, but I have found limited examples online. While there are many examples in Kotlin, I specifically need to implement it in Flutter. Can you assist me with this

Why write to closed pipe returns success

I recently read a post. In this post,Sonerclosed the read end of the pipe for both parent and child process.But when write to the pipe, It seems that no SIGPIPE signal is generated.

I modified the code,to make sure that read end of the pipe is really closed and write call return without any error.

here is my code

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <signal.h>
#define BUFSIZE 100

char const * errMsgPipe = "signal handled SIGPIPE\n";
int errMsgPipeLen;

void handler(int x) {
    write(2, errMsgPipe, errMsgPipeLen);
}

int main(void) {
    errMsgPipeLen = strlen(errMsgPipe);
    char bufin[BUFSIZE] = "empty";
    char bufout[] = "hello soner";
    int bytesin;
    pid_t childpid;
    int fd[2];

    struct sigaction sa;
    memset(&sa, 0, sizeof(sa));
    sa.sa_flags = 0;
    sigfillset(&sa.sa_mask);
    sa.sa_handler = handler;
    sigaction(SIGPIPE, &sa, 0);

    if (pipe(fd) == -1) {
        perror("Failed to create the pipe");
        return 1;
    }
    bytesin = strlen(bufin);
    childpid = fork();
    if (childpid == -1) {
        perror("Failed to fork");
        return 1;
    }

    close(fd[0]);

    if (childpid) {
        int ret = write(fd[1], bufout, strlen(bufout)+1);
        if (ret < 0) {
            perror("write");
        } else {
                printf("write success, ret: %d\n", ret );
        }
        wait(NULL);
    }
    else{
        bytesin = read(fd[0], bufin, BUFSIZE);
        if(bytesin == -1) {
                perror("child: read");
        }
    }
    fprintf(stderr, "[%ld]:my bufin is {%.*s}, my bufout is {%s}\n",
            (long)getpid(), bytesin, bufin, bufout);
    return 0;
}

output:

write success, ret: 12
child: read: Bad file descriptor
[9168]:my bufin is {empty}, my bufout is {hello soner}
[9167]:my bufin is {empty}, my bufout is {hello soner}

I modified the code as bellow:

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>

#define BUFSIZE 100

char const * errMsgPipe = "signal handled SIGPIPE\n";
int errMsgPipeLen;

void handler(int x) {
    write(2, errMsgPipe, errMsgPipeLen);
}

int main(void) {
    errMsgPipeLen = strlen(errMsgPipe);
    char bufin[BUFSIZE] = "empty";
    char bufout[] = "hello soner";
    int bytesin;
    pid_t childpid;
    int fd[2];

    struct sigaction sa;
    memset(&sa, 0, sizeof(sa));
    sa.sa_flags = 0;
    sigfillset(&sa.sa_mask);
    sa.sa_handler = handler;
    sigaction(SIGPIPE, &sa, 0);

    if (pipe(fd) == -1) {
        perror("Failed to create the pipe");
        return 1;
    }
    close(fd[0]);
    bytesin = strlen(bufin);
    childpid = fork();
    if (childpid == -1) {
        perror("Failed to fork");
        return 1;
    }


    if (childpid) {
        int flag = fcntl(fd[0], F_GETFD);
        if(flag = -1) {
                printf("pid:[%d], fcntl: %s\n", getpid(), strerror(errno));
        } else {
                printf("pip: [%d], fd[0] is not closed\n");
        }
        if (write(fd[1], bufout, strlen(bufout)+1) < 0) {
            perror("write");
        }
        //
    }
    else{
        int flag = fcntl(fd[0], F_GETFD);
        if(flag = -1) {
                printf("pid:[%d], fcntl: %s\n", getpid(), strerror(errno));
        } else {
                printf("pip: [%d], fd[0] is not closed\n");
        }
        bytesin = read(fd[0], bufin, BUFSIZE);
        if(bytesin == -1) {
                perror("read");
        }
    }
    fprintf(stderr, "[%ld]:my bufin is {%.*s}, my bufout is {%s}\n",
            (long)getpid(), bytesin, bufin, bufout);
    return 0;
}

But when I run the program multiple times, it produces different result. For example:

pid:[9200], fcntl: Bad file descriptor
signal handled SIGPIPE
write: Broken pipe
pid:[9201], fcntl: Bad file descriptor
[9200]:my bufin is {empty}, my bufout is {hello soner}
read: Bad file descriptor
[9201]:my bufin is {empty}, my bufout is {hello soner}

another result:

pid:[9189], fcntl: Bad file descriptor
[9189]:my bufin is {empty}, my bufout is {hello soner}
pid:[9190], fcntl: Bad file descriptor
read: Bad file descriptor
[9190]:my bufin is {empty}, my bufout is {hello soner}
โŒ
โŒ