#!/usr/bin/env python
# coding: utf-8
import socket
import cv2
# from matplotlib import pyplot as plt
# import matplotlib
import time
import threading
server = socket.socket()
server.bind(('0.0.0.0',8100))
print('0.0.0.0:8100')
server.listen(10)
def Server(connection,address):
try:
connection.settimeout(30)
buf = connection.recv(1024)
buf = buf.splitlines()[-1]
cap = cv2.VideoCapture(0)
ret,frame =cap.read()
if(not ret or frame is None):
cap.release()
time.sleep(2)
cap = cv2.VideoCapture(0)
ret,frame =cap.read()
if(not ret or frame is None):
cap.release()
time.sleep(2)
cap = cv2.VideoCapture(0)
ret,frame =cap.read()
if(not ret or frame is None):
cap.release()
connection.send(b"HTTP/1.1 202 OK\r\n\r\nerrer")
connection.close()
if(ret and not frame is None):
# frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
frame = cv2.putText(frame,buf.decode(),(10,30),cv2.FONT_HERSHEY_SIMPLEX,1.0,(50,50,50),5,cv2.LINE_AA,False)
frame = cv2.putText(frame,buf.decode(),(10,30),cv2.FONT_HERSHEY_SIMPLEX,1.0,(255,255,255),2,cv2.LINE_AA,False)
cv2.imwrite('image/'+buf.decode()+'.jpg',frame)
cap.release()
# plt.imshow(frame)
frame = cv2.imread('image/'+buf.decode()+'.jpg')
if not frame is None:
connection.send(b"HTTP/1.1 200 OK\r\n\r\nok")
connection.close()
else:
connection.send(b"HTTP/1.1 202 OK\r\n\r\nerrer")
connection.close()
else :
cap.release()
connection.send(b"HTTP/1.1 202 OK\r\n\r\nerrer")
connection.close()
except Exception as e :
connection.send(b"HTTP/1.1 202 OK\r\n\r\ntime out")
connection.close()
while True:
connection,address = server.accept()
thread = threading.Thread(target=Server, args=(connection,address))
thread.start()
connection.close()
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7288
最新资源
- 基于python实现的大麦抢票脚本
- 基于深度学习的声学回声消除基线代码Python实现+文档说明(高分项目)
- 俄罗斯方块c语言课程设计(PDF文档)
- 技术资料分享Zigbee协议栈OSAL层API函数(译)非常好的技术资料.zip
- vgg模型-基于深度学习AI算法对家用电器识别-不含数据集图片-含逐行注释和说明文档.zip
- 树莓派可用的国内源分享(项目汇总)
- vgg模型-基于卷积神经网络识别陶瓷制品表面缺陷-不含数据集图片-含逐行注释和说明文档.zip
- Centos7 el7.x86-64官方离线安装包.bind-utils.zip
- vgg模型-CNN图像分类识别光线强度-不含数据集图片-含逐行注释和说明文档.zip
- 基于 Python实现多模态语音和文本结合的情感识别(大模型finetune)高分项目代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈