I want to use a USB webcam (in a small C++/OpenCV application) and call it from a PHP script. My test app looks like this:
int main( int argc, char **argv )
{
cv::VideoCapture C( 0 );
cout << "C.isOpened() = " << boolalpha << C.isOpened() << endl;
return 0;
}
The PHP script looks like this:
<?php
exec( escapeshellcmd( '/thepath/theapp' ), $output, $result );
var_dump( $output );
?>
When I call this app directly from the command line, it returns true.
When I call the app via php like this php -f /the_php_script.php
it returns true.
When I call the app via php called by AJAX from a html file (with a button), it passes through Apache and then returns false.
So, my app works fine. My php script works fine too. But there is a permission or something like this that prevents php, via Apache to access the webcam (to initialize it with OpenCV library), but the permission is sufficient to allow the app to run.
Could someone help me? Any idea?
Thanks!
EDIT 1:
Following a suggestion, I tried to used a php script to start my app without the use of AJAX. I obtained the same results, i.e. OpenCV cannot initialized the USB webcam on the server.