Python OSError:[WinError 10038]尝试对套接字以外的项目进行操作
我有一个问题,当执行这个代码时,我收到这个错误! 有人能帮我吗Python OSError:[WinError 10038]尝试对套接字以外的项目进行操作,python,sockets,unity3d,deep-learning,Python,Sockets,Unity3d,Deep Learning,我有一个问题,当执行这个代码时,我收到这个错误! 有人能帮我吗 import socket import time import cv2 import numpy as np from time import sleep from tensorflow.keras.preprocessing.image import img_to_array HOST = '127.0.0.1' # The server's hostname or IP address PORT = 13000
import socket
import time
import cv2
import numpy as np
from time import sleep
from tensorflow.keras.preprocessing.image import img_to_array
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 13000 # The port used by the server
conto = 0
face_classifier = cv2.CascadeClassifier('./Haarcascades/haarcascade_frontalface_default.xml')
def face_detector(img):
# Convert image to grayscale
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces = face_classifier.detectMultiScale(gray, 1.1, 5)
if faces is ():
return (0,0,0,0), np.zeros((48,48), np.uint8), img
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
roi_gray = gray[y:y+h, x:x+w]
try:
roi_gray = cv2.resize(roi_gray, (48, 48), interpolation = cv2.INTER_AREA)
except:
return (x,w,y,h), np.zeros((48,48), np.uint8), img
return (x,w,y,h), roi_gray, img
cap = cv2.VideoCapture(0)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
ret, frame = cap.read()
rect, face, image = face_detector(frame)
if np.sum([face]) != 0.0:
roi = face.astype("float") / 255.0
roi = img_to_array(roi)
roi = np.expand_dims(roi, axis=0)
# make a prediction on the ROI, then lookup the class
preds = classifier.predict(roi)[0]
label = class_labels[preds.argmax()]
label_position = (rect[0] + int((rect[1]/2)), rect[2] + 25)
cv2.putText(image, label, label_position , cv2.FONT_HERSHEY_SIMPLEX,2, (0,255,0), 3)
s.sendall(b, label +' &')
time.sleep(3)
else:
cv2.putText(image, "No Face Found", (20, 60) , cv2.FONT_HERSHEY_SIMPLEX,2, (0,255,0), 3)
s.sendall(b'noFace &')
time.sleep(3)
cv2.imshow('All', image)
if cv2.waitKey(1) == 13: #13 is the Enter Key
break
s.shutdown(socket.SHUT_RDWR)
s.close()
cap.release()
cv2.destroyAllWindows()
错误:
OSError回溯(最近一次调用上次)
在里面
53.其他:
54 cv2.putText(图像,“找不到人脸”(20,60),cv2.FONT_HERSHEY_SIMPLEX,2,(0255,0),3)
--->55 s.sendall(b'noFace&')
56次。睡眠(3)
57
OSError:[WinError 10038]尝试在套接字以外的项目上操作看起来更像是一个一般的python和网络问题,与Unity3d或深度学习没有直接关系…@derHugo啊,好的,很抱歉标记(?),你能帮我吗?