forked from Fachep/yas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
314 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ data/ | |
target/ | ||
mona.json | ||
.idea/ | ||
captures/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div align="center"> | ||
|
||
# Yas | ||
Yet Another Genshin Impact Scanner | ||
又一个原神圣遗物导出器 | ||
|
||
</div> | ||
|
||
## 介绍 | ||
基于CRNN(MobileNetV3_Small + LSTM)字符识别模型,使用原神字体对原神中会出现的字符串进行训练,达到更高的速度和更精确的结果。 | ||
导出结果可以导入分析工具(例如 [莫娜占卜铺](https://mona-uranai.com/) )进行配装或者其他计算 | ||
由于使用了 [Rust](https://www.rust-lang.org/) 进行编写,运行效率和文件体积都得到了很大的提升 | ||
### 相关资料 | ||
- [MobileNetV3](https://arxiv.org/pdf/1905.02244.pdf) | ||
- [CRNN](https://arxiv.org/pdf/1507.05717.pdf) | ||
|
||
## 使用 | ||
- 打开原神,并切换到背包页面,将背包拉到最上面 | ||
- 下载单exe可执行文件,右键管理员运行 | ||
|
||
### 命令行使用 | ||
查看选项 | ||
```shell | ||
yas --help | ||
``` | ||
只扫描五星圣遗物 | ||
```shell | ||
yas --min-star=5 | ||
``` | ||
只扫描一行 | ||
```shell | ||
yas --max-row=1 | ||
``` | ||
|
||
## 反馈 | ||
- Issue | ||
- QQ群:801106595 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,19 @@ use yas::capture::{capture_absolute, capture_absolute_image}; | |
use yas::inference::pre_process::{to_gray, raw_to_img, normalize, crop, pre_process, image_to_raw}; | ||
use yas::info::info; | ||
|
||
use winapi::um::winuser::{SetForegroundWindow}; | ||
use winapi::um::winuser::{SetForegroundWindow, GetDpiForSystem, SetThreadDpiAwarenessContext, ShowWindow, SW_SHOW, SW_RESTORE}; | ||
|
||
use clap::{Arg, App}; | ||
|
||
use image::{ImageBuffer, Pixel}; | ||
use image::imageops::grayscale; | ||
use yas::common::{RawImage, PixelRect}; | ||
use yas::scanner::yas_scanner::YasScanner; | ||
use yas::scanner::yas_scanner::{YasScanner, YasScannerConfig}; | ||
use yas::inference::inference::CRNNModel; | ||
use yas::expo::mona_uranai::MonaFormat; | ||
use env_logger::{Env, Builder, Target}; | ||
use log::{info, LevelFilter}; | ||
use winapi::shared::windef::DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; | ||
|
||
fn open_local(path: String) -> RawImage { | ||
let img = image::open(path).unwrap(); | ||
|
@@ -38,17 +41,37 @@ fn main() { | |
utils::error_and_quit("请以管理员身份运行该程序") | ||
} | ||
|
||
let matches = App::new("YAS - 原神圣遗物导出器") | ||
.version("0.1.0") | ||
.author("wormtql <[email protected]>") | ||
.about("Genshin Impact Artifact Exporter") | ||
.arg(Arg::with_name("max-row").long("max-row").takes_value(true).help("最大扫描行数")) | ||
.arg(Arg::with_name("capture-only").long("capture-only").required(false).takes_value(false).help("只保存截图,不进行扫描,debug专用")) | ||
.arg(Arg::with_name("min-star").long("min-star").takes_value(true).help("最小星级").min_values(1).max_values(5)) | ||
.arg(Arg::with_name("max-wait-switch-artifact").long("max-wait-switch-artifact").takes_value(true).min_values(10).help("切换圣遗物最大等待时间(ms)")) | ||
.get_matches(); | ||
let config = YasScannerConfig::from_match(matches); | ||
|
||
unsafe { SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); } | ||
let hwnd = match utils::find_window(String::from("原神")) { | ||
Err(s) => { | ||
utils::error_and_quit("未找到原神窗口,请确认原神已经开启"); | ||
}, | ||
Ok(h) => h, | ||
}; | ||
|
||
unsafe { ShowWindow(hwnd, SW_RESTORE); } | ||
// utils::sleep(1000); | ||
unsafe { SetForegroundWindow(hwnd); } | ||
utils::sleep(1000); | ||
|
||
let rect = utils::get_client_rect(hwnd).unwrap(); | ||
let mut rect = utils::get_client_rect(hwnd).unwrap(); | ||
|
||
// rect.scale(1.25); | ||
info!("detected left: {}", rect.left); | ||
info!("detected top: {}", rect.top); | ||
info!("detected width: {}", rect.width); | ||
info!("detected height: {}", rect.height); | ||
|
||
let mut info: info::ScanInfo; | ||
if rect.height * 16 == rect.width * 9 { | ||
|
@@ -61,7 +84,7 @@ fn main() { | |
utils::error_and_quit("不支持的分辨率"); | ||
} | ||
|
||
let mut scanner = YasScanner::new(info.clone()); | ||
let mut scanner = YasScanner::new(info.clone(), config); | ||
|
||
let now = SystemTime::now(); | ||
let results = scanner.start(); | ||
|
Oops, something went wrong.