Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JavaCV IplImage to LibGDX texture #708

Closed
midn1 opened this issue Jun 2, 2017 · 4 comments
Closed

JavaCV IplImage to LibGDX texture #708

midn1 opened this issue Jun 2, 2017 · 4 comments

Comments

@midn1
Copy link

midn1 commented Jun 2, 2017

Is this possible?

@saudet
Copy link
Member

saudet commented Mar 24, 2019

BTW, what we should do for this is to create a new LibGDXFrameConverter or something.

@shan-luan
Copy link
Contributor

    /**
     * Convert Frame to Pixmap.
     *
     * @param frame AV_PIX_FMT_RGBA Frame object
     * @return RGBA8888 Pixmap objects
     * @author Shan-luan
     */
    public Pixmap convert(Frame frame) {
        return convert(frame, new Pixmap(frame.imageWidth, frame.imageHeight, Pixmap.Format.RGBA8888));
    }

    public Pixmap convert(Frame frame, Pixmap pixmap) {
        if (pixmap.getFormat() != Pixmap.Format.RGBA8888) {
            throw new IllegalArgumentException("Pixmap format must be RGBA8888");
        }
        ByteBuffer frameBuffer = (ByteBuffer) frame.image[0];
        ByteBuffer pixmapBuffer = pixmap.getPixels();
        pixmapBuffer.position(0);
        frameBuffer.rewind();
        pixmapBuffer.put(frameBuffer);
        pixmapBuffer.flip();
        return pixmap;
    }

I made one,You can first use org.bytedeco.javacv.OpenCVFrameConverter to convert IplImage to Frame, and then use this method to get a Pixmap, and then use Pixmap to get a Texture.

@saudet
Copy link
Member

saudet commented Jan 22, 2025

@shan-luan Thanks! Please open a pull request

@saudet
Copy link
Member

saudet commented Jan 28, 2025

@shan-luan Thanks for the contribution!

@saudet saudet closed this as completed Jan 28, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants