An open API service indexing awesome lists of open source software.

https://github.com/jose-elias-alvarez/flybox-scanner


https://github.com/jose-elias-alvarez/flybox-scanner

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# flybox-scanner

## Setup

First, make sure [Anaconda](https://www.anaconda.com) is installed.

Then, navigate to the project directory and run the following commands:

```sh
conda create --prefix .conda python=3.11
conda activate ./.conda
```

This will create a new environment in the current directory and activate it.

You'll then need to install the project's dependencies:

```sh
conda install --file requirements.txt
```

### Direnv (optional)

You can streamline activation by setting up [direnv](https://direnv.net/), which will automatically activate and deactivate the environment as needed.

### Start

If needed, activate the environment:

```sh
conda activate ./.conda
```

Then, run the script:

```sh
python main.py
```

### Uninstall

To uninstall the environment, run the following command:

```sh
conda env remove --name flybox-scanner
```

## Parameters

### Motion Detection

To tune motion detection parameters, run the following command:

```sh
python main.py --tuning=motion
```

Once you've found a set of parameters that works well, you can save them to `settings.json` using the `Save` button in the UI. The parameters will then be loaded automatically on subsequent runs.

### Other Parameters

Other parameters are currently hard-coded into the following Python source files and must be edited manually:

- `main.py`: controls source and window parameters

### Detection

- `detection/border.py`: controls the detection of borders in frames (used to "crop" the flybox background)
- `detection/grids.py`: controls the detection of wells

### Handlers

- `handlers/debug.py`: controls the display of debug info in the recording window (e.g. wells, flies)
- `handlers/file_interval.py`: controls the output of data into a file at a given interval
- `handlers/frame.py`: controls the handling of detected motion and its conversion into motion events

## Development

### Architecture

UI logic lives in `components/`. The main UI entrypoint is `components/root_window.py`, which is responsible for the main event loop and for mounting and unmounting "state canvases".

Each state canvas is responsible for a specific UI state, as defined in `components/state_manager.py`:

- `components/idle_canvas.py`: initial state, displays a source preview and state transition buttons
- `components/select_webcam_canvas.py`: active when selecting a webcam source
- `components/scan_canvas.py`: active when "scanning" (running grid detection on) the source, allows transitioning to the recording state
- `components/record_canvas.py`: active when recording, shows a (hideable) preview

### Videos

Note that video output is not yet optimized and may differ from webcam output.

- [Fly.mp4](https://drive.google.com/file/d/1q6RSJJIWKrrxvLqLVuanaOrmj1ull6yN/view?usp=share_link)
- [DoubleFly.mp4](https://drive.google.com/file/d/1jw3vVR3u8bQfJR4toDuorEAYqEPXu1Qc/view?usp=share_link)

### Tests

Tests are written using `unittest` and live in the `tests/` directory. To run them, use the following command:

```sh
python -m unittest discover tests/
```

### VS Code

#### Tasks

The repository contains a `Run` task to run `main.py`. To use it, open the command palette and select `Tasks: Run Task`. Then, select `Run`.

#### Interpreter

Upon creating the new environment, VS Code should prompt you to use it for the current workspace. If not, use the `Python: Select Interpreter` command to select the interpreter at `./env/bin/python.`