Code Monkey home page Code Monkey logo

roll_screenshot's Introduction

roll_screenshot

用python实现的滚动截屏功能,本功能集成自JamtoolsJamscreenshot项目

本仓库中的源码可能落后于Jamtools仓库

如果你还需要普通区域截屏类似qq截屏的功能,可以看看(https://github.com/fandesfyf/Jamscreenshot)

具体思路

滚动截屏的步骤:滚动-->截屏-->寻找拼接点-->拼接

滚动

滚动部分主要用了pynput模块的滚动功能,该模块还可以实现全局快捷键,具体方法本文不深究。

截屏

由于我的小工具集是采用pyqt作为界面的,就直接用qt的截屏方法了,可以自行改为pil或win32的截屏方法

截屏中止(滚动中止)采用了双重判定,当前后两张图片相同(到了尽头)时可以自动停止,当按下鼠标左键时也会停止

寻找拼接点

寻找拼接点就是比较相邻的图片,寻找下一张图片在前一张图片的相同部分的位置,并记录下来。

但考虑到有些截屏区域是包含不滚动部分的,即所有图片都有相同的头部或边框,所以截取的图片就不能直接用来寻找拼接点,需要比较多张图片并去除相同部分的影响;

所以这一部分又可以分几步:把图片灰度化(不然就要比较rgb3个通道,处理时间大大增加)-->把图片的灰度值储存于数组中-->比较前n张图片并找出所有相同的边界点(上、左、右三处,下方由于拼接的时候会覆盖掉就不用识别了)-->排除相同的部分开始寻找拼接的界限(逐行比较)

更具体的实现已经在代码中标明了,仔细看注释应该可以看懂,可以根据需要改动代码,例如可以完全去除qt库(这个库是真的大!)

听说还可以用opencv实现图片拼接功能(而且效率upup的),等我研究一下再来改蛤

-----20210226更新-------

使用opencv进行特征提取和匹配,拼接效率更快,需要安装opencv-contrib-python==3.4.2.17(包含sift算法)

roll_screenshot's People

Contributors

fandesfyf avatar

Stargazers

dlxj avatar Suen avatar  avatar ALSRitter avatar  avatar Snail Fan avatar  avatar  avatar  avatar  avatar Nic avatar Guangyuan Yao avatar  avatar  avatar  avatar  avatar DonQ Yu avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.