Results 1 to 3 of 3

Thread: image processing in OpenML using GL_ARB_imaging extensio

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Location
    MA
    Posts
    9

    image processing in OpenML using GL_ARB_imaging extensio

    I am now trying to get a transcoder based on nullxcode to do something useful. My first
    task is to switch the red and blue channels of the incoming video stream, for which I wrote the code below.

    Of course, it does not work as there is no device context or rendering context set within the nullxcode DLL--if there are any suggested/special settings for these it would be great to know about them.

    Is this generally the right way to approach this, or do people use for i/for j/memcpy . . . type loops if they are trying to do channel operations? On p. 104 of the OpenML Spec it indicates that the GL_ARB_imaging extension is used for image processing, but doesn't go into more detail than that.

    Thanks,

    Eliot

    /* Actually transcode an input buffer into an output buffer.
    * This is where the real work of a transcoder will occur.
    *
    * In our case, it's pretty trivial.
    */
    static bool
    transformBuffer(MLDDopen* pOpen,
    MLbyte* inBuf,
    MLint32 inSize,
    MLDDxcodeParams* inParams,
    MLbyte* outBuf,
    MLint32 outSize,
    MLDDxcodeParams* outParams)
    {
    bool rval = false;
    MLint32 ij=0;
    // matrix to swap red and blue chan.
    GLfloat colorMatrix[16] = {
    0.0, 0.0, 1.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    1.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 1.0
    };

    /* Must verify controls in order to catch incompatible settings
    * made via mlSendControls()
    */
    if (!verifyControls(inParams, outParams)) {
    return false;
    }

    /* Transform away...
    */
    if (pOpen->useCopyEngine) {
    // Original function--copies data from inBuf to outBuf
    // rval = (memcpy(outBuf, inBuf, inSize) ==
    outBuf);

    // First--to specify raster position transformed to screen
    coordinates,
    // need to set modelview and projection matrices for simple 2D
    rendering.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, (GLfloat) 320, 0.0, (GLfloat) 240);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // More setup
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_COLOR);
    glLoadMatrixf(colorMatrix);

    glDrawBuffer(GL_FRONT);
    glClear(GL_COLOR_BUFFER_BIT);
    glRasterPos2i(0,0);
    glDrawPixels(320,240, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)inBuf);
    glReadBuffer(GL_FRONT);
    glReadPixels(0,0,320,240, GL_RGB, GL_UNSIGNED_BYTE,(GLvoid *)outBuf);
    glMatrixMode(GL_MODELVIEW);
    // glDrawBuffer(GL_FRONT);
    rval = true;
    return rval;

    } else {
    memset(outBuf, 0, outSize);
    rval = true;
    }
    return rval;
    }

  2. #2
    Junior Member
    Join Date
    Feb 2005
    Location
    MPI for Informatics, Saarbruecken
    Posts
    3

    Re: image processing in OpenML using GL_ARB_imaging extensio

    I suspect that you have to create your own context, just like in an OpenGL application (try GLUT, and then "downscale" to native calls, only allocating pbuffers - EXT_framebuffer_object will soon help to avoid OS window manager calls for offscreen-rendering).
    /gernot

  3. #3
    Member
    Join Date
    Jul 2003
    Location
    Montreal
    Posts
    75

    Re: image processing in OpenML using GL_ARB_imaging extensio

    Perhaps you may want to profile this OpenGL solution vs. the more traditional "for-loop/memcpy" approach you mention. Depending on the architecture, you might find that transferring to an OpenGL board, and especially reading back from the board takes longer than plain memory operations (on many PC graphics boards, ReadPixels is much much slower than WritePixels).

Similar Threads

  1. Image Processing using OpenMAX AL
    By Sagiv B in forum OpenMAX AL
    Replies: 1
    Last Post: 05-29-2012, 04:12 PM
  2. Image Processing (GPGPU)
    By albus in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 2
    Last Post: 03-08-2011, 12:59 AM
  3. Looking for Simple Image Processing
    By wahabkotwal in forum OpenCL
    Replies: 2
    Last Post: 10-17-2010, 05:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •