|
2 | 2 |
|
3 | 3 | [](https://www.mathworks.com/matlabcentral/fileexchange/48428-cosbos-color-sensor-based-occupancy-sensing) |
4 | 4 | [](https://github.com/wq2012/COSBOS/actions/workflows/octave.yml) |
| 5 | +[](https://github.com/wq2012/COSBOS/actions/workflows/python.yml) |
5 | 6 |
|
6 | 7 |  |
7 | 8 |
|
@@ -89,6 +90,51 @@ run_tests; |
89 | 90 | ``` |
90 | 91 | This verifies LTM recovery accuracy, MEX script correctness, and model performance. |
91 | 92 |
|
| 93 | +## Python Package |
| 94 | + |
| 95 | +COSBOS is also available as a Python package `cosbos`. It provides pure Python implementations of the core algorithms (Reflection Model, Blockage Model, LTM Recovery). |
| 96 | + |
| 97 | +### Installation |
| 98 | + |
| 99 | +```bash |
| 100 | +pip install cosbos |
| 101 | +``` |
| 102 | + |
| 103 | +### Usage |
| 104 | + |
| 105 | +```python |
| 106 | +from cosbos import reflection, blockage, ltm |
| 107 | +import numpy as np |
| 108 | + |
| 109 | +# Reflection Model |
| 110 | +# Calculate reflection kernel for a light-sensor pair |
| 111 | +# light: [x, y, z], sensor: [x, y, z], dim: [dx, dy, dz] |
| 112 | +K = reflection.getReflectionKernel(light=[75, 22.5, 86.4], |
| 113 | + sensor=[66, 22, 86.4], |
| 114 | + dim=[87, 136, 88], |
| 115 | + para=1) |
| 116 | + |
| 117 | +# Blockage Model |
| 118 | +# Hash Gaussians for occupancy volume |
| 119 | +# sensors: [N, 3], lights: [M, 3] |
| 120 | +H = blockage.hashGaussians(sensors, lights, dim, sigma=2.0) |
| 121 | +# Reconstruct volume |
| 122 | +V = blockage.volumeFromHashing(sensors, lights, dim, H, E) |
| 123 | + |
| 124 | +# LTM Recovery |
| 125 | +# Recover matrix A from measurements Y and training data X |
| 126 | +# X: [m, N], Y: [l, N] (m: features, l: sensors, N: samples) |
| 127 | +A = ltm.solve_A_1norm(X, Y) |
| 128 | +``` |
| 129 | + |
| 130 | +### Development |
| 131 | +To run tests locally: |
| 132 | +```bash |
| 133 | +cd python |
| 134 | +pip install -e . |
| 135 | +pytest tests/ |
| 136 | +``` |
| 137 | + |
92 | 138 | ## Citation |
93 | 139 | If you use this work in your research, please cite: |
94 | 140 |
|
|
0 commit comments