class platypush.plugins.qrcode.QrcodePlugin(camera_plugin: Optional[str] = None, **kwargs)[source]

Plugin to generate and scan QR and bar codes.


  • numpy (pip install numpy).
  • qrcode (pip install 'qrcode[pil]') for QR generation.
  • pyzbar (pip install pyzbar) for decoding code from images.
  • Pillow (pip install Pillow) for image management.
__init__(camera_plugin: Optional[str] = None, **kwargs)[source]
Parameters:camera_plugin – Name of the plugin that will be used as a camera to capture images (e.g. camera or camera.pi).
decode(image_file: str) → platypush.message.response.qrcode.QrcodeDecodedResponse[source]

Decode a QR code from an image file.

Parameters:image_file – Path of the image file.
generate(content: str, output_file: Optional[str] = None, show: bool = False, format: str = 'png', camera_plugin: Optional[str] = None) → platypush.message.response.qrcode.QrcodeGeneratedResponse[source]

Generate a QR code. If you configured the platypush.backend.http.HttpBackend then you can also generate codes directly from the browser through http://<host>:<port>/qrcode?content=....

  • content – Text, URL or content of the QR code.
  • output_file – If set then the QR code will be exported in the specified image file. Otherwise, a base64-encoded representation of its binary content will be returned in the response as data.
  • show – If True, and if the device where the application runs has an active display, then the generated QR code will be shown on display.
  • format – Output image format (default: png).
  • camera_plugin – If set then this plugin (e.g. camera or camera.pi) will be used to capture live images from the camera and search for bar codes or QR-codes.


start_scanning(camera_plugin: Optional[str] = None, duration: Optional[float] = None, n_codes: Optional[int] = None) → Optional[List[platypush.message.response.qrcode.ResultModel]][source]

Decode QR-codes and bar codes using a camera.


  • camera_plugin – Camera plugin (overrides default camera_plugin).
  • duration – How long the capturing phase should run (default: until stop_scanning or app termination).
  • n_codes – Stop after decoding this number of codes (default: None).

When duration or n_codes are specified or stop_scanning is called, it will return a list of platypush.message.response.qrcode.ResultModel instances with the scanned results,