TensorFlow使用MySQl_tensorflow利用预训练模型进行目标检测(三):将检测结果存入mysql数据库...

该博客演示了如何使用TensorFlow的预训练模型进行目标检测,并将检测结果存入MySQL数据库。通过定义`detection_to_database`函数连接MySQL,根据帧编号检查检测状态,更新或插入数据。同时,加载模型数据并执行检测,使用`Detection`函数在图片上可视化检测结果,并调用`detection_to_database`将结果存储到数据库。
摘要由CSDN通过智能技术生成

#!usr/bin/python#-*- coding: utf-8 -*-

importnumpy as npimportmatplotlib

matplotlib.use('Agg')importmatplotlib.pyplotfrom matplotlib importpyplot as pltimportosimporttensorflow as tffrom PIL importImagefrom object_detection.utils importlabel_map_utilfrom object_detection.utils importvisualization_utils as vis_utilimportdatetime#关闭tensorflow警告

importtimeimportMySQLdbimportargparseimportsys

reload(sys)

sys.setdefaultencoding('utf8')

os.environ['TF_CPP_MIN_LOG_LEVEL']='3'detection_graph=tf.Graph()#将detection的结果存入mysql数据库

defdetection_to_database(object_name, frame_num):

conn=MySQLdb.connect(user='root',passwd='****',host='localhost',port=3306,db='rdshare',charset='utf8')

cursor=conn.cursor()#查询目标检测状态表,查看frame_num是否已经被检测过,若是,则更新,若否,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值