UIImage from Easyar_Image

+2 votes
asked Sep 2, 2018 by mirgas (140 points)

Hello, 

I am string to get an UIImage (iOS )from an Easyar_Image.

As described in the documentation, I can get image data with this code :

easyar_Frame * frame = [streamer peek];
for (easyar_Image * i in [frame images]) {
    easyar_Buffer * b = [i buffer];
    char * bytes = calloc([b size], 1);
    memcpy(bytes, [b data], [b size]);
    //TODO: use bytes here
    free(bytes);
}

So I tried to create an image like this :

        easyar_Frame * frame = [streamer peek];
        for (easyar_Image * i in [frame images]) {
            easyar_Buffer * b = [i buffer];
            char * bytes = calloc([b size], 1);
            memcpy(bytes, [b data], [b size]);
            NSData *imageData = [NSData dataWithBytes:[b data] length:[b size]];
            UIImage *image = [UIImage imageWithData:imageData];
    }

But the image is always nil, indicating that the image couldn't be initialised with the specified data.

Any Idea ?

Thanks !

Please log in or register to answer this question.

Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...