rpi_fb_capture v0.3.0 RpiFbCapture View Source

Capture the Raspberry Pi's frame buffer

Link to this section Summary

Functions

Return the name of the active capture backend

Capture the screen in the specified format.

Returns a specification to start this module under a supervisor.

Helper method for saving a screen capture to a file

Set dithering algorithm.

Adjust the value that pixels are on for monochromatic conversion.

Start up the capture process

Stop the capture process

Link to this section Types

Link to this type

dithering()

View Source
dithering() :: :none | :floyd_steinberg | :sierra | :sierra_2row | :sierra_lite
Link to this type

format()

View Source
format() :: :ppm | :rgb24 | :rgb565 | :mono | :mono_column_scan
Link to this type

option()

View Source
option() ::
  {:width, non_neg_integer()}
  | {:height, non_neg_integer()}
  | {:display, non_neg_integer()}

Link to this section Functions

Return the name of the active capture backend

Example backend names:

  • "sim" for the simulator
  • "dispmanx" for the Raspberry Pi
  • "unknown" if the backend hasn't reported its name
Link to this function

capture(server, format)

View Source
capture(GenServer.server(), format()) ::
  {:ok, RpiFbCapture.Capture.t()} | {:error, atom()}

Capture the screen in the specified format.

Formats include:

  • :ppm - PPM-formatted data
  • :rgb24 - Raw 24-bit RGB data 8-bits R, G, then B
  • :rgb565 - Raw 16-bit data 5-bits R, 6-bits G, 5-bits B
  • :mono - Raw 1-bpp data
  • :mono_column_scan - Raw 1-bpp data, but scanned down columns

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

save(server, path, format \\ :ppm)

View Source
save(GenServer.server(), Path.t(), format()) :: :ok | {:error, atom()}

Helper method for saving a screen capture to a file

Example:

iex> {:ok, cap} = RpiFbCapture.start_link()
iex> RpiRbCapture(cap, "/tmp/capture.ppm")
:ok
Link to this function

set_dithering(server, algorithm)

View Source
set_dithering(GenServer.server(), dithering()) :: :ok | {:error, atom()}

Set dithering algorithm.

Algorithms include:

  • :none - No dithering applied
  • :floyd_steinberg - Floyd–Steinberg
  • :sierra - Sierra (also called Sierra-3)
  • :sierra_2row - Two-row Sierra
  • :sierra_lite - Sierra Lite
Link to this function

set_mono_threshold(server, threshold)

View Source
set_mono_threshold(GenServer.server(), byte()) :: :ok | {:error, atom()}

Adjust the value that pixels are on for monochromatic conversion.

The threshold should be 8-bits. The capture buffer is rgb565, so the threshold will be reduced to 5 or 6 bits for the actual comparisons.

Link to this function

start_link(args \\ [])

View Source
start_link([option()]) :: :ignore | {:error, any()} | {:ok, pid()}

Start up the capture process

NOTE: The Raspberry Pi capture hardware has limitations on the window size. In general, capturing the whole display is fine. Keeping the width as a multiple of 16 appears to be good.

Options:

  • :width - the width of the capture window (0 for the display width)
  • :height - the height of the capture window (0 for the display width)
  • :display - which display to capture (defaults to 0)

Stop the capture process