mardi 4 août 2015

How can I create a cv:Mat from UIImage/NSData?

I'm working on image recognition for our company app (iOS).

Initially what I wanted to do is: to make a photo of some digits number and try to use recognition library tesseract. The problem is: the tesseract doesn't work good enough for me. So I decided to use image recognition instead of text recognition library.

I've made pictures of numbers from 0 to 9 with the font I need with the background I need. Next I take a photo of a number (which consists of several digits). Then I wanna compare the digits to the pictures I've made. The algorithm I've found on the internet. The problem is: I have to create a cv::Mat object for the photo, which I've taken in order to make a comparison. I'm working with iOS (Objective-C), so the image object is UIImage. How can I convert the UIImage to the cv::Mat object ?

I need somehow to decode the NSData object to the cv::Mat (the NSData object I can get from the following code, where testedImage is the UIImage*)

NSData *testedImageData = UIImagePNGRepresentation(testedImage);

The only way I can do it now is to save the picture on the file system and then get it's path and create a cv::Mat object, but it's not a good idea ...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire