简体   繁体   中英

parse variable from php to a c++ function as an argument

I have a web server which receives an image from a client and do some SIFT based image matching at the server (win32) end send the result back to the client.

Receiving image is done using apache and php. SIFT based processing functions are in C++. Now I want to parse the data in php variable $image (the variable which holds the received image) to the main function of C++ program as an argument.

Then I want to take the result back to php code. Result is the matching number of points (integer value)

  • save the image to a file. you may use file_put_contents...
  • use system('cpp_program "/path/to/image"') function to run the program.(or does it take image data as an argument? that would be strange). these functions return the console output of the run program.

that's what i would do:

$tmpFileName = tempnam();
file_put_contents($tmpFileName, $image);
$cppProgramResult = intval(trim(system('cpp_program "'.$tmpFileName.'"')));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM