Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] How to Get data / string / text from picture

Author
Message
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 20th Jul 2021 11:26 Edited at: 20th Jul 2021 11:31
Hello everyone .
Suppose I load a picture and their something written maybe " INDIA " , How to get this and take in some variable .
Thankyou

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 20th Jul 2021 13:21
Lol, not in Basic, your going to need some kind of reinforcement learning AI for that, I think OpenAI has some kid of image processor thing.
Loktofeit
AGK Developer
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 20th Jul 2021 13:28
This post has been marked by the post author as the answer.
Your choices:
- write a character recognition routine(good luck with that)
- use an SDK (ex: Aquaforest)
- use middleware (lots out there)
- tap into a cloud service (ex:Huawei Cloud OCR SDK)

There's also Google Drive, but I don't know how you'd swing this with AGK.

Link: https://support.google.com/drive/answer/176692



LynxJSA's web games/quizzes - LynxJSA's Android apps
AGK Resource Directory
"Stick to a single main loop (DO...LOOP) and loop through it every frame.
Do everything inside functions.
Use finite state machines to control your game.
Use lots and lots of source files.
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 20th Jul 2021 14:10
Thankyou to all
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 20th Jul 2021 14:59
Quote: "- write a character recognition routine(good luck with that)"

YES!

This really gets the juices flowing.

Facial recognition with a twist, but definitely huge potential for same groups using the facial.

Pixel color calculations, so something with multicolored letters (especially more than 2 colors) would be your wrench in the cogs (for those wanting protection from said tech) on that one.

Solid letters of one color contrasting from the background shouldn't be too bad though to develop since the cropping of each letter could be done as long as the letters are not toughing.

Otherwise, when touching, even the solid letters would create the need for more elaborate routines.

Tracing the outlines to establish routes of the turns made may be able to find matching paths to basic letters to handle more than one font, so vector calculations, but yeah.... "good luck with that".

I won't be much help on this one.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Jul 2021 02:36
OCR (Optical Character Recognition) isn't overtly difficult.
All you need to do is convert the image into a Binary Image... this way you get the Silhouette., you can then take Sample Blocks then check against a Vectorised Pattern for each Letter / Glyph; essentially this end up being a "Likelihood" Routine; i.e. you're checking to see how much of the Silhouette has a similar shape... so you're dividing the pixel count against 100 to get the Percentage per Pixel; then adding that value for each matched Pixel Vs. Vector Pixel.
Once you get say a 90% Match (you can fine tune this) you can then confidently say the Image Sample is that Letter / Glyph; and from that reconstruct the word as an ASCII String.

It's involved and time consuming., but simple and what's more EVERY OS since '97 has had such a feature as a "Core" element., with Modern OCR actually being somewhat more advanced.
The trick is of course deciding on the Sample Block Sizes... but of course in general Terms a Language will be formed from letters with a (relatively) Uniform Ratio.
For English this is approx. 1:2

So let's say we have a Silhouette that's 48px High., chances are you can sample 24 x 48 and acquire all (or most) of a given letter if it's English., or other Latin based languages.
Bored of the Rings
User Banned
Posted: 21st Jul 2021 07:42 Edited at: 21st Jul 2021 07:48
this is something I am doing at the moment.

Basics:

RGB -> GS = (Red value / 3) + (Green value / 3) + (Blue value / 3)

Decide a threshold and any value under the threshold = white, and any above the threshold = black, voila a binary image. invert using NOT operation. Then use erosion/dilution operations to remove the noise etc.
e.g. 2 x 1 pixel to determine which are white/black pixels.

good luck, I will post my code once it's completed and works well.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 21st Jul 2021 19:38
Thank-you to all .
Bored of the Rings
User Banned
Posted: 22nd Jul 2021 20:55 Edited at: 22nd Jul 2021 20:59
no problem, here's the binary file output (attached). I haven't removed the "noise" yet, but you can make out the lettering and the threshold calculation has been applied, will add code at a later date.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Loktofeit
AGK Developer
15
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 22nd Jul 2021 21:58
That's pretty epic, Bored.
LynxJSA's web games/quizzes - LynxJSA's Android apps
AGK Resource Directory
"Stick to a single main loop (DO...LOOP) and loop through it every frame.
Do everything inside functions.
Use finite state machines to control your game.
Use lots and lots of source files.
Bored of the Rings
User Banned
Posted: 23rd Jul 2021 12:01 Edited at: 23rd Jul 2021 12:03
Here is the AppGameKit draft (very draft) code and is subject to change. var names are long for easy to read/understand for any beginners out there. A lot to do when I get time. I've also played around with the ResizeImage command to save out binary image files in different sizes. Got an interesting result with GS image when setting bit depth to something like 16. As a data scientist in the clinical trial world, this is right up my alley a bit of stats programming type stuff to do yet.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 23rd Jul 2021 15:11 Edited at: 23rd Jul 2021 19:08
lol

That is really cool doing the contrasts as 0's and 1's

Reminds me of the hidden messages in the bitcoin blockchain from the early blocks.

People are getting really fancy now and embedding photographs in the blockchain data.

Seems they do a minimum transaction to represent a line of data using a fake recipient hash to get hexed into something for Unicode conversion.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Bored of the Rings
User Banned
Posted: 24th Jul 2021 06:33
@Loktofeit: thanks for the comment, much appreciated
@Conjured: thanks for the comment and the interesting thing about bitcoin hidden images , I didn't know that. thanks for the link

Of course the next thing I am writing is the dilation/erosion pixel processing and finally will be the extraction of the text.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Jul 2021 11:21 Edited at: 24th Jul 2021 11:47
Ther is the Cloud Vision API that can do OCR: Cloud Vision API OCR

@Bored of the Rings: i guess it helps if the Dilation and Erosion happens on the GPU ...do you want a shader ?
Dilation Shader.zip
Also: nice ! and thanks for sharing

Attachments

Login to view attachments
Bored of the Rings
User Banned
Posted: 24th Jul 2021 13:34 Edited at: 24th Jul 2021 13:35
@janbo, thanks very much for the shader and OCR link it will help a lot. I had started programming dilution side a different way using a 3x3 grid system to process the pixels, I will definitely have a look at the shader, awesome.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
User Banned
Posted: 24th Jul 2021 16:25 Edited at: 24th Jul 2021 16:30
[eidt]
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 25th Jul 2021 03:26 Edited at: 25th Jul 2021 03:44
Quote: "@Conjured: thanks for the comment and the interesting thing about bitcoin hidden images , I didn't know that. thanks for the link"


Not trying to take this off topic, but while we are on Bitcoin, here is another interesting read.

Been doing more research into it, and cruised over here whilst waiting for the next block to be mined... 48 minutes into #692529 to come in... the ones before is were less than 10 minutes, some as quick as 1 minute.

Not sure why this one is taking so long, but I wish I was set up to mine, because I think basic pooling strategies could be used by individuals to help find the nonce faster for small batches... like two people doing odds and even, so first one starts at X and the other at X+1 with both of them stepping by two... so whether odd or even either one would find it faster than someone doing all or even half sequentially.

So, starting the X at a ridiculously high number would reduce the number of blocks you were successful on (most coming in under), but for the big ones, you should hit it fast.

Still crunching the data while I learn more to develop a real plan, but mining might still be possible if luck prevails with X.

58 minute into this proof of work for this block.... new transactions pending... but no new block.... what the heck man?

Just saw a transaction of over 157 coins.... cool 5 million + dollars... dang... reminds me of a forum guy here who bought $100 worth when it was less than $8.50 a coin.... lol ... he said he was keeping for the long haul... I wonder if he did. (his 12 coins +/- would be worth a small fortune today at the current price of about $34k ... $408,000 ... from a $100 bet.... awesomeness.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-04-20 07:26:36
Your offset time is: 2024-04-20 07:26:36