I'm using tesseract on iOS to extract a word from an image.
The Image contains a single word only.
Now I'm trying to detect a word from a paragraph by simply tapping a word in the image and this word will get highlighted and extracted by tesseract.
The Question is:
How can i detect, highlight and extract the word from a paragraph when the user taps on it?
Related
Can I put a UIButton or UITextField or UITextView between the texts in Swift
examples:
"What is your **[UITextField]** about downloading free music files from the Internet?**[UIButton]**"
"What is your
**[UITextField]** about
downloading free
music files from the
Internet?**[UIButton]**"
Like "example2", the layout may change depending on the situation.
Not a particularly easy task. You can use attributed text to stylize a word and make it "tappable" (like a hyperlink on a webpage), but that wouldn't solve the issue of embedding an editable text field in the string.
One approach would be to embed "placeholder" text in your string, then find the bounding box for that word and overlay a textfield or button. You'd have to be sure to account for things like word wrap, and it would take some experimentation to get the widths right.
So, you might set the text of your label to:
What is your UITextFieldGoesHere about downloading free music files from the Internet? UIButtonHere
Then use code to find the bounding box / rect of UITextFieldGoesHere and position a text field on top of that, so it covers the word and looks like it is inline. Same thing with the UIButtonHere.
If your button might be simply OK, and you don't want it wide with left-right padding, change that placeholder in your string to something like OKB ... just make sure it is unique so you can find it.
Lots of examples out there for finding the bounding box / rect of a word in a label... use Google (or your favorite search engine) to search for:
uilabel find bounding box of specific word
I have many pictures like this and i want to segment each character alone by using any matching technique.
So I manually segmented a letter of this word , and i used a simple image difference of this image with slide in the original image of the same size.
This didn't work for all the words due to the variation of the character in the word itself as sometimes the window of the original image includes other characters.
So what's the optimum technique to match or to get the characters of the original image ?
There is a video on how to rotate an object around a point but I fail to select the text.
I wanted to do the same thing and saw your question before figuring this out.
1. The "Geogebra Way"
In the Algebra Perspective enter the following RotateText commands in the Input box at the bottom:
RotateText["Rotated text using degrees.", 45°]
RotateText["Rotated text using radians.", 0.785398]
In the Construction Protocol view, this is represented by
"rotatebox{45}{ \text{Rotated text using degrees.} }"
"rotatebox{44.9999999}{ \text{Rotated text using radians.} }"
Note that the radian form of the RotateText command is converted to degrees in the construction step. So this creates an graphical object that renders the text in a LaTeX "rotatebox". It's rather strange that the system doesn't have a tool to create rotateable text.
You can attach the text to an object via the object's Properties->Position->Starting Point. Only certain types of objects can be used, and the text can only be placed/moved underneath the object, which is odd. You can get around this by creating a line segment, attaching the rotateable text object to a desired end-point on the line segment above the location you want the final text, and then hiding the line segment.
2. A better, "undocumented" Geogebra method!
One can actually use LaTeX in captions of objects. Here's how you would enter the text:
$\rotatebox{45}{ \text{Rotated text using standard text box!} }$
A nice thing about this is the caption can be easily placed above the object. Notice that LaTeX commands are surrounded by the dollar sign. Also notice that there is a backslash as part of the \rotatebox command.
Also, one can use the standard text tool to do the same thing. This has the advantage that the text can be dynamic! Create some text anywhere. Then edit it's properties on the Text tab. Check the LaTeX checkbox, and enter the following for the text:
$\rotatebox{45}{ \text{} }$
Then inside the \text{} brackets, select an object. The text will be updated with the object's value. Or a combined form:
$\rotatebox{45}{ \text{"The value is:" + SliderObject} }$
I've tried to put an object in the "degreees" field, but could not get that to work.
Use the RotateText command like this:
RotateText("What ever text you want", angle)
I am using Tesseract for text recognition.
How can I simply recognize padding between text and create e.g. pdf or .doc file with the same padding?
Let's say that the source page contains 3 columns with some text (like a news paper). How can I recognize this text with appropriate padding and margin to each other and to page?
Maybe you can suggest example or library that does the same or just algorithm?
I want to draw highlighted parts of text, but I haven't any ideas, how can I do it.
Result, which I want:
Caption on image is one attributed string, where I'm finding hashtags and drawing it in blue color. Nickname in header - one simple NSString. I want to show rects, and text, which user wants to find. Have you any ideas, how I can find CGRects for NSRanges in my drawn string?
PS: I want to detect coordinate of last character for other image works.