This week, I implemented two ways to store the output text.

The first way is that output text will be recorded and saved as a text file. I implement the method saveTextFile(const QString& filePath, const QString& text) of Ocr Tesseract Engine; this function uses QTextStream’s streaming operators, so we can conveniently write and update text into the file. The text file is located with the same path as the Url image.

figure1

The second way is to save the text in XMP. I implement the method saveXMP(const QString& filePath, const QString& text) to do this task. XMP uses a structured container to host similar metadata. An alternative language string is an entry in the XMP tree (based on XML) which will be an additional property for a title or caption tag. A new language version of a label is appended to XML. There is no limit in size and char encoding. XMP is hosted in the image to a dedicated chunk outside the image data/properties.

figure1

This is precisely where digiKam stores the comment entered by the user in the right sidebar named Captions & Tags from the icon view. The advantage of seeing this place is the capability to set more than one text in different languages if the translation is available. In all cases, the default language must be x-default; variant will be hosted in de-DE for German, fr-FR from French, it-IT for Italian, etc. Furthermore, translating and storing recognized text in the new language is an attractive feature too. My mentor prepared the class QOnlineTranslator to be included in digiKam core. Here an example, translating recognize text from English into French

figure1

These two methods are also encapsulated in slotUpdateText(), a function that is called in response to a particular signal “clicked” on a button “Save” after post-processing text in the text editor.

Main commits