diff --git a/app/src/main/assets/sample/YOLO/NCNN-PaddleOCR不可同时使用.txt b/app/src/main/assets/sample/YOLO/NCNN-PaddleOCR不可同时使用.txt index 7347c85c..bd7f1ca6 100644 --- a/app/src/main/assets/sample/YOLO/NCNN-PaddleOCR不可同时使用.txt +++ b/app/src/main/assets/sample/YOLO/NCNN-PaddleOCR不可同时使用.txt @@ -1,5 +1,8 @@ -NCNN和PaddleOCR同时使用时有兼容性问题导致无法正常运行甚至闪退,请勿同时使用 +NCNN和PaddleOCR同时使用时, +有兼容性问题导致无法正常运行甚至闪退,请勿同时使用 -该问题暂时无法解决,因此如果需要使用PaddleOcr时 请使用onnx,或者使用mlkitocr进行文字识别 +该问题暂时无法解决,因此如果需要使用PaddleOcr时 +请使用onnx,或者使用mlkitocr进行文字识别 -建议在依赖性能的情况下使用ncnn,同时使用mlkitocr进行文字识别 +建议在依赖性能的情况下使用ncnn, +同时使用mlkitocr进行文字识别 diff --git a/app/src/main/assets/sample/YOLO/NCNN-P同时使用-必闪退.js b/app/src/main/assets/sample/YOLO/NCNN-P同时使用-必闪退.js index f258fddc..355b1652 100644 --- a/app/src/main/assets/sample/YOLO/NCNN-P同时使用-必闪退.js +++ b/app/src/main/assets/sample/YOLO/NCNN-P同时使用-必闪退.js @@ -1,6 +1,6 @@ const img = images.read("./test.png") console.show() -setTimeout(() -> console.hide(), 15000) +setTimeout(() => console.hide(), 15000) let cpuThreadNum = 4 // PaddleOCR 移动端提供了两种模型:ocr_v3_for_cpu与ocr_v3_for_cpu(slim),此选项用于选择加载的模型,默认true使用v3的slim版(速度更快),false使用v3的普通版(准确率更高) let useSlim = true @@ -14,8 +14,8 @@ let result = $ocr.detect(img, { cpuThreadNum, useSlim }) img.recycle() log('slim识别耗时:' + (new Date() - start) + 'ms') -let model_path = '/sdcard/脚本/best.bin' -let param_path = '/sdcard/脚本/best.param' +let model_path = '/sdcard/脚本/manor.bin' +let param_path = '/sdcard/脚本/manor.param' if (!files.exists(model_path) || !files.exists(param_path)) { toastLog('请确认已下载了模型文件') exit() diff --git a/app/src/main/assets/sample/YOLO/NCNN-P调整顺序-推理会卡死.js b/app/src/main/assets/sample/YOLO/NCNN-P调整顺序-推理会卡死.js index c2240c45..098919e6 100644 --- a/app/src/main/assets/sample/YOLO/NCNN-P调整顺序-推理会卡死.js +++ b/app/src/main/assets/sample/YOLO/NCNN-P调整顺序-推理会卡死.js @@ -1,8 +1,7 @@ console.show() -setTimeout(() -> console.hide(), 15000) -setTimeout(() -> console.hide(), 15000) -let model_path = '/sdcard/脚本/best.bin' -let param_path = '/sdcard/脚本/best.param' +setTimeout(() => console.hide(), 15000) +let model_path = '/sdcard/脚本/manor.bin' +let param_path = '/sdcard/脚本/manor.param' if (!files.exists(model_path) || !files.exists(param_path)) { toastLog('请确认已下载了模型文件') exit() diff --git a/app/src/main/assets/sample/YOLO/bus.jpg b/app/src/main/assets/sample/YOLO/bus.jpg deleted file mode 100644 index 40eaaf5c..00000000 Binary files a/app/src/main/assets/sample/YOLO/bus.jpg and /dev/null differ diff --git a/app/src/main/assets/sample/YOLO/ncnn-yolo-demo-gpu.js b/app/src/main/assets/sample/YOLO/ncnn-yolo-demo-gpu.js deleted file mode 100644 index 8cc1fcd3..00000000 --- a/app/src/main/assets/sample/YOLO/ncnn-yolo-demo-gpu.js +++ /dev/null @@ -1,39 +0,0 @@ -let model_path = '/sdcard/脚本/yolov8n.bin' -let param_path = '/sdcard/脚本/yolov8n.param' -if (!files.exists(model_path) || !files.exists(param_path)) { - toastLog('请确认已下载了模型文件') - exit() -} -console.show() -setTimeout(() -> console.hide(), 15000) -let yoloInit = $yolo.init({ - type: 'ncnn', - useGpu: true, - paramPath: files.path(param_path), - binPath: files.path(model_path), - imageSize: 480, - labels: [ - "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", - "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", - "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", - "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", - "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", - "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch", - "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone", - "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", - "hair drier", "toothbrush" - ] -}) - -if (!yoloInit) { - toast('初始化失败') - exit() -} - -const img = images.read("./bus.jpg") -let start = new Date() -const result = $yolo.forward(img) -toastLog('ncnn cost: ' + (new Date() - start) + 'ms') -log('predict result:' + JSON.stringify(result, null, 4)) - -img.recycle() \ No newline at end of file diff --git a/app/src/main/assets/sample/YOLO/ncnn-yolo-demo.js b/app/src/main/assets/sample/YOLO/ncnn-yolo-demo.js deleted file mode 100644 index d044b107..00000000 --- a/app/src/main/assets/sample/YOLO/ncnn-yolo-demo.js +++ /dev/null @@ -1,38 +0,0 @@ -let model_path = '/sdcard/脚本/yolov8n.bin' -let param_path = '/sdcard/脚本/yolov8n.param' -if (!files.exists(model_path) || !files.exists(param_path)) { - toastLog('请确认已下载了模型文件') - exit() -} -console.show() -setTimeout(() -> console.hide(), 15000) -let yoloInit = $yolo.init({ - type: 'ncnn', - paramPath: files.path(param_path), - binPath: files.path(model_path), - imageSize: 480, - labels: [ - "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", - "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", - "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", - "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", - "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", - "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch", - "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone", - "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", - "hair drier", "toothbrush" - ] -}) - -if (!yoloInit) { - toast('初始化失败') - exit() -} - -const img = images.read("./bus.jpg") -let start = new Date() -const result = $yolo.forward(img) -toastLog('ncnn cost: ' + (new Date() - start) + 'ms') -log('predict result:' + JSON.stringify(result, null, 4)) - -img.recycle() diff --git a/app/src/main/assets/sample/YOLO/ncnn-yolo-manor.js b/app/src/main/assets/sample/YOLO/ncnn-yolo-manor.js index 415e4ea4..dc563a61 100644 --- a/app/src/main/assets/sample/YOLO/ncnn-yolo-manor.js +++ b/app/src/main/assets/sample/YOLO/ncnn-yolo-manor.js @@ -1,11 +1,11 @@ -let model_path = '/sdcard/脚本/best.bin' -let param_path = '/sdcard/脚本/best.param' +let model_path = '/sdcard/脚本/manor.bin' +let param_path = '/sdcard/脚本/manor.param' if (!files.exists(model_path) || !files.exists(param_path)) { toastLog('请确认已下载了模型文件') exit() } console.show() -setTimeout(() -> console.hide(), 15000) +setTimeout(() => console.hide(), 15000) let yoloInit = $yolo.init({ type: 'ncnn', paramPath: files.path(param_path), diff --git a/app/src/main/assets/sample/YOLO/onnx-yolo-manor.js b/app/src/main/assets/sample/YOLO/onnx-yolo-manor.js index 12ad21d3..f4de4577 100644 --- a/app/src/main/assets/sample/YOLO/onnx-yolo-manor.js +++ b/app/src/main/assets/sample/YOLO/onnx-yolo-manor.js @@ -4,7 +4,7 @@ if (!files.exists(model_path)) { exit() } console.show() -setTimeout(() -> console.hide(), 15000) +setTimeout(() => console.hide(), 15000) let yoloInit = $yolo.init({ type: 'onnx', modelPath: files.path(model_path), diff --git a/app/src/main/assets/sample/YOLO/截图并识别-reuse.js b/app/src/main/assets/sample/YOLO/截图并识别-reuse.js deleted file mode 100644 index 73791d19..00000000 --- a/app/src/main/assets/sample/YOLO/截图并识别-reuse.js +++ /dev/null @@ -1,307 +0,0 @@ -// 杀死当前同名脚本 see AutoScriptBase/lib/killMyDuplicator -(() => { let g = engines.myEngine(); var e = engines.all(), n = e.length; let r = g.getSource() + ""; 1 < n && e.forEach(e => { var n = e.getSource() + ""; g.id !== e.id && n == r && e.forceStop() }) })(); - -if (!requestScreenCapture()) { - toastLog('请求截图权限失败') - exit() -} - - -let onnxInstance = null -let ncnnInstance = null -let currentType = 'ncnn' -initYoloInstances() -let yoloInstance = { - ncnn: ncnnInstance, - onnx: onnxInstance, -} - -// 识别结果和截图信息 -let result = [] -let img = null -let running = true -let capturing = false - -/** - * 截图并识别OCR文本信息 - */ -function captureAndDetect () { - capturing = true - img = captureScreen() - if (!img) { - toastLog('截图失败') - } - let start = new Date() - result = yoloInstance[currentType].forward(img) - console.verbose('识别结果:' + JSON.stringify(result)) - toastLog('耗时' + (new Date() - start) + 'ms') - img && img.recycle() - capturing = false -} - -// captureAndDetect() - -// 获取状态栏高度 -let offset = -getStatusBarHeightCompat() - -// 绘制识别结果 -let window = floaty.rawWindow( - -); - -// 设置悬浮窗位置 -ui.post(() => { - window.setPosition(0, offset) - window.setSize(device.width, device.height) - window.setTouchable(false) -}) - -// 操作按钮 -let clickButtonWindow = floaty.rawWindow( - -