简体   繁体   中英

Can't execute c++ opencv function from PHP

I want to make my c++ program run within PHP. In program below I want to make sure first that the program can be executed

#include <iostream>
#include "opencv/cv.h"
#include "opencv/highgui.h"

using namespace cv;

int main(int argc, char *argv[])
{
Mat  imgOk = imread("C:/xampp/htdocs/coba2/src.jpg", 1);
imwrite("res.jpg", imgOk);
printf("hello");
return 0;
}

I call it from

<?php
exec('bin\\Debug\\co.exe', $output);

print_r(array_values($output));

?>

And the result on the webpage was only

Array ( )

And the image wasn't saved

I have also tried passthru() , system() , shell_exec() but none of those work

when I try

 #include <iostream>
 #include "opencv/cv.h"
 #include "opencv/highgui.h"

using namespace cv;

int main(int argc, char *argv[])
{
printf("hello");
return 0;
}

it works fine

Array ([0]=> hello )

Any solutions?

Maybe copy the OpenCV DLLs to your bin\\Debug directory? You can find them in the OpenCV install directory.

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