Entry point for capture§

This python script serves as the entry point for capturing and uploading.

It detects cameras, creates uploaders and an updater, starts threads etc.

Created on Mon Nov 17 10:24:49 2014

author:chuong nguyen, chuong.nguyen@anu.edu.au
author:Gareth Dunstone, gareth.dunstone@anu.edu.au
pantiltzoomlib.draw_matches_opencv(img1, kp1, img2, kp2, matches)[source]§

Source: http://stackoverflow.com/questions/20259025/module-object-has-no-attribute-drawmatches-opencv-python This function takes in two images with their associated keypoints, as well as a list of DMatch data structure (matches) that contains which keypoints matched in which images.

An image will be produced where a montage is shown with the first image followed by the second image beside it.

Keypoints are delineated with circles, while lines are connected between matching keypoints.

Parameters:
  • img1 (np.ndarray) – grayscale image
  • kp1 (list) – Detected list of keypoints through any of the OpenCV keypoint detection algorithms
  • img2 (np.ndarray) – grayscale image
  • kp2 (list) – Detected list of keypoints through any of the OpenCV keypoint detection algorithms
  • matches (list) – A list of matches of corresponding keypoints through any OpenCV keypoint matching algorithm
Returns:

image of matches between images.

Return type:

np.ndarray

pantiltzoomlib.get_displacement_opencv(image0, image1)[source]§

Gets displacement (in pixels I think) difference between 2 images using opencv

Parameters:
  • image0 (np.ndarray) – reference image
  • image1 (np.ndarray) – target image
Returns:

pantiltzoomlib.get_displacement(image0, image1)[source]§

Gets displacement (in pixels I think) difference between 2 images using scikit-image not as accurate as the opencv version i think.

Parameters:
  • image0 – reference image
  • image1 – target image
Returns:

pantiltzoomlib.sec2human(seconds) → str[source]§

formats a timedelta object into semi-fuzzy human readable time periods.

Parameters:seconds (int or float) – seconds to format into a time period
Returns:human readable string
Return type:str
class pantiltzoomlib.Panorama(config=None, config_filename=None, queue=None)[source]§

Bases: object

Panorama class. Provides the calibration and creation of tiled panoramas with a configuration file.

accuracy = 3§
set_current_as_first_corner()[source]§

This and set_current_as_second_corner(), both internally call enumerate positions.

set_current_as_second_corner()[source]§

See set_current_as_first_corner().

enumerate_positions()[source]§

Uses the currrent image overlap, camera fov and corners to calculate a “grid” of pan and tilt positions.

Also sets the internal enumeration of pan/tilt positions.

summary§

returns a human readable summary of the panorama parameters. These include pan step, camera fov etc.

Returns:information about the panorama
Return type:str
camera§
pantilt§
image_overlap§
scan_order§
output_dir§
panorama_fov§

Gets the total fov of the Panorama.

Returns:total fov of the panorama as (hfov, vfov)
Return type:tuple[float, float]
first_corner§

the starting corner of the panorama. :return: tuple of first corner as (pan,tilt) :rtype: tuple[float,float]

center§
Returns:tuple of center position as (pan,tilt)
Return type:tuple[float,float]
second_corner§

the finishing corner of the panorama. :return: tuple of second corner as (pan,tilt) :rtype: tuple[float,float]

static format_calibration(fovlists: tuple, test: str) → str[source]§

formats a list of calibrated tuple of lists of fields of view and gives some statistics about the measurements.

Parameters:
  • fovlists (tuple[ list(float), list(float) ]) – 2 length tuple of lists of hfov and vfov - tuple(list(hfov), list(vfov))
  • test (str) – prefix for put before the output (ie, which number test it is)
Returns:

formattted string of the camera calibration.

Return type:

str

test_calibration(number_of_tests: int)[source]§

Tests the calibration process for accuracy, and prints the output values.

Parameters:number_of_tests – number of times to calibrate and compare calibration values.
calibrate_fov_list(zoom_list: list = range(50, 1000, 100), panpos: float = None, tiltpos: float = None, increment: float = 2, use_opencv: bool = True) → tuple[source]§

calibrates the Panorama for a list of zoom levels.

Parameters:
  • zoom_list – list of zoom positions to calibrate
  • panpos – pan position to calibrate
  • tiltpos – tilt “”
  • increment – pan increment amount for the calibration
  • use_opencv – whether to use opencv
Returns:

2 length tuple of lists of hfov and vfov - tuple(list(hfov), list(vfov))

calibrate_fov(zoom_pos: float, pan_pos: float, tilt_pos: float, increment: float, use_opencv: bool = True) → tuple[source]§

Capture images at different pan/tilt angles, then measure the pixel displacement between the images to estimate the field-of-view angle.

This function is also designed to reject outliers when measuring.

Parameters:
  • zoom_pos (float) – begin zoom position
  • pan_pos (float) – begin pan position
  • tilt_pos (float) – begin tilt position
  • increment (float) – amount to increment to get displacement.
  • use_opencv (bool) – Whether to use opencv or scikit image for displacement algorithm
Returns:

tuple of hfov, vfov estimates

Return type:

tuple[float,float]

quick_calibrate(increment: float)[source]§

Performs a quick calibration, a single time, and store the calibration values in the child camera object, and the child ptz object. :param increment: amount to increment by until we get optimal displacement. :type increment: float

load_csv_log() → dict[source]§

loads a csv log into a dictionary so that we can continue to write to it.

Returns:dict of values in the csv.
write_csv_log(image_index, pan_pos, tilt_pos)[source]§

writes a new line of values to the csv log.

Parameters:
  • image_index – current index to be written
  • pan_pos – the current pan position
  • tilt_pos – the current tilt position.
write_to_recovery_file(index, started_time)[source]§

writes the current state to the recovery file.

Parameters:
  • index – the current index into the panorama.
  • started_time – the time the panorama was started.
take_panorama()[source]§

takes a panorama using the current values stored in this Panorama object.

calibrate_and_run()[source]§

calibrates, and takes a panorama.

run_from_config()[source]§

Prints the summary and takes a panorama

static time2seconds(t: datetime.datetime) → int[source]§

converts a datetime to an integer of seconds since epoch

Returns:seconds since 1970-01-01 00:00
Return type:int
time_to_capture()[source]§

filters out times for capture, returns True by default returns False if the conditions where the camera should NOT capture are met.

Returns:whether we should start capturing images now or not
Return type:bool
next_pano§

calculates the amount of time until the next panorama

Returns:time until the next panorama (in seconds)
Return type:int
run_loop()[source]§

runs the panorama taker in a loop based on the interval in the config file.