Skip to content

Commit

Permalink
Improve docs about camera device names
Browse files Browse the repository at this point in the history
  • Loading branch information
nvtkaszpir committed Jul 13, 2024
1 parent 42e2ae0 commit f07ed5c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/config.for.camera.usb.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ For more details about formats it is better to use

Next, [test config](./test.config.md).

Note: if you have more cameras you probably want to use device by-id or by-path,
see [tuning](./configuration.tuning.md) for more details.

## Real world example

Raspberry Pi Zero W with endoscope camera over USB, registered as `/dev/video1`:
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration.env.full.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Config for camera is to the script as environment variables (env vars).
* `PRINTER_ADDRESS` - Printer address to ping, if address is unreachable there
is no point in sending an image. Set to `127.0.0.1` to always send images.
Set to empty value to disable ping check and always send images.
Default value `127.0.0.1`
Default value `127.0.0.1`.

* `PRUSA_CONNECT_CAMERA_TOKEN` - required, PrusaConnect API key

Expand All @@ -22,6 +22,8 @@ Config for camera is to the script as environment variables (env vars).
* `CAMERA_DEVICE` - camera device to use, if you use Raspberry Pi camera
attached to the CSI via camera ribbon then leave as is
Default `/dev/video0` which points to first detected camera.
If you have more cameras you probably want to use device
by-id or by-path, see [tuning](./configuration.tuning.md) for more details.

* `CAMERA_SETUP_COMMAND` - camera setup command and params executed before
taking image, default value is empty, because some cameras do not support it,
Expand Down
45 changes: 45 additions & 0 deletions docs/configuration.tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,51 @@ Below steps depend on the camera capabilities, thus your mileage may vary.
Notice that Prusa Connect has file size limit something about 8MB of the image uploaded,
so there may be no point in getting images with super high resolutions.

## Using predicable camera device names

Somethimes devices change their id so once given camera is under `/dev/video1`
while another restart and it is under `/dev/video2` and swaps with another one.

If you want to have a predictable camera identifiers then see directory
`/dev/v4l/by-id` or `/dev/v4l/by-path` and choose the one that you prefer

Example on Rasberry Pi with CSI camera and two USB cameras:

```text
pi@hormex:~ $ tree /dev/v4l
/dev/v4l
├── by-id
│   ├── usb-Generic_USB_Camera_200901010001-video-index0 -> ../../video3
│   ├── usb-Generic_USB_Camera_200901010001-video-index1 -> ../../video4
│   ├── usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index0 -> ../../video1
│   └── usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index1 -> ../../video2
└── by-path
├── platform-bcm2835-codec-video-index0 -> ../../video18
├── platform-bcm2835-isp-video-index0 -> ../../video20
├── platform-bcm2835-isp-video-index1 -> ../../video21
├── platform-bcm2835-isp-video-index2 -> ../../video22
├── platform-bcm2835-isp-video-index3 -> ../../video23
├── platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-video-index0 -> ../../video3
├── platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-video-index1 -> ../../video4
├── platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4:1.0-video-index0 -> ../../video1
├── platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4:1.0-video-index1 -> ../../video2
├── platform-fe801000.csi-video-index0 -> ../../video0
└── platform-feb10000.codec-video-index0 -> ../../video19
```

so now if I want to have a Camera-1 always to point to the LifeCam_HD-3000
I can use:

```shell
CAMERA_DEVICE=/dev/v4l/by-id/usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index0
```

and for CSI camera (notice it is not available under `by-id`):

```shell
CAMERA_DEVICE=/dev/v4l/by-path/platform-fe801000.csi-video-index0
```

## Getting higher quality camera images

Use `v4l2-ctl` to get the list of available resolutions that camera provides
Expand Down
3 changes: 3 additions & 0 deletions docs/service.kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ for the content you can use with a [kustomize](https://kustomize.io/).

- deployment possible using for example kustomize

- camera device - if you have more cameras you probably want to use device
by-id or by-path, see [tuning](./configuration.tuning.md) for more details

## Examples

- [deployment-1.yaml](https://github.com/nvtkaszpir/prusa-connect-camera-script/blob/master/k8s/deployment-1.yaml)
Expand Down

0 comments on commit f07ed5c

Please sign in to comment.