i am trying to execute a python script via a php script. both scripts running on my web host from the same folder. this first example works perfectly.
<?php
shell_exec("python main.py");
echo"success";
?>
import os
os.popen('cp uploads/1.jpg sessions/1.jpg')
here comes the problem, when i try to run a slightly more complex python script i get no results?
same php file
new python script
import cv2
import datetime
import pytz
tz_London = pytz.timezone('Europe/London')
datetime_London = datetime.datetime.now(tz_London)
name = datetime.date.today().strftime("%y-%m-%d-") + (datetime_London.strftime("%p"))
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt2.xml')
width = 295
height = 360
dim = (width, height)
filename = "sessions/%s_1.jpg" % name
img = cv2.imread('uploads/1.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.1, 4)
for (x, y, w, h) in faces:
cv2.rectangle(img, (x, y), (x +100 + w -100, y +100 + h -50), (0, 0, 255), 2)
faces = img[y:y +50 + h, x:x + w]
faces = cv2.resize(faces, dim)
cv2.imwrite(filename, faces)
print(name)
by the way, when i execute this python script via the terminal it works perfectly.
any help would be much appreciated