How can I get the texts presented on an image ?
Description : "I am developing one application which needs to get the text presented on an Image and show the text in an another view after putting the texts in to some frames."
EDIT : From this I'm getting some Values and also the ".png" but the characters I am getting is like ASCII value or something.
UIImage*img=[UIImage imageNamed:#"btn_reset.png"];
NSData *dataObj = UIImagePNGRepresentation(img);
NSString*str= [[NSString alloc] initWithData:dataObj encoding:NSASCIIStringEncoding];
printf("Image is %s",[str UTF8String]);
Any tutorial/link/solution would be very helpful.
Thank You !
I couldn't understand the question clearly, but I think you are referring to OCR.
One of the main open-source lib for this is: Tesseract
Some one has ported this lib for ios. You can get the code from: https://github.com/rcarlsen/Pocket-OCR/
you might get solution from following link:
Is there any iphone Class that converts images to text format?
If you just want to print the string
UIImage*img=[UIImage imageNamed:#"btn_reset.png"];
NSData *dataObj = UIImagePNGRepresentation(img);
NSString*str= [[NSString alloc] initWithData:dataObj encoding:NSASCIIStringEncoding];
NSLog("Image is %#",str);
If you still dont get it change the encoding
Related
I would like to convert audio data into NSString.
I have audio data and it is not bull. But when i convert audio into NSString that converting string is null. I am using following code.....
NSString *audioStr = [[NSString alloc] initWithData:audioData encoding:NSUTF8StringEncoding];
Where i am wrong i don't understand. Please help me any one.
If you are looking for 'Speech to Text' recognition, you can try
OpenEars
iSpeech
Also, if you just want to dictate to UITextField or UITextView, you can use the built-in option for speech-to-text.
I need to include an image in a vcard file. The image is supposed to be in binary format. I create the image data as follows:
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:#"Pic1"], 1.0);
I have unsuccessfully tried encoding using the following 2 methods:
vcardString = [vcardString stringByAppendingFormat:#"PHOTO;ENCODING=b;TYPE=JPEG:%#\n", [imageData base64EncodedString]];
AND
vcardString = [vcardString stringByAppendingFormat:#"PHOTO;ENCODING=b;TYPE=JPEG:%#\n", [imageData description]];
Any advice on how to get the image data properly encoded to binary would be appreciated. Thanks
According to this blog entry I found (which points to this spec), it looks like the second form of what you're trying to do should work.
Change your ENCODING=b to ENCODING=BASE64 and see if that makes the difference.
OS X v10.11 and iOS 9 introduces CNContactVCardSerialization which greatly simplifies embedding images in a VCard.
I'm a young iPhone developer and I'm trying to write an iPhone app that syncs data from a server side app on my mac, basically text data.
I'm having trouble reading data on the iPhone side with the following:
`
(void)connectionReceived:(NSNotification *)aNotification {
NSFileHandle *incomingConnection = [[aNotification userInfo] objectForKey:NSFileHandleNotificationFileHandleItem];
[[aNotification object] acceptConnectionInBackgroundAndNotify];
NSData *receivedData = [incomingConnection availableData];
NSString *theString = [[[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding] autorelease];
`
I need to print out theString to a text label on the iPhone, but what I get is the exact "hex code translation" of the text entered on the server side app and I don't seem to be able to convert it to char.
Can anyone help ?
I don't know the answer - but there are a few things to look at or try:
Did you try converting into something other than UTF8? (Unicode? ASCII?)
In the hex output it gives you - I assume it is giving a UTF8 representation - i.e. one 8-bit (two hex nibble) code for each character in your string. Is this the case? Are the hex codes "correct" for a UTF-8 or ASCII representation of your string?
Are there any "bad" codes in the result?
I am wondering if this is happening because there are characters (maybe even invisable ones - control characters - nulls, whatever) in your string which are making it so iOS can't do a "normal" UTF8 conversion...
I am using the base64 implementation at the bottom of this post.
If I use following code:
NSLog(#"decoded:%#",[[[NSString alloc] initWithData:[Base64 decode:#"8fEmIzEyNDA3OyYjMTI0MTE7"] encoding:NSUTF8StringEncoding] autorelease]);
I get decoded:(null)
However, if I use:
NSLog(#"decoded 1:%#",[[[NSString alloc] initWithData:[Base64 decode:#"8fEmIzEyNDA3OyYjMTI0MTE7"] encoding:NSASCIIStringEncoding] autorelease]);
I get decoded:ññぷほ
But I should get decoded:ññぷほ
What am I doing wrong?
Those are HTML character references. You'll need to decode further if you want raw text.
You should read this article by Matt Gallagher. At the bottom there is link with code for iOS if that is what you are after.
It provides an class extension to NSData which is you string is easily converted from and too.
I am aware this question has been asked several times, but I was unable to find a definate answer that would best fit my situation.
I want the ability to have the user select an image from the library, and then that image is converted to an NSData type. I then have a requirement to call a .NET C# webservice via a HTTP get so ideally I need the resulting string to be UTF8 encoded.
This is what I have so far:
NSData *dataObj = UIImageJPEGRepresentation(selectedImage, 1.0);
[picker dismissModalViewControllerAnimated:YES];
NSString *content = [[NSString alloc] initWithData:dataObj encoding:NSUTF8StringEncoding];
NSLog(#"%#", content);
The NSLog statement simply produces output as:
2009-11-29 14:13:33.937 TestUpload2[5735:207] (null)
Obviously this isnt what I hoped to achieve, so any help would be great.
Kind Regards
You can't create a UTF-8 encoded string out of just any arbitrary binary data - the data needs to actually be UTF-8 encoded, and the data for your JPEG image obviously is not. Your binary data doesn't represent a string, so you can't directly create a string from it - -[NSString initWithData:encoding:] fails appropriately in your case.
Assuming you're using NSURLConnection (although a similar statement should be true for other methods), you'll construct your NSMutableURLRequest and use -setHTTPBody: which you need to pass an NSData object to. I don't understand why you would be using a GET method here since it sounds like you're going to be uploading this image data to your web service - you should be using POST.