Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting a Buffer to a Bitmap

Hello together, I am relatively new to opencv and trying to use it in an iOs app. OpenCV will be used for other things, too, but the first thing I'm trying to do is to create a Bitmap-Image from a CVImageBufferRef. I'm doing it that way because I need image data without any compression if possible.

The data I'm getting should be uncompressed BGRA bytes so I'm using this function

cv::cvtColor(frame, frame, CV_BGRA2GRAY);

because I only need gray values and then I turn it into a NSData-Object and save it like this:

NSData *dataForRawBytes = [NSData dataWithBytes:frame.data length:frame.elemSize()*frame.total()];

[dataForRawBytes writeToFile:imageName atomically:YES];

The problem is that the data I'm getting out of this is not an image I can see, it's just symbols and stuff.

I would like to know if there are better ways to use openCV for this and is there a really good documentation for openCV especially in connection with iOs?

I'm grateful for every hint and help. Thanks!

Converting a Buffer to a Bitmap

Hello together, I am relatively new to opencv and trying to use it in an iOs app. OpenCV will be used for other things, too, but the first thing I'm trying to do is to create a Bitmap-Image from a CVImageBufferRef. I'm doing it that way because I need image data without any compression if possible.

The data I'm getting should be uncompressed BGRA bytes so I'm using this function

cv::cvtColor(frame, frame, CV_BGRA2GRAY);

because I only need gray values and then I turn it into a NSData-Object and save it like this:

NSData *dataForRawBytes = [NSData dataWithBytes:frame.data length:frame.elemSize()*frame.total()];

[dataForRawBytes writeToFile:imageName atomically:YES];

The problem is that the data I'm getting out of this is not an image I can see, it's just symbols and stuff.

I would like to know if there are better ways to use openCV for this and is there a really good documentation for openCV especially in connection with iOs?

I'm grateful for every hint and help. Thanks!