Friday, 9 August 2013

How can i save the content of a file .txt into a NSString

How can i save the content of a file .txt into a NSString

I am working in an app and i found one problem. This is my loop, which
take take images and files of text at the same time. Apply Tesseract to
the images and compare the resulting text with the text of the files.
1.jpg with 1.txt 2.jpg with 2.txt . . .
This is my code
- (IBAction)entrenamiento
{
for(int i=1;i<=36;i++){
//Charge image from Resource
NSMutableString *a = [NSMutableString stringWithFormat:@"%i", i];
[a appendString:@".jpg"];
//Charge txt from Resource
NSMutableString *b = [NSMutableString stringWithFormat:@"%i", i];
[b appendString:@".txt"];
//Call Tesseract
Tesseract *tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata"
language:@"spa"];
[tesseract setImage:[UIImage imageNamed:a]];
[tesseract recognize];
//Assing b to a Nsstring
NSString *cadena1 = b;
NSLog(@"The text is:%@", cadena1);
//OCR result to a NSstring
NSString *cadena2 = [tesseract recognizedText];
NSLog(@"Text OCR:%@", cadena2);
The problem is that i don't know how save the content of the files txt
into NSString. In console with ---> NSLog(@"Cadena de archivo de
texto:%@", cadena1); Cadena de archivo de texto: %i.text
Best regards

No comments:

Post a Comment