js mouse movie获取坐标

document.addEventListener('mousemove',function (e) {
        //mousemove 鼠标一移动,就会触发事件
        //获取鼠标最新的坐标
        console.log("y:",e.clientY,"x:",e.clientX)
    })

clientX:当鼠标事件发生时(不管是onclick,还是omousemove,onmouseover等),鼠标相对于浏览器(这里说的是浏览器的有效区域)x轴的位置;
clientY:当鼠标事件发生时,鼠标相对于浏览器(这里说的是浏览器的有效区域)y轴的位置;

一般看验证码轨迹用

需要注意的是,验证码前端中的验证码,缺口距离的计算和opencv的区别。

opencv计算图片缺口距离代码

from io import BytesIO

import cv2
def get_distance(fg, bg):
        """
        计算滑动距离
        """
        target = cv2.imdecode(np.asarray(bytearray(fg.read()), dtype=np.uint8), 0)
        template = cv2.imdecode(np.asarray(bytearray(bg.read()), dtype=np.uint8), 0)
        result = cv2.matchTemplate(target, template, cv2.TM_CCORR_NORMED)
        _, distance = np.unravel_index(result.argmax(), result.shape)
        return distance

其中fg和bg如下

 r = requests.get(fg_url)
 fg = BytesIO(r.content)
 r = requests.get(bg_url)
 bg = BytesIO(r.content)
posted @ 2023-01-17 11:59  公众号python学习开发  阅读(52)  评论(0编辑  收藏  举报