Actually IOS has a pretty strong sandBox thus if you want to save some images you should do it in some allowed directory. In this example is the Document directory that is used:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; Then in order to retrieve the path of the image (if you don't save it) you need to do: NSString* filePath = [[NSBundle mainBundle] pathForResource:@“your_file_name" ofType:@“jpg”]; I managed to save and retrieve images successfully using this technique. Cheers, Oliver Nicolini > On 01 Dec 2014, at 15:41, Rafael Ruiz Muñoz <[email protected]> wrote: > > I'm trying to develop a X-platform tool with Tesseract, but I'm having > problems. > > My Tesseract's API works fine, for example, the next code compiled in C++ > does work: > > tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI(); > putenv("TESSDATA_PREFIX=/Users/rafaelruizmunoz/Desktop"); > api->Init(NULL, "eng"); > api->SetPageSegMode(tesseract::PSM_SINGLE_LINE); > api->SetVariable("tessedit_char_whitelist", "0123456789/"); > Pix *image = > pixRead("/Users/rafaelruizmunoz/Desktop/6a00d8341bfb1653ef0192acb84130970d.jpg"); > api->SetImage(image); > so, no problem. > > Now, I try to implement it for iPhone. From the iPhone I'm passing the path > where I'm going to store images to then load them with Tesseract (I can't > pass them from Mat to PIX): > > string nameFile = "/tempTime" + to_string(i) + to_string(j) + ".jpg"; > string cPathString = folder + nameFile; > const char* cPath = cPathString.c_str(); > > filenameVector.push_back(cPath); > imwrite(cPath, date); > The image is saved sucessfully (imwrite = 1). > > But then when I load it as: > > tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();; > api->Init(resourcePath.c_str(), "eng"); > api->SetPageSegMode(tesseract::PSM_SINGLE_LINE); > api->SetVariable("tessedit_char_whitelist", "0123456789/"); > Pix *image = pixRead(filenameVector.at(i).c_str()); > the image is NULL, and the errors are: > > Error in pixReadStreamJpeg: function not present > > Error in pixReadStream: jpeg: no pix returned > > Error in pixRead: pix not read > > Error in pixGetDimensions: pix not defined > > Error in pixGetColormap: pix not defined > > Error in pixClone: pixs not defined > > Error in pixGetDepth: pix not defined > > Error in pixGetWpl: pix not defined > > Error in pixGetYRes: pix not defined > > Please call SetImage before attempting recognition. > > I'm pretty sure that the file still exists, because if I do: > > Mat matInserted = imread(filenameVector.at(i).c_str()); > the matInserted is my image (seen it from debug). > > What is going wrong? Thanks. > > > -- > You received this message because you are subscribed to the Google Groups > "tesseract-ocr" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/tesseract-ocr > <http://groups.google.com/group/tesseract-ocr>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/tesseract-ocr/6ddb3ed9-d91d-4daf-801e-1397b944ccee%40googlegroups.com > > <https://groups.google.com/d/msgid/tesseract-ocr/6ddb3ed9-d91d-4daf-801e-1397b944ccee%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "tesseract-ocr" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tesseract-ocr. To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/DBA577E1-B2A8-4D15-8F6E-0187EC6814F0%40gmail.com. For more options, visit https://groups.google.com/d/optout.

