I compile my c++ file by this command:-
g++ main.cpp -o main pkg-config --cflags --libs opencv
This runs fine. Now when i run main file by command line using this command './main', it's runs fine, and stared my webcam.
But when i write code in php to execute this file by php code, It's also runs but my webcam does not found, And gives me an error. starting cam No webcam where found
I don't know what's the reason behind this. I am putting some piece of code of my files.
main.cpp
CvMemStorage *storage = cvCreateMemStorage(0);
CvHaarClassifierCascade *cascade = (CvHaarClassifierCascade*)cvLoad("data/haarcascade_frontalface_default.xml");
printf("starting cam\n");
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
if(capture == 0)
{
printf("No webcam where found");
return 1;
}
CvScalar red = CV_RGB(250,0,0);
// counters used for frame capture
int happy_count = 0;
int sad_count = 0;
printf("starting recognition\n");
output.php
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo shell_exec('./main');
Error on run php:- starting cam No webcam where found.
Note:-Works fine on terminal