首页 > 其他分享 >count_ga_5.py

count_ga_5.py

时间:2023-10-06 22:11:07浏览次数:39  
标签:count -% url py list ga time tep row

 

 

#!/usr/bin/python3
'''
    作用:统计港澳车的识别率,分别输出港牌和澳牌识别失败的港澳车的二次识别车牌、筛选过的时间和图片url的csv文件
'''
import os
import sys
import re
import pymysql
import time
import datetime
import logging
import pandas as pd
import requests
from clickhouse_driver import Client
if __name__ == '__main__':
    logging.basicConfig(filename=os.path.dirname(os.path.abspath(__file__)) + "/count_ga.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)
    sql = "select license_plate2,xgbdp,ambdp,VIIDOBJECTID,location_id,capture_time,image_url1  from yisa_oe.vehicle_all where (license_plate2 like '粤Z%澳' or license_plate2 LIKE '粤Z%港') and date = '2022-07-06'"
    try:
        results = cursor.execute(sql)
        sql = "select  count(*)  from yisa_oe.vehicle_all where license_plate2 LIKE '粤Z%港' and date = '2022-07-06'"
        xg_len = cursor.execute(sql)
        sql = "select  count(*)  from yisa_oe.vehicle_all where license_plate2 LIKE '粤Z%澳' and date = '2022-07-06'"
        am_len = cursor.execute(sql)
    except:
        logging.error("语句执行错误!")
        sys.exit(1)
    
    data_list = []  # 统计某天的港澳牌的行
    xg_recognize = 0 # 港牌识别成功总数
    am_recognize = 0 # 澳牌识别成功总数
    # df_recog =  []  # 识别失败,港澳能访问图片url的,元素是车牌号码和图片url的list
    xg_fail_recognize = [] # 识别失败,香港牌的,元素是车牌号码和图片url的list
    am_fail_recognize = [] # 识别失败,澳门牌的,元素是车牌号码和图片url的list
    fail_c = 0 # 港澳图片访问失败总数
    url_xg = 0 #港牌识别失败本地牌总数
    url_am = 0 #澳牌识别失败本地牌总数
    for row in results:
        row_list = list(row)
        for i in range(len(row_list)): #循环结果每行的每个字段
            if  row_list[i] and i == 0: # 遍历字段是二次识别
                if re.findall(r"澳+",row_list[i]): # 二次识别是澳牌
                    if  row_list[2]: #澳牌本地牌存在
                        am_recognize=am_recognize+1
                    else:
                        tep_list = []
                        tep_list.append(row_list[i])
                        url_am = url_am + 1 # 澳牌识别失败+1
                        time_int = row_list[5]
                        time_obj = time.localtime(time_int)
                        time_str = time.strftime("%Y-%m-%d_%H-%M-%S",time_obj)
                        tep_list.append(time_str)
                        tep_list.append(row_list[6])
                        # df_recog.append(tep_list) # 识别失败,元素是车牌+捕获时间+图片url
                        am_fail_recognize.append(tep_list)

                if re.findall(r"港+",row_list[i]):  # 二次识别是港牌
                    if row_list[1]: #港牌本地牌存在
                        xg_recognize = xg_recognize+1
                    else:
                                                tep_list = []
                                                tep_list.append(row_list[i])
                                                url_xg = url_xg + 1
                                                time_int = row_list[5]
                                                time_obj = time.localtime(time_int)
                                                time_str = time.strftime("%Y-%m-%d_%H-%M-%S",time_obj)
                                                tep_list.append(time_str)
                                                tep_list.append(row_list[6])
                                                # df_recog.append(tep_list)
                                                xg_fail_recognize.append(tep_list)
            if not row_list[i] and i == 0:
                row_list[i] = "二次识别失败"
            if not row_list[i] and i == 1:
                row_list[i] = "香港牌识别失败"
            if not row_list[i] and i == 2:
                row_list[i] = "澳门牌识别失败"
            if i == 5:
                time_int = row_list[i]
                time_obj = time.localtime(time_int)
                row_list[i] = time.strftime("%Y-%m-%d_%H-%M-%S",time_obj)
        logging.info(row)
        data_list.append(row_list)
    df = pd.DataFrame(data_list,columns=['license_plate2','xgbdp','ambdp','VIIDOBJECTID','location_id','capture_time','image_url1'])
    #df2 = pd.DataFrame(df_recog,columns=['license_plate2','capture_time','image_url1']) # 识别失败的图片url、捕获时间和港澳车牌
    #s_dt = datetime.datetime.strptime('2022-06-23_17-00-00','%Y-%m-%d_%H-%M-%S')
    #df2['capture_time'] = pd.to_datetime(df2['capture_time'], format='%Y-%m-%d_%H-%M-%S')
    #df3 = df2[df2['capture_time']<=s_dt]
    #logging.info("df: {}".format(df))
    df_xg_fail_recognize = pd.DataFrame(xg_fail_recognize,columns=['license_plate2','capture_time','image_url1'])
    
    df_am_fail_recognize = pd.DataFrame(am_fail_recognize,columns=['license_plate2','capture_time','image_url1'])
    df_xg_fail_recognize.to_csv('xg_fail_rec.csv',index=False)
    df_am_fail_recognize.to_csv('am_fail_rec.csv',index=False)

 

标签:count,-%,url,py,list,ga,time,tep,row
From: https://www.cnblogs.com/lfxx/p/17745171.html

相关文章

  • post_image.py
    说明:在特定的目录中通过文件名通配符筛选出图片,向某个接口发送post请求传输图片识别图片,并判断post请求返回的结果 #!/usr/bin/python#-*-coding:utf-8-*-importos,sys,glob#importtqdmimportmultiprocessing#importreimporttimeimportthreadingimportreq......
  • G9、ACGAN理论与实战
    ......
  • G7、Semi-Supervised GAN 理论与实战
    ......
  • openGauss学习笔记-91 openGauss 数据库管理-内存优化表MOT管理-内存表特性-使用MOT-M
    openGauss学习笔记-91openGauss数据库管理-内存优化表MOT管理-内存表特性-使用MOT-MOT使用MOT外部支持工具为了支持MOT,修改了以下外部openGauss工具。请确保使用的工具是最新版本。下面将介绍与MOT相关的用法。有关这些工具及其使用方法的完整说明,请参阅《工具与命令参考》。91......
  • 笨办法学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文件,源码如下:......
  • 无涯教程-OC - Navigation Bar函数
    导航栏包含导航控制器的导航按钮,导航控制器是可被按下和弹出的视图控制器的堆栈。导航栏上的标题是当前视图控制器的标题。NavigationBar-示例代码步骤1-创建基于视图的应用程序。步骤2-现在,选择AppDelegate.h并为导航控制器添加一个属性,如下所示-#import<UIKit/U......
  • 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=......