ofxPiMapper icon indicating copy to clipboard operation
ofxPiMapper copied to clipboard

Raspberry Pi 4 B

Open techgunk opened this issue 5 years ago • 14 comments

I'm trying to get this working on some Rpi 4 B to use at a gallery, is the Rpi 4 not supported?

techgunk avatar Jan 16 '20 15:01 techgunk

Not yet

—- Krisjanis Rijnieks Creative coding. Projection mapping. Solutions https://rijnieks.com

On 16. Jan 2020, at 17:41, techgunk [email protected] wrote:

 I'm trying to get this working on some Rpi 4 B to use at a gallery, is the Rpi 4 not supported?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

kr15h avatar Jan 16 '20 16:01 kr15h

Hello!

Considering using this on a project and I'd love to use RPI4, happy to help with the porting effort if I can.

Would you mind briefly summarising what would be necessary for the port if you know? OF has been ported to RPI4 now, so is there a lot that needs to be done on top of that?

eshkrab avatar Apr 29 '20 19:04 eshkrab

@eshkrab Why don't you test it and report what is not working.....

magdesign avatar Apr 29 '20 19:04 magdesign

@magdesign I'm not at the stage of this project where it's appropriate to test solutions, especially when they're known to not be working. I just asked the dev if they happen to know any of the big-picture problems since they said rpi4 is definitely not supported and I've helped the oF rpi4 porting efforts in the past, didn't mean for that to come off as lazy or to upset anyone.

eshkrab avatar Apr 29 '20 20:04 eshkrab

It takes a lot of time to test things, if someone can tell: I installed this, compiled this, that was working but stuck here, its much easier for a dev to fix the issue. That's how opensource works.

So why not installing OF on your RPI4, compile PiMapper and test if it works or what errors you get... the community will help.

magdesign avatar Apr 29 '20 20:04 magdesign

Thank you for your input, I'll post if I end up using this and have issues I can't fix myself

eshkrab avatar Apr 29 '20 20:04 eshkrab

It takes a lot of time to test things, if someone can tell: I installed this, compiled this, that was working but stuck here, its much easier for a dev to fix the issue. That's how opensource works.

So why not installing OF on your RPI4, compile PiMapper and test if it works or what errors you get... the community will help.

1588835685(1) when I compile example_basic in ofxPimapper addon on Raspberry 4B, I get this error ,who can help me to solve this problem

sxy2069 avatar May 07 '20 07:05 sxy2069

Hi!

Seems like the same issues are there when I last tested. There are some problems with the new gl stuff. I believe a new window class has to be created. @jvcleave seems to be working in that.

cheers

—- Krisjanis Rijnieks Creative coding. Projection mapping. Solutions https://rijnieks.com

On 7. May 2020, at 10:18, sxy2069 [email protected] wrote:

 It takes a lot of time to test things, if someone can tell: I installed this, compiled this, that was working but stuck here, its much easier for a dev to fix the issue. That's how opensource works.

So why not installing OF on your RPI4, compile PiMapper and test if it works or what errors you get... the community will help.

when I compile example_basic in ofxPimapper addon on Raspberry 4B, I get this error ,who can help me to solve this problem

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

kr15h avatar May 07 '20 07:05 kr15h

unlikely to have texture mode support on the RPI4 https://github.com/jvcleave/ofxOMXPlayer/issues/157

jvcleave avatar May 07 '20 15:05 jvcleave

Hey so the odd thing is that I seem to be getting the exact same error on a Pi 3B+. Did a fresh install of the latest stable version of Noobs and open frameworks today to make sure everything was installed correctly and I got the same error. Any idea what I might have done wrong? I had no issue getting ofxOMXPlayer working in the past.

mysticcircuits avatar May 08 '20 09:05 mysticcircuits

I don't have an Pi 3B+ to test but it looks like maybe eglCreateImageKHR has been moved in Buster

If that is the case, there was a new way I was using to access it on the RPI4 that may work. See this commit

https://github.com/jvcleave/ofxOMXPlayer/commit/94178e69d2be5e7ba45c724e3c666009896a7ba1

the important parts are in this block

static PFNEGLCREATEIMAGEKHRPROC createImageProc = NULL;
EGLImageKHR createImage(EGLDisplay dpy, EGLContext ctx, EGLenum target,
                        EGLClientBuffer buffer, const EGLint *attrib_list)
{
    if (!createImageProc)
    {
        createImageProc = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
    }
    
    return createImageProc(dpy, ctx, target, buffer, attrib_list);
}
static PFNEGLDESTROYIMAGEKHRPROC destroyImageProc = NULL;

EGLBoolean destroyImage(EGLDisplay dpy, EGLImageKHR image)
{
    if (!destroyImageProc)
    {
        destroyImageProc = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
    }
    
    return destroyImageProc(dpy, image);
}

bool ofxOMXPlayerEngine::generateEGLImage()
{
    bool success = false;
    bool needsRegeneration = false;
    
    if (!texture.isAllocated())
    {
        needsRegeneration = true;
    }
    else
    {
        if (texture.getWidth() != videoWidth && texture.getHeight() != videoHeight)
        {
            needsRegeneration = true;
        }
    }
    
    if (!fbo.isAllocated())
    {
        needsRegeneration = true;
    }
    else
    {
        if (fbo.getWidth() != videoWidth && fbo.getHeight() != videoHeight)
        {
            needsRegeneration = true;
        }
    }
    
    if(!needsRegeneration)
    {
        //ofLogVerbose(__func__) << "NO CHANGES NEEDED - RETURNING EARLY";
        return true;
    }
    
    if (appEGLWindow == NULL)
    {
        appEGLWindow = (ofAppEGLWindow *) ofGetWindowPtr();
    }
    
    if (appEGLWindow == NULL)
    {
        ofLogError(__func__) << "appEGLWindow is NULL - RETURNING";
        return false;
    }
    if (display == NULL)
    {
        display = appEGLWindow->getEglDisplay();
    }
    if (context == NULL)
    {
        context = appEGLWindow->getEglContext();
    }
    
    if (display == NULL)
    {
        ofLogError(__func__) << "display is NULL - RETURNING";
        return false;
    }
    if (context == NULL)
    {
        ofLogError(__func__) << "context is NULL - RETURNING";
        return false;
    }
    
    if (needsRegeneration)
    {
        
        fbo.allocate(videoWidth, videoHeight, GL_RGBA);
        texture.allocate(videoWidth, videoHeight, GL_RGBA);
        texture.setTextureWrap(GL_REPEAT, GL_REPEAT);
        textureID = texture.getTextureData().textureID;
    }
    
    ofLog() << "textureID: " << textureID;
    ofLog() << "tex.isAllocated(): " << texture.isAllocated();
    ofLog() << "videoWidth: " << videoWidth;
    ofLog() << "videoHeight: " << videoHeight;
    ofLog() << "pixels: " << videoHeight;
    
    // setup first texture
    int dataSize = videoWidth * videoHeight * 4;
    
    if (pixels && needsRegeneration)
    {
        delete[] pixels;
        pixels = NULL;
    }
    
    if (pixels == NULL)
    {
        pixels = new unsigned char[dataSize];
    }
    ofLog() << "dataSize: " << dataSize;
    
    //memset(pixels, 0xff, dataSize);  // white texture, opaque
    
    glBindTexture(GL_TEXTURE_2D, textureID);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, videoWidth, videoHeight, 0,
                 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
    
    
    if (eglImage && needsRegeneration)
    {
        destroyEGLImage();
    }
    
    // Create EGL Image
    eglImage = createImage(display, context, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)textureID, NULL);

    if (eglImage == EGL_NO_IMAGE_KHR)
    {
        ofLog()    << "Create EGLImage FAIL <---------------- :(";
        
    }
    else
    {
        success = true;
        ofLog()  << "Create EGLImage PASS <---------------- :)";
    }
    return success;
    
}

void ofxOMXPlayerEngine::destroyEGLImage()
{
    
    
    if (eglImage)
    {
        if (appEGLWindow == NULL)
        {
            appEGLWindow = (ofAppEGLWindow *) ofGetWindowPtr();
        }
        
        if (display == NULL)
        {
            display = appEGLWindow->getEglDisplay();
        }
        
        if (!destroyImage(display, eglImage))
        {
            ofLog() << __func__ << " FAIL <---------------- :(";
        }else
        {
            ofLog() << __func__ << " PASS <---------------- :)";
        }
        eglImage = NULL;
    }
    
}

jvcleave avatar May 08 '20 16:05 jvcleave

news about pi 4? thx

pietrondo avatar May 29 '20 11:05 pietrondo

Nope. I have the feeling that one has to make a new Pi Mapper for Pi 4 actually.

kr15h avatar May 29 '20 11:05 kr15h

Anything new @kr15h ? Thanks a lot

Brumeux avatar Sep 01 '21 14:09 Brumeux