OCR ?

Discussion and feedback on Construct 2

Post » Sat Sep 05, 2015 7:46 pm

Hello,

Does anyone know is OCR possible in C2?
eg. jpg or pdf with some text to be read and transfered into variable or via json etc.

tnx!
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Sat Sep 05, 2015 9:24 pm

it can if you can write your own extensions... but that's beyond me. I'm sure there's been something similar on the forums before.

R
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Sat Sep 05, 2015 9:41 pm

well im searching forums for OCR but theres nothing usefull to find :(

found online some stuff:
http://articles.qiguang.net/2012/04/13/ ... avascript/
http://antimatter15.com/ocrad.js/demo.html
http://stackoverflow.com/questions/2695 ... ml5-canvas

but how to make a plugin out of it is beyond me... :(
Last edited by irina on Sat Sep 05, 2015 9:45 pm, edited 3 times in total.
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Sat Sep 05, 2015 9:42 pm

i read that teserract is the best but its not JS based... can outside program be somehow connected to C2?
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Sat Sep 05, 2015 10:02 pm

B
15
S
5
Posts: 40
Reputation: 1,221

Post » Sun Sep 06, 2015 7:02 am

@nonom
...and what to do with that?
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Mon Sep 07, 2015 8:03 am

can anyone point me what needs to be done in order to run this example in browser element: execute js?
http://stackoverflow.com/questions/2695 ... ml5-canvas

thanx!
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Mon Sep 07, 2015 5:39 pm

@irina
First you need to load that js library. You can do that by running this js at the start of the layout:
Code: Select all
"var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://antimatter15.com/ocrad.js/ocrad.js';
script.onreadystatechange = script.onload = function(){console.log('occad.js loaded');};
head.appendChild(script);"


It can take time to load, so you shouldn't try using it right away. You can tweak it so you're signaled when it's done loading but it makes things more complicated, so for now you can wait a second or so before trying to use it.

The one function used in that link is OCRAD(c), where "c" is an html5 canvas. The only readily available one would be the game canvas which can be gotten with document.getElementById('c2canvas').

In my test I did this to get the result:

time=1 seconds:
--- set text to Browser.ExecJS("OCRAD(document.getElementById('c2canvas'))")
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Tue Sep 08, 2015 2:23 pm

@R0J0hound

i have some error in NW.js (ocrad.js line 66 col 3)
i browser theres no error but i just can't get this to work... what am i doing wrong!?

https://dl.dropboxusercontent.com/u/169390986/PUB/OCR.capx

thanx!!!
B
31
S
13
G
2
Posts: 752
Reputation: 5,541

Post » Tue Sep 08, 2015 5:15 pm

Just a side note you can safely remove the second execute javascript action, it does nothing.

I have no solution for that nw.js issue. It's not anything we're doing wrong, it's probably just a problem with the library.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests