-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
farm_ng_amiga
examples/tutorial (#190)
* update camera client * update the calibration readme * update camera settings example * add the camera to pointcloud example * minor updates to the file readers * add service client tutorial * remove people detection * add the service_counter tutorial * add the service propagation example * Update motor state stream example * Add vehicle twist example * Formatting & some typos * Rename so examples are all README (helps w/ links) * Update examples sidebar --------- Co-authored-by: Kyle Coble <[email protected]>
- Loading branch information
1 parent
75c75c7
commit e8322f5
Showing
16 changed files
with
1,246 additions
and
312 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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
id: camera-calibration | ||
title: Camera Calibration | ||
--- | ||
|
||
## Camera Calibration | ||
|
||
The requirements to run this example are to have a | ||
[**farm-ng brain**](/docs/brain/) running Oak cameras and that | ||
your PC is on the same local network as the brain. | ||
|
||
### 1. Install the [farm-ng Brain ADK package](/docs/brain/brain-install) | ||
|
||
### 2. Setup | ||
|
||
:::tip | ||
|
||
It is recommended to also install these dependencies and run the | ||
example in the brain ADK virtual environment. | ||
|
||
::: | ||
|
||
Create first a virtual environment | ||
|
||
```bash | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
``` | ||
|
||
```bash | ||
# assuming you're already in the amiga-dev-kit/ directory | ||
cd farm-ng-amiga/py/examples/camera_calibration | ||
``` | ||
|
||
### 3. Install the example's dependencies | ||
|
||
```bash | ||
pip3 install -r requirements.txt | ||
``` | ||
|
||
### 4. Execute the Python script | ||
|
||
```bash | ||
python3 main.py --service-config service_config.json | ||
``` | ||
|
||
:::info | ||
By default, the camera address is assumed top be `localhost`. | ||
::: | ||
|
||
### 5. Customize run | ||
|
||
```bash | ||
# usage: amiga-camera-calibration [-h] --service-config SERVICE_CONFIG | ||
# | ||
# optional arguments: | ||
# -h, --help show this help message and exit | ||
# --service-config SERVICE_CONFIG | ||
# The camera config. | ||
``` | ||
|
||
### 6. Code overview | ||
|
||
In this example we use the `EventClient` with the `request_reply` | ||
method to receive the camera camera calibration. | ||
The `request_reply` method is a coroutine that returns a `Future` object. | ||
The `Future` object is used to retrieve the result of the request. | ||
|
||
The path to the calibration service is `/calibration` and the request message is `Empty`. | ||
The response message is `OakCalibration`, which is automatically decoded by the `request_reply` | ||
method using the `decode=True` argument. | ||
|
||
```python | ||
async def main(service_config_path: Path) -> None: | ||
"""Request the camera calibration from the camera service. | ||
Args: | ||
service_config_path (Path): The path to the camera service config. | ||
""" | ||
# create a client to the camera service | ||
config: EventServiceConfig = proto_from_json_file(service_config_path, EventServiceConfig()) | ||
|
||
# get the calibration message | ||
calibration: oak_pb2.OakCalibration = | ||
await EventClient(config).request_reply("/calibration", Empty(), decode=True) | ||
print(calibration) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(prog="amiga-camera-calibration") | ||
parser.add_argument("--service-config", type=Path, required=True, help="The camera config.") | ||
args = parser.parse_args() | ||
|
||
asyncio.run(main(args.service_config)) | ||
``` | ||
|
||
:::tip | ||
We highly recommend to have some basic knowledge about | ||
[**`asyncio`**](https://docs.python.org/3/library/asyncio.html). | ||
::: |
74 changes: 0 additions & 74 deletions
74
website/docs/examples/camera_calibration/camera-calibration.md
This file was deleted.
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
Oops, something went wrong.