【发布时间】:2019-08-23 03:05:28
【问题描述】:
我有一个 nodeJS 应用程序,我需要运行一个 python 脚本才能获得特定的响应。我正在使用 python-shell 来做到这一点,但我没有得到任何回应。
我也尝试过使用子进程,同样的响应。
这里我调用python脚本:
var ps = require('python-shell');
ps.PythonShell.run('./face_detect.py', array1, function (err, data) {
if (err) req.send(err);
req.send(data.toString())
});
这是我的 python 脚本的 sn-p:
import cv2
import sys
import os
import numpy as np
students = sys.argv[1]
# get the names and put them in an array ---> subjects
imagePath = "class/welcome.jpg"
cascPath = "haarcascade_frontalface_alt.xml"
faceCascade = cv2.CascadeClassifier(cascPath)
.....
for (x, y, w, h) in faces:
num = 0
crop_img = cv2.UMat(image[y-40:y+h+100,x-40:x+h+40])
cv2.imwrite("face" + str(num) + ".jpg", crop_img)
test_img = cv2.imread("face" + str(num) + ".jpg")
num = num + 1
predicted_img1 = predict(test_img)
absences["A"] = 1
for name, a in absences.items():
if a == 0:
noshow.append(name)
print(noshow)
cv2.waitKey(0)
我希望它返回一个数组。 谁能帮我解决这个问题?
【问题讨论】:
-
cv2.waitkey(0)之前的最终打印结果是什么? -
这是一个字符串数组
-
您正在打印的数组
noshow是否有您要查找的数据? -
是的,我的问题是 nodejs 中的函数返回空
标签: javascript python node.js no-response