评价图像10度一个梯度的文本框数量

评价图像文本框数量

import numpy as np
import cv2
import paddlehub as hub


import math
import datetime
import multiprocessing as mp
import multiprocessing as mp

#旋转10度检测文本框
#记录文本框最多的角度
#识别

#检测文本框数量
def rotate_bound_white_bg(imageMats):
    text_detector = hub.Module(name="chinese_text_detection_db_server")
    text_detector.__init__(enable_mkldnn=True)
    #获取文本框
    results = text_detector.detect_text(
                images=imageMats,
                use_gpu=False,
                output_dir='detection_result',
                box_thresh=0.1,
                visualization=True)
    print(results)
    for index in range(len(results)):
        data = results[index]['data']
        #文本框数量
        print(len(data))



# 逆时针旋转图像degree角度(原尺寸)
def rotateImage(src, degree):
    # 旋转中心为图像中心
    h, w = src.shape[:2]
    # 计算二维旋转的仿射变换矩阵
    RotateMatrix = cv2.getRotationMatrix2D((w / 2.0, h / 2.0), degree, 1)
    #print(RotateMatrix)
    # 仿射变换,背景色填充为白色
    rotate = cv2.warpAffine(src, RotateMatrix, (w, h), borderValue=(255, 255, 255))
    return rotate

if __name__ == '__main__':
    num_cores = int(mp.cpu_count())
    print("本地计算机有: " + str(num_cores) + " 核心")

    src = cv2.imread("C:\\s\\2b.jpg")
    start_t = datetime.datetime.now()
    #定义角度数组
    roList = [10,20,30,40,50,60,70,80,90,-10,-20,-30,-40,-50,-60,-70,-80,-90,]
    #建立每个角度下的Mat数据
    matList = []
    for index in range(len(roList)):
        yjd = roList[index]
        mat = rotateImage(src,yjd)
        matList.append(mat)
    print(len(matList))
    #检测




    pool = mp.Pool(num_cores)
    #pool.apply_async(( rotate_bound_white_bg(),matList))

    results = [pool.apply_async(rotate_bound_white_bg, args=(images)) for images in matList]


    end_t = datetime.datetime.now()
    elapsed_sec = (end_t - start_t).total_seconds()
    print("多进程计算 共消耗: " + "{:.2f}".format(elapsed_sec) + " 秒")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全栈攻城狮s

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值