我們是用百度PaddleOCR插件實現美團上訂單的數字價格識別,然后借用autojs對識別到的價格數字進行判斷,符合數字條件比如,PaddleOCR識別到的訂單價格為5,那么我們在AUTOJS上的價格為3就會觸發搶單,其實這個操作非常方便,比人工快好幾倍,幾乎是毫秒及反應,我這邊本地做了具體的測試,效果可以,然后這邊把源碼直接分享過來了,感興趣的可以下載嘗試奧。
字庫源碼:
//比較文字
var 數1="/storage/emulated/0/腳本1.png"
var 數2="/storage/emulated/0/腳本/2.png"
var 數3="/storage/emulated/0/腳本/3.png"
var 數4="/storage/emulated/0/腳本/4.png"
var 數5="/storage/emulated/0/腳本/5.png"
var 數6="/storage/emulated/0/腳本/6.png"
var 數7="/storage/emulated/0/腳本/7.png"
var 數8="/storage/emulated/0/腳本/8.png"
var 數9="/storage/emulated/0/腳本/9.png"
var 數點="/storage/emulated/0/腳本/點.png"
arr = [];
內容=""
總數字 = new Array(數1,數2,數3,數4,數5,數6,數7,數8,數9,數點);
//toastLog("數組"+總數字.length);
//toastLog("數組"+總數字[0]);
function 對比(圖片1){
for (let b = 0; b < 總數字.length; b++) {
//images.save(img, "/sdcard/" +a + ".png");
var 本地圖=images.read(圖片1)
//toastLog(總數字[0])
var 字庫圖=images.read(總數字[b])
//images.save(字庫圖, "/sdcard/字庫"+b+".png")
var 反饋=images.getSimilarity(本地圖, 字庫圖, {
"type": "PNSR"
})
if(反饋==0){
arr.push(總數字[b]);
}
// toastLog(總數字.length);
}
}
//比較文字
//以上為分割圖片
圖片 = images.read("/storage/emulated/0/腳本/價格.png");
識別()
圖片.recycle()
function 識別() {
let w = 圖片.getWidth()
let h = 圖片.getHeight()
let color = images.pixel(圖片, 0, 0);
let xsh = images.interval(圖片, color, 60)
//images.save(xsh,"/sdcard/精靈.jpg");
let bitmap = xsh.getBitmap();
let ysz = util.java.array("int", w * h);
bitmap.getPixels(ysz, 0, w, 0, 0, w, h);
let bjs = ysz[0] //背景色
let jl = [] //記錄
let jz = [] //記字
for (let x = 0; x < w; x++) {
i = 0
for (let y = 0; y < h; y++) {
let ys = ysz[y * w + x]
if (ys != bjs) {
log(ys)
jz.push({
x: x,
y: y
})
i++
}
}
if (i == 0 && jz.length > 0) {
jl.push(jz)
jz = []
}
}
let jzb = [] //記坐標
for (let i = 0; i < jl.length; i++) {
let sz = jl[i]
let x = sz[0].x,
y = sz[0].y,
w = sz[0].x,
h = sz[0].y
for (var z = 1; z < sz.length; z++) {
if (sz[z].x < x) {
x = sz[z].x
}
if (sz[z].x > w) {
w = sz[z].x
}
if (sz[z].y < y) {
y = sz[z].y
}
if (sz[z].y > h) {
h = sz[z].y
}
}
jzb.push({
x: x,
y: y,
w: w,
h: h
})
}
for (let i = 0; i < jzb.length; i++) {
img = images.clip(圖片, jzb[i].x, jzb[i].y, jzb[i].w-jzb[i].x, jzb[i].h-jzb[i].y)
images.save(img, "/sdcard/" +i + ".png");
對比("/sdcard/" +i + ".png")
img.recycle()
}
xsh.recycle()
//這里為識別文字
for (let i = 0; i < arr.length; i++) {
內容=內容+arr[i]
}
//這里為識別文字
//這里為讀取價格
//這里為讀取價格
}
//內容=內容.replace('點','.');
var str =內容
var 內容 = str.replace(/storage/g, '');
var 內容 = 內容.replace(/emulated/g, '');
var 內容 = 內容.replace(//0/g, '');
var 內容 = 內容.replace(///g, '');
var 內容 = 內容.replace(/.jpg/g, '');
var 內容 = 內容.replace(/腳本/g, '');
//var result = str.replace(///g, '');
//console.log('result:' + 內容);
// 輸出 result:AbcAbcAbc
toastLog(內容)
//以上為分割圖片
價格判斷+自動滑動源碼:
"ui";
ui.layout(
<vertical h="*" w="*">
<text textSize="16sp" textColor="black" text="軟件激活碼:"/>
<input id="jhm" text="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
<text textSize="16sp" textColor="black" text="最低預設價:(訂單價>預設價=搶單)"/>
<input id="jiage" text="5"/>
<text textSize="16sp" textColor="black" text="接單一次后延遲時間(防止多搶):"/>
<input id="huadongyanchi" text="1"/>
<text textSize="16sp" textColor="black" text="滑動搶單速度:(毫秒)"/>
<input id="huadonqd" text="120"/>
<radiogroup orientation="horizontal">
<radio id="單1"text="本地識別"/>
<radio id="單2"text="百度orc"/>
</radiogroup>
<button id="啟動" text=">>>只搶10元以上單【默認】" w="*" h="auto"/>
<button id="近距離" text=">>>只搶近距離單(一公里內)" w="*" h="auto"/>
<button id="只搶先搶" text=">>>只搶近距離單(一公里內)" w="*" h="auto"/>
<button id="串號" text="獲取設備機器碼" w="*" h="auto"/>
<button id="激活" text="點我授權設備" w="*" h="auto"/>
</vertical>
);
ui.激活.click(() => {
var 機器碼=device.getAndroidId()
var 最終機器碼=機器碼+"1995"+"
www.xkrj5.com
"
//importClass(
java.security.Me
ssageDigest);
function md5(string) {
return java.math.BigInteger(1,
java.security.Me
ssageDigest.getInstance("MD5")
.digest(java.lang.String(string).getBytes())).toString(16);
}
var md5=md5(最終機器碼)
setClip(md5);//復制當前的授權碼
//toastLog(md5);
var 編輯框=ui.jhm.getText();
if(編輯框==md5)
{toastLog("恭喜您!授權成功");
var 返回= files.create("/sdcard/1995/");
// toastLog(返回)
}else{toastLog("授權失敗,請填寫正確的授權碼")}
});
ui.串號.click(() => {
var 串號=device.getAndroidId()
toastLog("當前機器碼: "+串號+" 已復制到剪貼板,請發送給作者");
setClip(串號);
});
ui.近距離.click(() => {
//全局點擊刷新坐標
x坐標=225
y坐標=1296
初始化=1
//全局點擊刷新坐
//全局懸浮窗位置
寬=520
高=450
懸x=600
懸y=1800
//全局懸浮窗位置
//ocr = $plugins.load("com.hraps.ocr")
var 返回= files.create("/sdcard/1995/");
if(返回==false){
console.setSize(寬,高);
console.setPosition(懸x, 懸y);
console.log('感謝騎手選擇星辰搶單輔助v1.2免root穩定版!只搶高價單');
console.show()
app.launchApp("VMOS Pro");
threads.start(進入初始化)
暫停=1
arr=[1];
threads.start(距離)
}
});
ui.啟動.click(() => {
//全局點擊刷新坐標
x坐標=342
y坐標=1976
初始化=1
//全局點擊刷新坐
//全局懸浮窗位置
寬=520
高=450
懸x=600
懸y=1800
//全局懸浮窗位置
//ocr = $plugins.load("com.hraps.ocr")
var 返回= files.create("/sdcard/1995/");
if(返回==false){
console.setSize(寬,高);
console.setPosition(懸x, 懸y);
console.log('感謝騎手選擇星辰搶單輔助v1.2免root穩定版!只搶高價單');
console.show()
app.launchApp("VMOS Pro");
threads.start(進入初始化)
暫停=1
arr=[1];
threads.start(action)
}else{
toastLog("很抱歉!當前手機設備沒有授權")
}
});
//初始化
function 進入初始化(){
//懸浮窗停止腳本
var window = floaty.window(
<frame gravity="center">
<button id="action" text="點我暫停檢測"/>
</frame>
);
window.exitOnClose();
window.setPosition(懸x, 懸y);
window.action.click(() => {
//threads.start(zta)
//toastLog("已暫停,如需重新檢測訂單,請重啟檢測程序,一定記得開啟無障礙服務奧!");
//engines.stopAll();
if (window.action.getText() == '點我暫停檢測') {
// engines.execScriptFile(action);
window.action.setText('繼續運行');
console.log("已進行暫停腳本運行");
暫停=9999999999999
} else {
if (window.action.getText() == '繼續運行') {
// engines.execScriptFile(action);
暫停=0
threads.start(action)
console.log("已重啟訂單檢測服務");
window.action.setText('點我暫停檢測');
}
}
});
setInterval(() => {}, 1000);
//懸浮窗停止腳本
requestScreenCapture();
}
//初始化
//價格識別本地
function 價格識別(){
圖片 = images.read("/storage/emulated/0/腳本/wx.png");
識別()
圖片.recycle()
function 識別() {
let w = 圖片.getWidth()
let h = 圖片.getHeight()
let color = images.pixel(圖片, 0, 0);
let xsh = images.interval(圖片, color, 60)
//images.save(xsh,"/sdcard/精靈.jpg");
let bitmap = xsh.getBitmap();
let ysz = util.java.array("int", w * h);
bitmap.getPixels(ysz, 0, w, 0, 0, w, h);
let bjs = ysz[0] //背景色
let jl = [] //記錄
let jz = [] //記字
for (let x = 0; x < w; x++) {
i = 0
for (let y = 0; y < h; y++) {
let ys = ysz[y * w + x]
if (ys != bjs) {
log(ys)
jz.push({
x: x,
y: y
})
i++
}
}
if (i == 0 && jz.length > 0) {
jl.push(jz)
jz = []
}
}
let jzb = [] //記坐標
for (let i = 0; i < jl.length; i++) {
let sz = jl[i]
let x = sz[0].x,
y = sz[0].y,
w = sz[0].x,
h = sz[0].y
for (var z = 1; z < sz.length; z++) {
if (sz[z].x < x) {
x = sz[z].x
}
if (sz[z].x > w) {
w = sz[z].x
}
if (sz[z].y < y) {
y = sz[z].y
}
if (sz[z].y > h) {
h = sz[z].y
}
}
jzb.push({
x: x,
y: y,
w: w,
h: h
})
}
for (let i = 0; i < jzb.length; i++) {
let img = images.clip(圖片, jzb[i].x, jzb[i].y, jzb[i].w-jzb[i].x, jzb[i].h-jzb[i].y)
images.save(img, "/sdcard/腳本/分割/價格" + i + ".jpg");
img.recycle()
}
// xsh.recycle()
//判斷搶單
var arr = files.listDir("/sdcard/腳本/分割");
var 數量=arr.length
toast(數量);
if(數量>=5){
toast("大於");
//進入搶單
//進入搶單
}else{
toast("小於");
//價格不符合
//價格不符合
}
}
}
//價格識別本地
//識別價格
//價格識別
//檢測距離
function 距離(){
while(true){
sleep(暫停);
var src = images.read("/storage/emulated/0/腳本/xq.png");
var xq = findImage(captureScreen(), src)
//如果找到滑動圖標就循環檢測距離
//檢測到了
if(xq!=null){
console.log("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")
var src = images.read("/storage/emulated/0/腳本/huadong.png");
var hd = findImage(captureScreen(), src, {
region: [0,xq.y,device.width,500],
threshold: 0.8
});
if(hd!=null){
var suiji=Math.ceil(Math.random()*80);//生
swipe(hd.x,hd.y,1000,hd.y,parseInt(滑動速度)+parseInt(suiji))
sleep(2000);
}
if(hd==null){
click(357,1881)
}
//檢測到了
}else{
console.log("m")
click(357,1881)
}
}
}
//檢測距離
//剪輯價格
function action(){
//導入插件
//ocr = $plugins.load("com.hraps.ocr")
sleep(5000);
本地 =ui.單1.isChecked()
百度= ui.單2.isChecked()
var 接單延遲=ui.huadongyanchi.getText();
var 激活碼=ui.jhm.getText();
var 最低價格=ui.jiage.getText();
var 延遲時間=ui.shijian.getText();
var 滑動速度=ui.huadonqd.getText();
toastLog("准備初始化數據,啟動軟件");
sleep(500);
//全局檢測義
while(true){
sleep(暫停);
}
}