首页 > 其他分享 >tcc_pn_recognize_fail.py

tcc_pn_recognize_fail.py

时间:2023-10-06 22:23:01浏览次数:38  
标签:tmp 卡口 recognize py list fail import pn id

 

 

#!/usr/bin/python3
import os
import sys
import re
import pymysql
import time
import logging
import pandas as pd
import requests
from clickhouse_driver import Client
from pathlib import Path
"""
    统计佛山市停车场的所有卡口的过车总数
"""
if __name__ == '__main__':
    logging.basicConfig(filename=os.path.dirname(os.path.abspath(__file__)) + "/pn_recognize_fail.log",level=logging.DEBUG)
    try:
        cursor = Client(host='68.109.211.36', port=9001, password='Yisa_fs_2021')
    except:
        logging.info("lighting连接失败!")
        sys.exit(1)
    ct = "2022-07-14"
    sql = "select license_plate2,xgbdp,ambdp,viid_object_id,location_id,capture_time,image_url1,location_id  from yisa_oe.vehicle_all where (license_plate2 like '粤Z%澳' or license_plate2 LIKE '粤Z%港') and date = '{}'".format(ct)
    try:
        results = cursor.execute(sql)
    except:
        logging.error("lighting语句执行错误!")
        sys.exit(1)
    try:
        mysql_db = pymysql.connect(host='68.109.211.67',user='yisa_oe',password='Yisa_fs_2021',database='yisa_oe')
    except:
        logging.info("mysql连接失败!")
        sys.exit(1)
    #pn_list = [] # 元素是列表,0:卡口名称,1:卡口id,2:香港内地牌,3:香港本地牌,4:澳门内地牌,5:澳门本地牌,6:香港识别率,7:澳门识别率
    pn_list = [] # 元素是列表,0:卡口名称,1:卡口id,2:过车总数
    for row in results:
        row_list = list(row)
        #tmp_list = ['','',0,0,0,0,0,0,0]
        tmp_list = ['','',1]
        localtion_id = int(row_list[7])
        cursor = mysql_db.cursor()
        try:
            sql = "select  pointname,PROVIDER,location_type from location where id = {};".format(localtion_id)
        except:
            logging.error("mysql语句执行错误!")
            sys.exit(1)
        print(sql)
        cursor.execute(sql)
        result = cursor.fetchall()
        if result and int(result[0][2]) == 5:
            pn = result[0][0]
            tmp_list[0] = pn
            tmp_list[1] = result[0][1]
        else:
            continue
        if pn_list:
            flag = 0
            for i in range(len(pn_list)):
                if tmp_list[0] in pn_list[i]:
                    pn_list[i][2] = tmp_list[2] + pn_list[i][2]
                    flag = 1
            if flag == 0: #pn_list没有这个卡口
                pn_list.append(tmp_list)
        else:
            pn_list.append(tmp_list)
    sort_pn_list = sorted(pn_list,key=(lambda x:x[2]),reverse=True)
    df = pd.DataFrame(sort_pn_list,columns=['卡口名称','卡口ID','过车总数'])
    df.to_csv('tcc_pn_recognize_fail_0719.csv',index=False)
    print(df.head())

 

标签:tmp,卡口,recognize,py,list,fail,import,pn,id
From: https://www.cnblogs.com/lfxx/p/17745197.html

相关文章

  • pn_recognize_fail_SJKK_4.py
      #!/usr/bin/python3importos,statimportsysimportreimportpymysqlimporttimefromdatetimeimporttimedeltafromdatetimeimportdatetimeimportloggingimportpandasaspdimportrequestsfromclickhouse_driverimportClientfrompathlibimport......
  • Python 元组完全指南1
    元组用于在单个变量中存储多个项目。mytuple=("apple","banana","cherry")元组是Python中的4种内置数据类型之一,用于存储数据集合,另外还有列表、集合和字典,它们都具有不同的特性和用途。元组是有序且不可更改的集合。元组使用圆括号表示。示例,创建一个元组:thistuple=......
  • area_recognize_fail.py
      #!/usr/bin/python3importosimportsysimportreimportpymysqlimporttimeimportloggingimportpandasaspdimportrequestsfromclickhouse_driverimportClientif__name__=='__main__':logging.basicConfig(filename=os.path.dirname......
  • count_ga_5.py
      #!/usr/bin/python3'''作用:统计港澳车的识别率,分别输出港牌和澳牌识别失败的港澳车的二次识别车牌、筛选过的时间和图片url的csv文件'''importosimportsysimportreimportpymysqlimporttimeimportdatetimeimportloggingimportpandasaspdimportre......
  • post_image.py
    说明:在特定的目录中通过文件名通配符筛选出图片,向某个接口发送post请求传输图片识别图片,并判断post请求返回的结果 #!/usr/bin/python#-*-coding:utf-8-*-importos,sys,glob#importtqdmimportmultiprocessing#importreimporttimeimportthreadingimportreq......
  • 笨办法学Python3 习题24 更多的练习
    根据书中的PowerShell运行结果,进行仿写 beans,jars,crates=secret_formula(start_point)#函数运算结果存储方式一print(f"We'dhave{beans}beans,{jars}jars,and{crates}crates.") formula=secret_formula(start_point)        #两种函数运......
  • python单例模式
    Python单例模式的好处主要有以下几点:节省资源:单例模式可以确保一个类只有一个实例,这样可以避免在多个地方创建相同的对象,从而节省内存和计算资源。保证数据一致性:在多线程环境下,单例模式可以确保全局变量只被初始化一次,避免了多线程同时修改数据导致的数据不一致问题。方......
  • python - pdf转成excel文件
    初次尝试用python将pdf转换为excel表格,如有错误欢迎指出,需要用到的库如下:pipinstallpdfminer3kpipinstalltabula-pypipinstallopenpyxl如果是pip3,则:pip3installpdfminer3kpip3installtabula-pypip3installopenpyxl通过终端即可安装新建一个IDLE文件,源码如下:......
  • Python异步编程并发比较之循环、进程、线程、协程
    服务端现在有一个api接口http://127.0.0.1:18081/hello批量请求该接口,该接口中有一个5s的阻塞。使用循环,多进程,多线程,协程等四种方式,一共请求10次,比较总的请求耗时。importtimefromflaskimportFlaskapp=Flask(__name__)@app.route('/hello')defhello_world():......
  • Python分享之路径与文件 (os.path包, glob包)
    os.path包os.path包主要是处理路径字符串,比如说'/home/vamei/doc/file.txt',提取出有用信息。importos.pathpath='/home/vamei/doc/file.txt'print(os.path.basename(path))#查询路径中包含的文件名print(os.path.dirname(path))#查询路径中包含的目录info=......