imgs

spring boot 图片上传到resources/static/upload/imgs目录下

无人久伴 提交于 2019-11-29 00:08:22
1.上传方法 package com.*; import *; public class BaseController { protected Logger logger = LoggerFactory.getLogger(getClass()); /** * 输出JSON数据 * * @param response * @param jsonStr */ public void writeJson(HttpServletResponse response, String jsonStr) { response.setContentType("text/json;charset=utf-8"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); PrintWriter pw = null; try { pw = response.getWriter(); pw.write(jsonStr); pw.flush(); } catch (Exception e) { logger.info("输出JSON数据异常", e); }finally{ if(pw!=null){ pw

[OpenCV-Python案例] 游戏图集分割

你说的曾经没有我的故事 提交于 2019-11-25 17:02:43
游戏图集分割程序 本程序只对游戏图集做简单的处理,需要有 json配置文件 与 图集文件 运行环境 python 3.6 + opencv-python pip install opencv-python 案例 目录 |--split |--|--imgs //用于存储分割后的散图 |--|--index.py |--|--res.json //图集配置文件(以LayaBox的图集为例) |--|--res.png //图集(以LayaBox的图集为例) index.py # -*- coding: utf-8 -*- import json import cv2 # 读取图集 imgMax = cv2.imread('res.png', cv2.IMREAD_UNCHANGED) # 读取图集配置文件 with open('res.json', 'r') as load_f: load_dict = json.load(load_f) imgs = load_dict.get('frames') # 遍历配置并保存散图 for imgName in imgs: d = imgs[imgName] img = imgMax[d['y']:d['y']+d['h'], d['x']:d['x']+d['w']] cv2.imwrite('imgs/' + imgName + '