pywebcat package¶
Submodules¶
pywebcat.cli module¶
pywebcat.utils module¶
-
class
pywebcat.utils.
TqdmUpTo
(iterable=None, desc=None, total=None, leave=True, file=None, ncols=None, mininterval=0.1, maxinterval=10.0, miniters=None, ascii=None, disable=False, unit='it', unit_scale=False, dynamic_ncols=False, smoothing=0.3, bar_format=None, initial=0, position=None, postfix=None, unit_divisor=1000, write_bytes=None, lock_args=None, nrows=None, gui=False, **kwargs)[source]¶ Bases:
tqdm.std.tqdm
Utility class for displaying a progress bar.
-
download_url
(self, fout=None, verbose=1)¶ Download the video from the url.
Examples
>>> url = "http://webcat-video.axds.co/buxtoncoastalcam/raw/2019/2019_11/2019_11_13/buxtoncoastalcam.2019-11-13_1000.mp4" >>> with TqdmUpTo(unit="B", unit_scale=True, unit_divisor=1024, miniters=1, desc=f"Saving to {fout}") as t: >>> urllib.request.urlretrieve(self.fin, fout, reporthook=t.update_to) ... Saving to buxtoncoastalcam.2019-11-13_1000.mp4: 0%| | 44.1M/125M [00:08<00:16, 5.18MB/s]
-
update_to
(b: int = 1, bsize: int = 1, tsize: int = None)[source]¶ Progress bar udpate function.
Parameters: - b (int, optional) – Number of blocks transferred so far, by default 1
- bsize (int, optional) – Size of each block (in tqdm units), by default 1
- tsize (int, optional) – Total size (in tqdm units), by default None
-
-
class
pywebcat.utils.
WebCAT
[source]¶ Bases:
object
Utility class for viewing local or remote webcat videos.
-
url
¶ url to the .mp4 file.
-
name
¶ Unique name based on url.
-
video
¶ The cv2.VideoCapture object of the video file at url.
Type: cv2.VideoCapture
-
frames
¶ Total number of frames in the video.
Type: int
-
fps
¶ Frames per second in the video.
Type: int
-
width
¶ Width of video frames in pixels.
Type: int
-
height
¶ Height of video frames in pixels.
Type: int
Examples
>>> from webcat_utils import VidRetriever >>> url = "http://webcat-video.axds.co/buxtoncoastalcam/raw/2019/2019_11/2019_11_13/buxtoncoastalcam.2019-11-13_1000.mp4" >>> vr = VidRetriever(url) >>> vr.download_url() ... Saving to buxtoncoastalcam.2019-11-13_1000.mp4: 0%| | 44.1M/125M [00:08<00:16, 5.18MB/s]
-
download_url
(fout: str = None, verbose: bool = True)[source] Download the video from the instance url.
Parameters: - fout (str) – The file path to save the downloaded file to, e.g., ~/Downloads/download.mp4, by default None
- verbose ({True, False}, optional) – Display download progress bar, by default True
-
fps
-
frames
-
generate_url
(station: str, year: int, month: int, day: int, time: int)[source]¶ Generate WebCAT URLs and expressive name for files from user inputs.
Parameters: - station (str) – Station name, e.g., “buxtoncoastalcam”.
- year (int) – Year of video, e.g., 2020.
- month (int) – Month (numerical) of video, e.g., 11.
- day (int) – Day of video, e.g., 17.
- time (int) – Time (24 hr) of video rounded to nearest 10 minutes, e.g., 0500 (5:00 am), 1300 (1:00 pm), 1330 (1:30pm).
-
height
-
plot_average_frame
(step: int = 500)[source]¶ Plot the average of every “step” frames in the video.
Parameters: step (int, optional) – The step between frames to average by, lower values result in a smoother average, by default 10. Examples
>>> from webcat_utils import WebCAT >>> wc.generate_url("buxtoncoastalcam", 2019, 11, 13, 1000) >>> wc.plot_average_frame() ... <matplotlib.subplot>
-
plot_frames
(frames: list = [0])[source]¶ Plot frames from the video, zero-based indexing.
Parameters: frames (list, optional) – List of the frames to display in a grid plot, by default [0]. Examples
>>> from webcat_utils import WebCAT >>> wc.generate_url("buxtoncoastalcam", 2019, 11, 13, 1000) >>> wc.plot_frames() ... <matplotlib.subplots>
-
save_frames
(delta_t: int = 10, fout_path: str = '', save_csv=True, verbose=False)[source]¶ Download the video from the instance url.
Parameters: - delta_t (int, optional) – A frame will be saved every delta_t seconds, by default 10.
- fout (str, optional) – Path to save frames and csv to, e.g., “~/Downloads/”.
-
width
-