Kaynağa Gözat

旋转和平移验证码

luojiehua 5 ay önce
ebeveyn
işleme
ec1bd13574

+ 0 - 0
RotateMatch/__init__.py


BIN
RotateMatch/captcha_rotate.pt


BIN
RotateMatch/captcha_rotate.state


BIN
RotateMatch/captcha_tailor.pt


BIN
RotateMatch/captcha_tailor.state


BIN
RotateMatch/rotate.png


Dosya farkı çok büyük olduğundan ihmal edildi
+ 116 - 0
RotateMatch/rotate.py


BIN
RotateMatch/rotate_b.jfif


Dosya farkı çok büyük olduğundan ihmal edildi
+ 3045 - 0
RotateMatch/test.jpeg


+ 83 - 0
captcha_rotate_server.py

@@ -0,0 +1,83 @@
+
+
+
+from flask import request, Flask, jsonify,logging
+import time
+import logging
+
+
+app = Flask(__name__)
+
+from RotateMatch.rotateInterface import *
+
+
+@app.route("/tailor", methods=["POST"])
+def tailor():
+    start_time = time.time()
+    """receive image and predict """
+    base64pic = request.json.get('base64pic')
+    height = request.json.get("height")
+    # print(request.data)
+    data = {'success':False}
+
+    if base64pic is None:
+        data["errorinfo"] = "captcha tailor needs two params:base64pic and height,please check"
+        return jsonify(data),404
+    try:
+
+        img_b64 = base64pic.split(',')[-1]
+        width = getMoveLength(img_b64,height)
+
+        data["destination"] = width
+        data["success"] = True
+        data["cost"] = time.time()-start_time
+
+
+        logging.info("tailor takes %.2f"%(time.time()-start_time))
+        return jsonify(data),200
+    except Exception as e:
+        data["errorinfo"] = "exception with %s"%(str(e))
+        return jsonify(data),500
+
+@app.route("/rotate", methods=["POST"])
+def rotate():
+    start_time = time.time()
+    """receive image and predict """
+    base64pic = request.json.get('base64pic')
+    radius = request.json.get('radius')
+    # print(request.data)
+    data = {'success':False}
+
+    if base64pic is None :
+        data["errorinfo"] = "captcha tailor needs one params:base64pic,please check"
+        return jsonify(data),404
+    try:
+
+        img_b64 = base64pic.split(',')[-1]
+        angle = getRotateAngle(img_b64,radius)
+
+        data["angle"] = angle
+        data["success"] = True
+        data["cost"] = time.time()-start_time
+
+
+        logging.info("tailor takes %.2f"%(time.time()-start_time))
+        return jsonify(data),200
+    except Exception as e:
+        data["errorinfo"] = "exception with %s"%(str(e))
+        traceback.print_exc()
+        return jsonify(data),500
+
+
+
+
+if __name__ == '__main__':
+    handler = logging.FileHandler('flask.log', encoding='UTF-8')
+    app.logger.setLevel("INFO")
+    logging_format = logging.Formatter(
+        '%(asctime)s - %(levelname)s - %(filename)s -%(lineno)s - %(message)s'
+    )
+    handler.setFormatter(logging_format)
+    app.logger.addHandler(handler)
+    app.run("0.0.0.0", port=17053, debug=False) # 2.177 本地IP
+

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor