API¶
This module implements an interface to a Wunder 360 S1 through Python.
- authors
Athanasios Anastasiou
- date
August 2019
Resource I/O¶
-
class
pywundercam.
SingleResource
(full_remote_filename, metadata=None)¶ A single file resource held in the camera’s disk space.
This can be a single image or video stored on the camera’s SD card.
Note
If you are simply using this package to interface with the camera you do not usually need to instantiate this class directly.
-
property
full_remote_filename
¶ Returns the remote filename as this is found on the camera’s file space.
-
get
()¶ Retrieves a resource from the camera and serves it to the application in the right format.
Warning
As of writing this line, anything other than image/jpeg will raise an exception. To save the resource locally, please see SingleResource.save_to().
-
property
metadata
¶ Returns metadata recovered from a resource’s filename.
Note:
This can be
None
if no named regular expression was passed during initialisation ofResourceContainer
.
-
save_to
(filename=None)¶ Saves a resource to a local path as a binary file.
- Parameters
filename (str(path)) – The local filename to save this file to. If
None
, the original name as found on the camera is used.
-
property
-
class
pywundercam.
SequenceResource
(file_io_uri, file_list)¶ A sequence resource at the camera’s memory space.
Sequence resources are produced by the “Continuous” (or “Burst”) mode and are basically a set of images that were collected after a single “trigger” action. PyWunderCam will serve these as one resource if a filename regular expression and list of group-by attributes are provided.
Note
This is basically a tuple of SingleResource with a convenience get() to retrieve all resources of the sequence.
-
get
()¶ Returns an array of
PIL.Image
images.
-
save_to
(directory=None)¶ Saves an image sequence to a given directory (or the current one if none is provided).
- Parameters
directory (str(path)) – The directory to save the files to.
-
-
class
pywundercam.
ResourceContainer
(file_io_uri, file_re=None, group_by=None, order_by=None)¶ A ResourceContainer represents a list of files that are accessed via an HTTP interface.
Usually, in devices like cameras, scanners, etc, the file name of an image, encodes a number of metadata, such as time, date, sequence number and others. A file_rule is used to parse these metadata. Based on the assumption that sequences of resources would share part of their filename characteristics, it is possible to group resources that are created as a result of a single action. If a “frame” attribute is provided as well, it is also possible to order these resources in the order they were taken.
Camera State¶
-
class
pywundercam.
CamState
(camera_data=None)¶ Represents all data that capture the camera’s state.
The class exposes properties with Pythonic names that are fully documented and ensures that the values that represent the camera’s state are valid throughout their round trip to the hardware and back. This class also handles marshalling between the variable names used by the hardware and their Python counterparts.
-
property
auto_shutdown
¶ Minutes to auto-shutdown. Positive Integer. (Read only).
-
property
battery_grid
¶ Battery charge indicator in an arbitrary scale. Integer [0..6]. (Read only).
Note:
The battery charge indicator on the camera is a 3 bar icon. This indicator goes all the way up to 6.
The property name on the camera has been mispolled (BatterGird).
-
property
charge_flag
¶ Whether the camera’s battery is charging. Bool [0..1]. (Read only).
-
property
exposure_compensation
¶ Exposure compensation in stops. Integer [0..13]. (Read / Write).
Note:
For this setting to be effective the camera must be in Manual Mode (setting_mode=1).
Exposure compensation spans a scale of 13 values (1..13) with 0 being the AUTO setting.
-
property
firmware_software_version
¶ Firmware and software version as returned by the camera. String. (Read only).
-
property
hdmi_connect_flag
¶ Whether the HDMI connector is plugged in. Bool [0..1]. (Read only).
Note:
There is no HDMI connector exposed on the Wunder 360 S1.
-
property
iso
¶ Equivalent ISO in preset values. Integer [0..4]. (Read / Write).
Note:
For this setting to be effective the camera must be in Manual Mode (setting_mode=1).
- The preset values are as follows:
0: AUTO
1: 100
2: 200
3: 400
4: 800
-
property
loop_video_time
¶ Maximum video time in Loop mode in minutes. Integer. (Read only).
-
property
mute
¶ Whether to sound the camera’s buzzer. Bool [0..1]. (Read only).
Note:
This does not seem to be implemented on the Wunder 360 S1. Even if you manage to switch this flag to 0 the buzzer still sounds.
-
property
operations
¶ Returns a list of operations to be sent to the camera hardware so that its state reflects the requested state.
The list is of the format
(command, params)
, wherecommand
is usually an integer and params a dictionary of command specific parameters.command
andparams
are hardware specific.
-
property
product_model
¶ Product model as returned by the camera. String. (Read only).
Note:
This will always be “S1” on this camera.
-
property
remain_num
¶ Remaining number of pictures, given the capacity of the SD card. (Read only).
-
property
remain_time
¶ Remaining time for video recording, given the capacity of the SD card, in minutes. (Read only).
-
property
sd_card_plug_flag
¶ Whether an SD card is plugged in the camera and can be used. Integer [0..2]. (Read only).
Note:
- Values are as follows:
0: No SD card plugged in
1: SD card plugged in (not necessarily readable)
2: SD card plugged in and readable.
-
property
serial_number
¶ Product serial number as returned by the camera. String. (Read only).
-
property
setting_mode
¶ Whether the camera is in manual or automatic mode. Bool [0..1]. (Read / Write).
Note:
The photographic settings (iso, white_balance, exposure_compensation) require the camera to be in manual mode.
-
property
shoot_mode
¶ Determines which shoot mode to trigger. Integer [0..6]. (Read / Write).
Note:
- The shoot modes are as follows:
0: Photo
1: Video (3K)
2: Timer
3: Continuous (Burst)
4: Time-Lapse
5: Video (60 FPS)
6: Loop
To stop video recording, simply re-trigger the camera.
-
property
white_balance_mode
¶ White balance in color temperature presets. Integer [0..4]. (Read / Write).
Note:
For this setting to be effective the camera must be in Manual Mode (setting_mode=1).
- The temperature presets are as follows:
0: AUTO
1: 2856K
2: 4000K
3: 5500K
4: 6500K
-
property
wifi_pass
¶ The camera’s network password. (Read only).
Note:
The default password is 12345678
-
property
wifi_ssid
¶ The SSID of the WiFi interface that the camera advertises. (Read only).
Note:
By default, the SSID is Pano_[Camera-Serial-Number].
-
property
Camera Control¶
-
class
pywundercam.
PyWunderCam
(camera_ip='192.168.100.1')¶ The main client object that communicates with the various services exposed by the camera.
WunderCam handles all hardware requests and data transfers. At the very least, the camera exposes the following services:
An NGINX web server on
camera_ip:80
. (Known here as the “File I/O service”)A
fcgi_client.cgi
script that handles specific commands towards the hardware. (Known here as the “Control Service”)A Real Time Streaming Protocol (RTSP)/Real Data Transport (RDT) service to handle preview video streaming.
Currently, the WunderCam interfaces to the first two services and there are plans to be able to decode individual frames from a stream, at will, in the future.
-
property
camera_ip
¶ Returns the IP that the camera was initialised with.
-
property
camera_state
¶ Prepares and returns the camera state object to the user.
When the object enters the “prepare” state, any variable state changes are logged but NOT applied, until the user resets the state back to the camera. At that point, any changes to the state are unrolled, applied and their effect on the camera logged.
-
get_resources
(img_file_re=re.compile('Img_(?P<year>[0-9][0-9][0-9][0-9])(?P<month>[0-9][0-9])(?P<day>[0-9][0-9])_(?P<hour>[0-9][0-9])(?P<minute>[0-9][0-9])(?P<second>[0-9][0-9])_(?P<frame>[0-9][0-9][0-9])\\.jpg'), vid_file_re=re.compile('Vid_(?P<year>[0-9][0-9][0-9][0-9])(?P<month>[0-9][0-9])(?P<day>[0-9][0-9])_(?P<hour>[0-9][0-9])(?P<minute>[0-9][0-9])(?P<second>[0-9][0-9])_(?P<frame>[0-9][0-9][0-9])\\.mp4'), img_group_by=['year', 'month', 'day', 'hour', 'minute', 'second'], vid_group_by=['year', 'month', 'day', 'hour', 'minute', 'second'], img_order_by='frame')¶ Returns the two resource sets that reside on the camera’s file space. One for images and one for videos.
- Parameters
img_file_re (compiled regexp) – Regular expression to unpack image filename metadata. By default set to the one the Wunder 360 S1 is using.
vid_file_re (compiled regexp) – Similarly to
img_file_re
but for the video resource.img_group_by (list of str) – List of named attributes from
img_file_re
to use in distinguishing sequences from singles.vid_group_by (list of str) – Similarly to
img_group_by
but for video resourcesimg_order_by (str) – Named attribute from the image filename regular expression to be used for ordering sequences.
-
trigger
()¶ Triggers the camera to take an action given its current configuration.
- . autoclass:: PyWunderCamAuto
- members
Constants¶
-
pywundercam.
IMG_FILE_RE
= re.compile('Img_(?P<year>[0-9][0-9][0-9][0-9])(?P<month>[0-9][0-9])(?P<day>[0-9][0-9])_(?P<hour>[0-9][0-9])(?P<minute>[0-9][0-9])(?P<second>[0-9][0-9])_(?P<frame>[0-9][0-9][0-9])\\.jpg')¶ Named regular expression for decoding metadata from the name of an image file. The named attributes of this regular expression are preserved along with a file resource as metadata.
-
pywundercam.
VID_FILE_RE
= re.compile('Vid_(?P<year>[0-9][0-9][0-9][0-9])(?P<month>[0-9][0-9])(?P<day>[0-9][0-9])_(?P<hour>[0-9][0-9])(?P<minute>[0-9][0-9])(?P<second>[0-9][0-9])_(?P<frame>[0-9][0-9][0-9])\\.mp4')¶ Named regular expression for decoding metadata from the name of a video file. The named attributes of this regular expression are preserved along with a file resource as metadata.
-
pywundercam.
IMG_GROUP_BY
= ['year', 'month', 'day', 'hour', 'minute', 'second']¶ Attributes to group sets of images by. Images that are shot in quick succession (for example, in “Continuous” (or “Burst”) mode). In that case, the images can be grouped by same values in these attributes.
-
pywundercam.
VID_GROUP_BY
= ['year', 'month', 'day', 'hour', 'minute', 'second']¶ Similar to
IMG_GROUP_BY
but for videos.
-
pywundercam.
IMG_ORDER_BY
= 'frame'¶ Attribute to order image sequences by. This refers to a field of the metadata regular expressions.
-
pywundercam.
VID_GROUP_BY
= ['year', 'month', 'day', 'hour', 'minute', 'second'] Similar to
IMG_GROUP_BY
but for videos.
Exceptions¶
This module describes the full exception hierarchy for all possible errors raised by PyWunderCam.
- authors
Athanasios Anastasiou
- date
September 2019
-
exception
pywundercam.exceptions.
PyWunderCamCameraNotFoundError
¶ Raised when the camera hardware is unresponsive at the specified IP
-
exception
pywundercam.exceptions.
PyWunderCamConnectionError
¶ Raised when a connection error is encountered during a data request to the camera.
-
exception
pywundercam.exceptions.
PyWunderCamContentTypeError
¶ Raised when a resource’s content type cannot be handled.
In the current version of PyWunderCam, this exception is thrown if the content-type of a file transfer is other than image/jpeg.
-
exception
pywundercam.exceptions.
PyWunderCamDataTransferError
¶ Raised when a data transfer error occurs.
For example, in case the request was met with an HTTP404 error.
-
exception
pywundercam.exceptions.
PyWunderCamError
¶ Base class for all exceptions originating from the pywundercam module.
-
exception
pywundercam.exceptions.
PyWunderCamFileIOError
¶ Base class for errors raised during file transfer
-
exception
pywundercam.exceptions.
PyWunderCamSDCardUnusable
¶ Raised when the SD card is either not plugged in or is not formatted.
-
exception
pywundercam.exceptions.
PyWunderCamStateError
¶ Base class for camera state related errors.
-
exception
pywundercam.exceptions.
PyWunderCamTimeOutError
¶ Raised when a data transfer time out occurs.
-
exception
pywundercam.exceptions.
PyWunderCamValueError
¶ Raised when an attempt is made to set a state variable to an invalid value.