1 Star 0 Fork 2

叶志飞/Flask-application

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.py 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
小南橙 提交于 2022-12-21 14:59 +08:00 . face done
from flask import Flask, render_template, session, redirect, url_for, request, jsonify
# from flask_cors import CORS #跨域
app = Flask(__name__)
# CORS(app, resources=r'/*') # 注册CORS, "/*" 允许访问所有api
#从工具中导入需要的功能函数
from tools.imageColor import dragColor
from tools.shotvideo import genFrame
from tools.getSubtitle import GetSubtitle
from tools.OCR import getOCR
from tools.text import read_deal_text
from tools.face import get_face_res
@app.route('/')
def home():#首页
return render_template('index.html',active="home")
@app.route('/shot')
def shot():#分镜
#
pic="static/img/image" #分镜结果目录
# framecount=genFrame()# 正式使用需要将这行注释取消 下面这行注释
framecount=[92, 192, 227]
return render_template('shot.html',pic1=pic,framecount=framecount,active="shot")
@app.route("/get_colors")
def get_colors():#视频关键帧的色彩提取
img_id =request.args.get("id",None)
if img_id:#判断是否有图片的id 有的话返回颜色提取结果 否则返回整个分镜结果 注释同分镜
colors,colors_hex = dragColor(f"./static/img/image{img_id}.jpg")
return render_template("get_color.html",img_id=img_id,colors=colors,colors_hex=colors_hex,active="get_colors")
pic="static/img/image"
# framecount=genFrame()
framecount=[92, 192, 227]
return render_template("get_color.html",flag=True,pic1=pic,framecount=framecount,active="get_colors")
@app.route("/get_subtitle")
def get_subtitle():# 视频中字幕提取识别 直接返回前端页面
return render_template("get_subtitle.html",active="get_subtitle")
@app.route("/get_res")
def get_res():#获取字幕结果 由于时间过长 单独处理 前端使用ajax异步向后端请求
res=GetSubtitle()
return jsonify({'data':res})
@app.route("/text")
def text():
text_name =request.args.get("name",None)
if text_name:
counts,save_file_path=read_deal_text(text_name)
return jsonify({'counts':counts,'save_file_path':save_file_path})
counts,save_file_path=read_deal_text()
return render_template("text.html",active="text",counts=counts,save_file_path=save_file_path)
@app.route("/face")
def face():
face_path=r".\static\img\face1.jpeg"
face_alignment_res,face_detect_res=get_face_res()
return render_template("face.html",active="face",face_alignment_res=face_alignment_res,face_detect_res=face_detect_res,face_path=face_path)
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5001,debug=True)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yezhifei8855_admin/flask-application.git
git@gitee.com:yezhifei8855_admin/flask-application.git
yezhifei8855_admin
flask-application
Flask-application
master

搜索帮助