Skip to content

Commit 4fdfe3d

Browse files
committed
Add asset bootstrap script and base64 encoded assets
1 parent d0e181c commit 4fdfe3d

7 files changed

Lines changed: 67 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Generated binary assets
2+
app/
3+
__pycache__/

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
# DroneDetectAndroid
12

3+
This repo hosts Android-side utilities for drone rotor detection.
4+
Binary assets (TensorFlow Lite model and icons) are stored in base64 to
5+
keep the repo lean for air-gapped deployments.
6+
7+
## Bootstrap
8+
9+
After cloning, restore the binary assets:
10+
11+
```bash
12+
python3 scripts/bootstrap_assets.py
13+
```
14+
15+
This will recreate the `rotor_v1.tflite` model and the required PNG
16+
drawables under `app/src/main/...`.

USAGE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Usage
2+
3+
1. Clone the repository.
4+
2. Restore binary assets:
5+
6+
```bash
7+
python3 scripts/bootstrap_assets.py
8+
```
9+
3. Open the Android project in Android Studio or your preferred build
10+
system. The script will have populated `app/src/main/assets` and
11+
`app/src/main/res/drawable`.

assets/drone_icon.png.b64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC

assets/radar_icon.png.b64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC

assets/rotor_v1.tflite.b64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cm90b3IgbW9kZWwgcGxhY2Vob2xkZXI=

scripts/bootstrap_assets.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
"""Decode base64-encoded assets into their binary forms.
3+
4+
Designed for air-gapped setups: keeps repository text-only and restores
5+
binary assets locally. Currently handles rotor model and PNG icons.
6+
"""
7+
import base64
8+
from pathlib import Path
9+
10+
ROOT = Path(__file__).resolve().parent.parent
11+
ASSET_SRC = ROOT / 'assets'
12+
MODEL_DST = ROOT / 'app' / 'src' / 'main' / 'assets'
13+
DRAWABLE_DST = ROOT / 'app' / 'src' / 'main' / 'res' / 'drawable'
14+
15+
16+
def decode_file(src: Path, dst: Path) -> None:
17+
data = base64.b64decode(src.read_text())
18+
dst.parent.mkdir(parents=True, exist_ok=True)
19+
dst.write_bytes(data)
20+
print(f"decoded {src} -> {dst}")
21+
22+
23+
def main() -> None:
24+
# Model
25+
model_b64 = ASSET_SRC / 'rotor_v1.tflite.b64'
26+
if model_b64.exists():
27+
decode_file(model_b64, MODEL_DST / 'rotor_v1.tflite')
28+
# PNG assets
29+
for b64_file in ASSET_SRC.glob('*.png.b64'):
30+
out_name = b64_file.name[:-4] # strip .b64
31+
decode_file(b64_file, DRAWABLE_DST / out_name)
32+
33+
34+
if __name__ == '__main__':
35+
main()

0 commit comments

Comments
 (0)