php expert needed here!! (pHpOCR)

Status
Not open for further replies.

albertlee

Baseband Member
Messages
27
I have found this php program especially interesting for academic purpose.

This program is called pHpOCR. Its function is Optical Character Recognition.

Website: http://phpocr.sourceforge.net/
Here you can know what I refer imidiately.

You can view the screenshot: http://phpocr.sourceforge.net/screen1.jpg


It is composed of 2 main php files:

1. index.php
actual code: http://supershare.trap17.net/index.txt

it can generate template for a new font type.
It recognises the input image and parse the corresponding number to the output.


2, char_inc_6.php
actual code: http://supershare.trap17.net/char_inc_6.txt

it is basically the template




The question is: Since I am not very familar with pHp, I do have some difficulties reading the code regarding its syntax. I would like to make the same thing in Java. I can read partially the code, but it's just too long. Can any tell me which part of the code, especially in the index.php, that scruntinizes the image input with the template and chooses the character for the parsed output?

I want to know that bit of the code, because I want to change it a little so the index.php can also evaluate alphabets beside numbers....

sample of the program:
http://supershare.trap17.net/index.php
here, I implemented the program on my hosting. However, I change the code a little bit, so it's abit buggy.


please help here.,

apreciate for any one taking interests here and help
 
first of all, php is pretty easy to learn, and i'm no great expert, but here's my understanding of the code.

First, make sure you understand that all PHP variables being with $. For example a variable with the name "monkey" would be "$monkey", not simply "monkey".

Everything above "MAIN" seems to be all the functions to manipulate the image. Right below "MAIN" are configuration array variables. This should be straightfoward up until now.

now, in this line:
PHP:
$out=isset($_REQUEST['out'])?$_REQUEST['out']:$conf['default_output_format'];
The isset() function returns true if the variable is set. What we're checking here is if the variable named 'out' is set. 'out' is part of an array, namely $_REQUEST[]. This variable was past to the file through the HTML FORM after the user clicked the "Parse" button. Whenever HTML forms are sent, data is sent to the php file in arrays. The creator of this script chose to use the array $_REQUEST, but you can also use $_GET or $_POST. (If you scroll down to the bottom of the script, you can see that there are <input> HTML tags with names such as "out" or "filename")

The same reasoning applies to $filename.

Below all this, the image parsing functions are called, and then the correct display function is called (based on what the user put in the selection box).

At the beginning of the print_output_html() function, we see:
PHP:
$ret = '';
$ret.='<html>';
$ret.='<body>';
$ret.='<center>';
I'm not sure how java concatenates strings, but PHP concatenates by using the "." (period). The rest of the page is simply more outputing functions.

I didn't look at all the image parsing functions, but in the "MAIN" section, the first image parsing function called is not surprisingly: parse_image()

Hopes that helps. I might try to look at the image parsing functions later, but no guarantees :)
 
Status
Not open for further replies.
Back
Top Bottom