FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Integrating VC++ and PHP





bukaida
Hi
I have a program written in VC++. Is it possible to design any interface between them, like taking the input and displaying the output in php and the processing is done in the VC++ module? Please help. Do I need to convert the VC++ module to php?
hexkid
bukaida wrote:
I have a program written in VC++. Is it possible to design any interface between them, like taking the input and displaying the output in php and the processing is done in the VC++ module? Please help. Do I need to convert the VC++ module to php?


http://php.net/exec

Here's one way to do it
Code:
<?php
$input = 'abcdefgh';
$cmd = 'YOURVC++PROGRAM ' . escapeshellarg($input);

ob_start();
system($cmd, $retval);
$output = ob_get_contents();
ob_end_clean();

echo $output;
?>
bukaida
@Hexkid: Thanx man. Can I send an image like this? Actualy my OCR program is written in VC++ and The image is residing in anothe machine where the output is to be returned. Can I do it by the method mentioned by you? There is not much information about this in php manual.BTY I am using php4.4.0 with GD library support under apache 2.
hexkid
bukaida wrote:
@Hexkid: Thanx man. Can I send an image like this? Actualy my OCR program is written in VC++ and The image is residing in anothe machine where the output is to be returned. Can I do it by the method mentioned by you? There is not much information about this in php manual.BTY I am using php4.4.0 with GD library support under apache 2.


Well ... it depends. What are the inputs and outputs of your VC++ program?
Can you read and write to the other machine from your VC++ program?

Maybe this would work

YOURVC++PROGRAM --input=\\othermachine\path\to\image.tiff --output=\\othermachine\path\to\image.tiff.txt

and you'd use PHP to build the input and output parameters based on user input
bukaida
Quote:

Well ... it depends. What are the inputs and outputs of your VC++ program?
Can you read and write to the other machine from your VC++ program?



Nope man, I have to scan the image in the local computer and ocr it there itself. Thats why I am trying to build the application so that the scanning part will be at the client's end and ocr will be at the remote server.The result will be returned to the client.Help me please.
hexkid
bukaida wrote:
I have to scan the image in the local computer and ocr it there itself. Thats why I am trying to build the application so that the scanning part will be at the client's end and ocr will be at the remote server.The result will be returned to the client.Help me please.


Use PHP to transfer the file from the client to the server (see Handling file uploads in the PHP manual).
After the file is transferred (and validated) use your VC++ program to generate the text output.
When you have the text output, send it to the client.

Code:
// part 1
// deal with file upload
// ...
// part 2
// generate text from image
system('YOURVC++PROGRAM ' . $uploadedfilename . ' ' . $uploadedfilename . '.txt');
// ...
// part 3
// send the text to the client
echo '<pre>', htmlentities(file_get_contents($uploadedfilename . '.txt')), '</pre>';


Does YOURVC++PROGRAM work as expected on the server?


But, I think, the proper way to do what you want, is to do it all at the client side with no need to send files anywhere. The client scans the image and uses it with the OCR software that should be installed locally, on the client machine.
bukaida
The actual scenario is a bit complecated. The OCR software we are using requires huge amount of memory and processing power which a client machine cannot have.Moreover we want to provide it as a service rather than delivering the entire software to the client. It is a part of the e-Governance program, so they want to keep the main program with themselves.

BTW, does (YOURVC++PROGRAM ) means the exe file we are running?
I am trying to implement your suggessions. can inform you about the result and difficulties very shortly.
Many many Thanx in advance.
bukaida
@ hexkid: Man, it is not working. Sad The VC++ program takes three arguments, Name of the image, Layout and output filename. I put all of them with a blankspace between them(as we do in stand alone system in command line mode) but it failed to generate the output.The image however is coming to the server.
hexkid
bukaida wrote:
The VC++ program takes three arguments, Name of the image, Layout and output filename.

If you go to the server yourself and try the command using the server keyboard, does the statement created by PHP work?

Code:
C:\VC\bin> YOURVC++PROGRAM "D:\USERDATA\INPUTFILE.TIFF" simple "D:\GENERATEDDATA\OUTPUTFILE.TXT"


Does the above create the output file?
Does it report errors?
Does it run?
bukaida
No to all. The file which is coming to the server appears to be corrupted. Although the name, size and type are identical but after the lexican and layout analysis(manualy) the data appeared to be somehow garbled.
Related topics
http://tuvanonline.com/library/index.php
PHP-Nuke platium?
PHP Write to line
Anyone good with PHP-NUKE?
PHP safety?
req: PHP to list files in directory, and link to them
[php scripts ] phpweather&email
PHP Tutorials
PHP VS ASP
Need help integrating html code into php
Need Help integrating php variable into mySQL SELECT query
Flash, PHP and MySQL
PHP-SOAP enable
IN php what does the ON mean ->
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.