This document will show how to use `dev_tools/item_statistics.py`
## Enable statistics in alas
In alas GUI,
- set `enable_drop_screenshot` to `yes`, if enabled, alas will add a 1s sleep before screenshot, to avoid capture the flash. There's a flash light when item shows up.
- set `drop_screenshot_folder` to be the folder you want to save. It is recommended to save it in SSD.
After few hours or few days of running, you will get a folder structure like:
```
<your_folder>
campaign_7_2
get_items
158323xxxxxxx.png
158323xxxxxxx.png
158323xxxxxxx.png
get_mission
get_ship
mystery
status
campaign_10_4_HARD
get_items
get_mission
get_ship
status
d3
get_items
get_mission
get_ship
status
```
Screenshot are named after millesecond timestamp.
## Prepare a new environment
- Prepare another virtual environment, accoring to `requirements.txt`. But use the GPU version of `mxnet`.
I am using GTX1080Ti, and I installed `mxnet-cu80==1.4.1`, `CUDA8.0`, `cuDNN`. Google `mxnet gpu install`, and see how to do in details. You may intall other version of CUDA, and mxnet for that CUDA, because you are using another graphic card.
- Look for the cnocr in your virtual environment. Replace site-packages\cnocr\cn_ocr.py line 89
```
mod = mx.mod.Module(symbol=sym, context=mx.cpu(), data_names=data_names, label_names=None)
```
to be:
```
mod = mx.mod.Module(symbol=sym, context=mx.gpu(), data_names=data_names, label_names=None)
```
Now cnocr will run on GPU.
You can skip these anyway, and use the same environment as alas, but the OCR will run really slow.
- Install tqdm, a package to show progressbar.
```
pip install tqdm
```
## Extract item_template
Copy folder `dev_tools\item_template` to the map folder such as `<your_folder>\campaign_7_2`.
Change the folder in line 24
These template are named in chinese, rename them in English.
>**How to a name template image**
>
>You should use their full name, such as "138.6mm单装炮Mle1929T3", instead of short name or nickname, such as "DD_gun".
>
>If you have same item with different image, use names like `torpedo_part.png`, `torpedo_part_2.png`, they will a classified as torpedo_part
Uncomment the part for item extract in dev_tools/item_statistics.py, and run, you will have some new item templates. Here's an example log:
```
1%| | 107/12668 [00:05<10:24, 20.10it/s]2020-06-03 10:39:42.609 | INFO | New item template: 50
1%| | 158/12668 [00:07<10:42, 19.47it/s]2020-06-03 10:39:45.098 | INFO | New item template: 51
2%|▏ | 207/12668 [00:10<10:33, 19.66it/s]2020-06-03 10:39:47.772 | INFO | New item template: 52
2%|▏ | 215/12668 [00:10<11:20, 18.29it/s]2020-06-03 10:39:48.304 | INFO | New item template: 53
You can open it in Excel or load it into database.
## Improvement
These code is running on single thread, you can try adding multiprocess to speed up. I didn't do that because it's still acceptable (20it/s without ocr, 12it/s with ocr)