asi_core.daq.url_image_receiver

Tool for the ASI image data acquisition

Attributes

EXIF_KEYS

defined by the exif metadata convention, see e.g. https://exiftool.org/TagNames/EXIF.html

KNOWN_MOBOTIX_MODELS

Mobotix camera models which are known to be compatible with the data acquisition

detected_local_tz

Classes

ImageReceiver

Handles the image acquisition of an IP camera with http-API.

SeriesReceiver

Defines the acquisition of image series with different exposure times.

AxisSeriesReceiver

Handles the acquisition of image series with an AXIS camera.

MobotixSeriesReceiver

Handles the acquisition of image series with a Mobotix camera.

Functions

main()

Parse cmd line arguments and run data acquisition

Module Contents

asi_core.daq.url_image_receiver.EXIF_KEYS

defined by the exif metadata convention, see e.g. https://exiftool.org/TagNames/EXIF.html

asi_core.daq.url_image_receiver.KNOWN_MOBOTIX_MODELS = ['Q71', 'Q26', 'Q25', 'Q24']

Mobotix camera models which are known to be compatible with the data acquisition

asi_core.daq.url_image_receiver.detected_local_tz = None
class asi_core.daq.url_image_receiver.ImageReceiver(url_snapshot, storage_path, location, sampling_time=timedelta(seconds=15), night_sampling_time=timedelta(seconds=60), timezone_images=detected_local_tz)

Handles the image acquisition of an IP camera with http-API.

Parameters:
  • url_snapshot – str, URL which is sent to camera to get a snapshot

  • storage_path – path to which image series will be stored; folders for month, day, hour will be created

  • location – dict, with fields indicating coordinates: “lat” (decimal degrees, northing positive), “lon” (decimal degrees, easting positive), “alt” (meters)

  • sampling_time – datetime timedelta – temporal offset between image series

  • night_sampling_time – datetime timedelta – temporal offset between image series during nighttime

  • timezone_images – Specify pytz.timezone of the images and log file. If not provided computer timezone is used.

min_sun_ele_exp = 0
max_sun_ele_exp = 90
min_moon_ele = 10
min_moon_phase = 0.8
url_snapshot
storage_path
sampling_time
location
timezone_images
day_sampling_time
night_sampling_time
record_night_image = False
midnight = None
ephem_observer
url_get_snapshot()

Sends a URL request and extract binary JPEG from response

Returns:

Binary encoded JPEG image

store_img_to_path(ts, img, exp_time=0)

Stores an image record in the folder structure according to the convention below

Parameters:
  • ts – datetime, timestamp at which the image was taken

  • img – binary encoded image (jpg)

  • exp_time – int, exposure time of the image (microseconds)

record_continuously()

Once called, this function runs infinitely taking images at the defined sampling rate

trigger_store_exposure()

Triggers, receives and saves a snapshot from the camera.

Exposure time etc. remain unchanged. Only a snapshot is requested and saved

prepare_image_acquisition()

Prepare image acquisition.

Check if conditions for recording images are met. Either for standard daylight images (depending on sun elevation) or nighttime images when there is (almost) full moon and the moon is above the horizon.

Returns:

Boolean whether image should be recorded.

class asi_core.daq.url_image_receiver.SeriesReceiver(url_cam, storage_path, location, sampling_time=timedelta(seconds=15), night_sampling_time=timedelta(seconds=60), exposure_times=[80, 160, 320, 640, 1280], night_exposure_times=[80000], settling_time=timedelta(seconds=0.25), timezone_images=detected_local_tz, rel_threshold_exposure=0.1, safety_deadtime_between_exposure_series=timedelta(seconds=3))

Bases: ImageReceiver

Defines the acquisition of image series with different exposure times.

Parameters:
  • url_cam – URL/ IP of the camera to be controlled

  • storage_path – see ImageReceiver

  • location – see ImageReceiver

  • sampling_time – see ImageReceiver

  • night_sampling_time – timedelta, sampling time used during nighttime

  • exposure_times – list, exposure times in microseconds. One snapshot per exp. time will be stored

  • settling_time – Time to wait until requesting an image from camera after setting new exposure time or after previous request

  • timezone_images – see ImageReceiver

  • rel_threshold_exposure – Relative deviation of exp. time. Image will be rejected if real exp. time deviates stronger from expected value

  • safety_deadtime_between_exposure_series – Cancel acquisition of exposure series if less than this time remains until end of sampling period

exposure_times = [80, 160, 320, 640, 1280]
night_exposure_times = [80000]
url_cam
settling_time
rel_threshold_exposure = 0.1
safety_deadtime_between_exposure_series
abstractmethod set_exposure(exp_set)

” Request camera to change exposure time

Parameters:

exp_set – Exposure time in microseconds

trigger_store_exposure()

Records an image series with different exposure times

static get_real_exposure(img)

Checks the exposure time noted in the EXIF header.

Parameters:

img – Binary encoded jpeg image with EXIF header that contains actual exposure time

Returns exp:

int, read exposure time in microseconds

class asi_core.daq.url_image_receiver.AxisSeriesReceiver(url_cam, storage_path, location, user, password, **kwargs)

Bases: SeriesReceiver

Handles the acquisition of image series with an AXIS camera.

Parameters:
  • url_cam – see SeriesReceiver

  • storage_path – see ImageReceiver

  • location – see ImageReceiver

  • user – name of user authorized to set exposure parameters

  • password – password of user

  • sampling_time – see ImageReceiver

  • exposure_times – see SeriesReceiver

  • settling_time – see SeriesReceiver

  • user – name of user authorized to set exposure parameters

  • password – password of user

command_record = 'jpg/image.jpg?camera=1&overview=0&resolution=2016x2016&videoframeskipmode=empty&timestamp=166279...
authentication
set_exposure(exp_set)

” Request camera to change exposure time

Parameters:

exp_set – Exposure time in microseconds

class asi_core.daq.url_image_receiver.MobotixSeriesReceiver(*args, **kwargs)

Bases: SeriesReceiver

Handles the acquisition of image series with a Mobotix camera.

Parameters:
  • url_cam – see SeriesReceiver

  • storage_path – see ImageReceiver

  • location – see ImageReceiver

  • sampling_time – see ImageReceiver

  • exposure_times – see SeriesReceiver

  • settling_time – see SeriesReceiver

command_record = 'record/current.jpg'
set_exposure(exp_set)

” Request camera to change exposure time

Parameters:

exp_set – Exposure time in microseconds

static get_real_exposure(img)

Checks the exposure time noted in the header of a Mobotix JPEG.

Mobotix JPEGs possess a specific header. This is fundamental for the function.

Exposure times of 1e4 seconds and more are not expected.

Parameters:

img – Binary encoded mobotix jpeg image

Returns:

int, read exposure time in microseconds

asi_core.daq.url_image_receiver.main()

Parse cmd line arguments and run data acquisition

Provide the path to your config file as argument after flag -c or run the daq in a folder which contains a config file named ‘asi_daq_cfg.yaml’