Skip to content

Commit

Permalink
Docs about fixing camera issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nvtkaszpir committed Jul 7, 2024
1 parent 1031050 commit 09343b1
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 1 deletion.
14 changes: 14 additions & 0 deletions docs/config.for.camera.usb.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,17 @@ CAMERA_COMMAND=fswebcam
CAMERA_COMMAND_EXTRA_PARAMS="--resolution 1280x960 --no-banner"
```
<!-- markdownlint-enable line_length -->

Microsoft LifeCam HD-3000, USB, to avoid image capture tearing we skip first 10
frames `-S 10` which also helps to set up proper auto exposure and white balance.

<!-- markdownlint-disable line_length -->
```shell
PRINTER_ADDRESS=192.168.1.25
PRUSA_CONNECT_CAMERA_TOKEN=redacted
PRUSA_CONNECT_CAMERA_FINGERPRINT=7054ba85-bc19-4eb9-badc-6129575d9651
CAMERA_DEVICE=/dev/video4
CAMERA_COMMAND=fswebcam
CAMERA_COMMAND_EXTRA_PARAMS="-S 10 --resolution 1280x720 --no-banner -s auto_exposure=1,brightness=128,contrast=5"
```
<!-- markdownlint-enable line_length -->
58 changes: 57 additions & 1 deletion docs/configuration.tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@ Get device capabilities, especially `User controls`:
v4l2-ctl -d /dev/video0 -l
```

and set accordingly parameters you want in `CAMERA_SETUP_COMMAND` env var, for example:
Those params can be passed in various ways, depending on the requirement:

* `CAMERA_COMMAND_EXTRA_PARAMS` emv var, when using given tool directly
* `CAMERA_SETUP_COMMAND` env var for some complex use cases
* other (probably directly via v4l when using ffmpeg, not tested)

and set accordingly parameters you want , you just need to pass them fswebcam,
for example:

`CAMERA_COMMAND_EXTRA_PARAMS=--resolution 1280x960 --no-banner -s auto_exposure=1,brightness=128,contrast=5`

For more advanced options see `CAMERA_SETUP_COMMAND` env var, for example:

```shell
CAMERA_SETUP_COMMAND="v4l2-ctl --set-ctrl brightness=64,gamma=300 -d $CAMERA_DEVICE"
Expand All @@ -102,6 +113,43 @@ remember to restart given camera service.

You can try to use `guvcview` desktop application to check prams in realtime.

## Image issues

If your captured image has below issues:

* the whole image is too dark or too bright and it changes with every capture
so it get too dark or too bright in a matter of minutes:
![image.artifacts.dark](./static/image.artifacts.dark.jpg)
![image.artifacts.normal](./static/image.artifacts.normal.jpg)
![image.artifacts.bright](./static/image.artifacts.bright.jpg)

* has some horizontal/vertical super bright/dark areas:
![image.artifacts.0](./static/image.artifacts.0.jpg)
![image.artifacts.1](./static/image.artifacts.1.jpg)

* some visible artifacts such as colored blocks or missing image fragments:
![image.artifacts.2](./static/image.artifacts.2.jpg)
![image.artifacts.3](./static/image.artifacts.3.jpg)
![image.artifacts.4](./static/image.artifacts.4.jpg)

then you may need to initialize camera and capture it with a delay
or drop initial number of frames.

Notice that sometimes you cannot do much about it (remote cams) because some
camera images will be broken anyway, then I suggest changing camera.

### Dropping frames

Usually this is the fastest and with `fswebcam` it can be achieved by passing `-S`
param, for example

`-S 10` will skip 10 first frames.

### Delay

`fswebcam` param `-d 2` will delay capture for 2 seconds, for some cameras it may
help.

## Image flip and rotation

You can pass on params to rpicam-still or fswebcam as you want.
Expand Down Expand Up @@ -141,6 +189,14 @@ CAMERA_COMMAND=fswebcam
CAMERA_COMMAND_EXTRA_PARAMS="--flip v --resolution 640x480 --no-banner"
```

or to skip first 10 frames (`-S 10`, helps to get proper auto white balance and
image exposure) and pass on camera controls:

```shell
CAMERA_COMMAND=fswebcam
CAMERA_COMMAND_EXTRA_PARAMS="-S 10 --resolution 1280x720 --no-banner -s auto_exposure=1,brightness=128,contrast=5"
```

## ffmpeg

When curl is not enough and you don't really want to physically rotate your camera,
Expand Down
Binary file modified docs/static/esp32-camera.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.bright.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/image.artifacts.normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/static/pi-camera.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 09343b1

Please sign in to comment.