栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python实时采集摄像头图像传递到docker服务获取人脸特征代码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python实时采集摄像头图像传递到docker服务获取人脸特征代码

import os
import cv2
import time
from urllib3 import encode_multipart_formdata
import requests
def cam2frame(rtsp,outpath):
cap = cv2.VideoCapture(0)
frame_index = 0
frame_count = 2307
if cap.isOpened():
success = True
else:
success = False
print(“读取失败!”)

while (success):
    start = time.time()
    res, frame = cap.read()
    success, encoded_frame = cv2.imencode(".jpg", frame)
    # cv2.imshow('image', frame)
    # cv2.waitKey(1)
    data = {
        "filePath": "path/for/test"
    }
    header = {}
    data['fileName'] = ("fileName", encoded_frame.tobytes())
    encode_data = encode_multipart_formdata(data)
    data = encode_data[0]
    header['Content-Type'] = encode_data[1]
    result = requests.post("http://jxust-db:8888/facereg/faceFeature", headers=header, data=data)
    print(result.text)
    end = time.time()
    print("花费时间为%lf" % (end - start))
cap.release()  # 这行要缩一下、原博客会报错(全局变量与局部变量)

def main():
cam2frame(‘rtsp://admin:jxlgust123@172.26.138.54:554/Streaming/Channels/302?transportmode=unicast’, ‘F:pswsimg’)
if name == ‘main’:
main()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/701102.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号