当前位置: 首页 > news >正文

反钓鱼网站联盟网上购物系统功能需求分析

反钓鱼网站联盟,网上购物系统功能需求分析,定制企业网站建设哪家好,网址导航网站如何做文章目录 背景代码 背景 如果我们想要根据json标注文件,获取里面的指定目标的裁剪区域,那么我们可以根据以下代码来实现(也可以校验标注情况)。 代码 from tqdm import tqdm import os, json, cv2, copy import numpy as npdef…

文章目录

  • 背景
  • 代码

背景

如果我们想要根据json标注文件,获取里面的指定目标的裁剪区域,那么我们可以根据以下代码来实现(也可以校验标注情况)。

代码

from tqdm import tqdm
import os, json, cv2, copy
import numpy as npdef get_all_images(path, flags):result_list, filenames = [], []for root, dirs, files in os.walk(path):for file in files:filename, file_extension = os.path.splitext(file)if file_extension.lower() in flags:result_list.append(os.path.join(root, file))filenames.append(file)return result_list, filenamesdef get_labelme_info(label_file, target):anno = json.load(open(label_file, "r", encoding="utf-8"))shapes = anno['shapes']image_path = os.path.basename(anno['imagePath'])labels = []boxes = []for s in shapes:pts = s['points']x1, y1 = pts[0]x2, y2 = pts[1]label = s['label']if label in target:labels.append(label)boxes.append([x1, y1, x2, y2])return image_path, boxes, labelsdef plot_one_ori(image, boxs, label, color, mask_alpha=0.4):[x1, y1, x2, y2] = boxsmask_img = copy.deepcopy(image) # 1ori_img = copy.deepcopy(mask_img) # 1cropped_image = ori_img[y1:y2, x1:x2]img_height, img_width = image.shape[:2]size = min([img_height, img_width]) * 0.0006text_thickness = int(min([img_height, img_width]) * 0.001)cv2.rectangle(image, (x1, y1), (x2, y2), color, 3)caption = f'{"原标签-"}{label}'(tw, th), _ = cv2.getTextSize(text=caption, fontFace=cv2.FONT_HERSHEY_SIMPLEX,fontScale=size, thickness=text_thickness)th = int(th * 1.2)cv2.rectangle(image, (x1, y2),(x1 + tw, y2 + th), color, -1)cv2.rectangle(mask_img, (x1, y2),(x1 + tw, y2 + th), color, -1)cv2.putText(image, caption, (x1, y2 + th), cv2.FONT_HERSHEY_SIMPLEX, size, (255, 255, 255), text_thickness, cv2.LINE_AA)cv2.putText(mask_img, caption, (x1, y2 + th), cv2.FONT_HERSHEY_SIMPLEX, size, (255, 255, 255), text_thickness, cv2.LINE_AA)image = cv2.addWeighted(mask_img, mask_alpha, image, 1 - mask_alpha, 0)return image, cropped_imagedef cv_imread(filePath):cv_img = cv2.imdecode(np.fromfile(filePath, dtype=np.uint8), flags=cv2.IMREAD_COLOR)return cv_imgif __name__ == "__main__":img_folder = r"\\DSJ_NAS_90*******" # 原图和JSON文件位置save_target_path = r"\\DSJ_NA************" # 保存位置target = ["red_face"] # 获取指定目标,可传多个os.makedirs(save_target_path, exist_ok=True)img_list, filenames = get_all_images(img_folder, flags=[".jpg", ".png", ".jpeg"])print(filenames)for filename in filenames:fn, file_extension = os.path.splitext(filename)image_path = os.path.join(img_folder, filename)  # 图片名json_path = os.path.join(img_folder, "{}.json".format(fn))  # 标签文件名save_path = os.path.join(save_target_path, "{}.jpg".format(fn))_, ori_boxes, ori_labels = get_labelme_info(json_path, target)for box, label in zip(ori_boxes, ori_labels):x1, y1, x2, y2 = list(map(int, box))image = cv_imread(image_path)image, crop_image = plot_one_ori(image, [x1, y1, x2, y2], label, color=(0,0,255))# cv2.imshow("1",crop_image)# cv2.waitKey(1)cv2.imencode('.jpg', crop_image)[1].tofile(save_path)
http://www.yayakq.cn/news/621069/

相关文章:

  • 做app网站需要什么技术支持wordpress 订单插件
  • 建一个淘宝客网站需要多少钱自己建立网站多少钱
  • 儿童网站开发网站index.php被修改
  • 阿里云建设网站费用舆情监测工作要怎么做
  • 果洛营销网站建设服务注册域名要钱吗
  • 阿里云网站建设怎么样设计师灵感网站
  • asp网站如何迁移1核做网站
  • 如皋市建设局网站在哪上海网站备案人工服务器
  • 写出网站版面布局设计步骤长治网站制作服务
  • 哪个网站可以做c 的项目WordPress首页可见
  • 网站打开不对微商城手机网站设计
  • wordpress积分站内搜索成都新闻最新消息
  • 万网如何购买网站空间佳天下装饰公司怎么样
  • 网站源码程序上海官网网址
  • 珠海网站建设q479185700棒wordpress oauth2
  • iis默认网站怎么设置做华为网站的还有哪些功能
  • 杂志网站建设推广方案网站建设平台哪个公司好
  • 江西省楚天建设集团有限公司网站凡科网小程序制作教程
  • 温州做网站报价网站开发需要多少人
  • 免费建网站平台教简单网站建设教程
  • 秦皇岛seo网站推广wordpress无评论
  • 树莓派用来做网站网商之窗登录
  • 网站首页动画怎么做的做网站大概
  • 东莞公司官网建站做网站还需要买空间吗
  • 民宿网站开发dfd图做企业网站的尺寸是多少钱
  • 百度网站建设开场话术江门蓬江发布
  • wordpress是哪家公司的建站程序重庆建工信息网官网
  • 资兴市网站建设服务商seort什么意思
  • flash做网站的流程网店推广的方法有哪些
  • 抚州网站推广东莞公共资源交易中心