actfw package

Submodules

actfw.application module

class actfw.application.Application

Bases: object

Actcast Application

get_settings(default_settings)

Get given Act settings.

Parameters

default_settings (dict) – default settings

Returns

updated settings

Return type

dict

Notes

Copy default_settings and overwrite it by given Act settings.

register_task(task)

Register the application task.

Parameters

task (Task) – task

run()

Start application

actfw.capture module

class actfw.capture.Frame(value)

Bases: object

Captured Frame

getvalue()

Get frame data.

Returns

captured image data

Return type

bytes

class actfw.capture.PiCameraCapture(camera, *args, **kwargs)

Bases: actfw.task.producer.Producer

Captured Frame Producer for Raspberry Pi Camera Module

Parameters

camera (PiCamera) – picamera object

run()

Run producer activity

class actfw.capture.V4LCameraCapture(device='/dev/video0', size=(640, 480), framerate=30, expected_format=<V4L2_PIX_FMT.RGB24: 859981650>, fallback_formats=[<V4L2_PIX_FMT.YUYV: 1448695129>, <V4L2_PIX_FMT.MJPEG: 1196444237>], format_selector=<FormatSelector.DEFAULT: 1>)

Bases: actfw.task.producer.Producer

Parameters
  • device (str) – v4l device path

  • size (int, int) – expected capture resolution

  • framerate (int) – expected capture framerate

  • expected_format (V4L2_PIX_FMT) – expected capture format

  • fallback_formats (list of V4L2_PIX_FMT) – fallback capture format

Notes

If a camera doesn’t support the expected_format, try to capture one of the fallback_formats and convert it to expected_format.

class FormatSelector(value)

Bases: enum.Enum

Captured Frame Producer for Video4Linux

DEFAULT = 1
PROPER = 2
capture_size()

Get configured capture resolution. A configured resolution may be more larger than expected one.

Returns

configured capture resolution (width, height)

Return type

(int, int)

configure(configurator)

Run user defined video configurator.

Parameters

configurator – unary function (actfw.v4l2.video.Video -> a)

Returns

return type of configurator

Return type

object

run()

Run producer activity

actfw.command_server module

class actfw.command_server.CommandServer(sock_path=None)

Bases: actfw.task.isolated.Isolated

Actcast Command Server

This server handles these commands

  • ‘Take Photo’
    • responses cached image as png data

run()

Run and start the activity

stop()

Stop the activity

update_image(image)

Update the cached ‘Take Photo’ command image.

Parameters

image (Image) – image

actfw.display module

class actfw.display.Display(camera, size)

Bases: object

Display using PiCamera Overlay

Parameters
  • camera (PiCamera) – picamera object

  • size (int, int) – display area resolution

update(dst_rect, src_buf, src_size, src_format)

Update display.

Parameters
  • dst_rect (int, int, int, int) – destination area rectangle (left, upper, width, height)

  • src_buf (bytes) – update image data buffer

  • src_size (int, int) – update image data size (width, height)

  • src_format (string) – “rgb”

actfw.edid module

class actfw.edid.EDID

Bases: object

Extended Display Information Data

prefferd_mode()

Preffered Display Resolution.

Returns

(width, height)

Return type

(int, int)

Module contents

actfw.heartbeat(*args, **kwargs)

Execute heartbeat action.

Notes

Default action is ‘touch /root/heartbeat’.

actfw.notify(notification, *args, **kwargs)

Make a notification to Actcast.

Parameters

notification (list of dict) – dicts must be encodable to JSON.

Example

>>> import actfw
>>> actfw.notify([{'msg': 'Hello!'}])
[{"msg": "Hello!"}]
actfw.set_heartbeat_function(f)

Set heartbeat action.

Parameters

f (function) – function which execute heartbeat action

Example

>>> import actfw
>>> def heartbeat(): print("working!")
...
>>> actfw.set_heartbeat_function(heartbeat)
>>> actfw.heartbeat()
working!