Linked Questions

Popular Questions

I am trying to build a facial recognition web app. I run the image capture and processing code via python scripts, and call the python file from php.

The python code works when called via command line, but through php, the simply does not capture any frames, and the return value is always false. I do get the cam.isOpened() value to be true though, hence I know that my camera is turned on. It's just that it isn't reading any frames when called via php.

Also, the read() function returns true when I read the frames from a video file rather than the webcam.

Any help on figuring out why would be appreciated! Could it be related to xampp permissions or so? I'm running the xampp server on macOS.

Here's my code:

import cv2
import time

cam = cv2.VideoCapture(0) #initialize webcam
time.sleep(2) #to warm up camera sensor

retL = [] #to store the frame return values

i = 0
while i < 10:
    ret, frame = #read frames from webcam
    i += 1

print(retL) #returns a list filled with 'False' only when the script is called from php


      $a = shell_exec('/usr/local/bin/python3 2>&1');
      echo $a;

Related Questions