This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _create_config(): | |
return {"foo_key":0} | |
def create_foo_thing(): | |
config = _create_config() | |
return config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepare_frame(np_arr_shape, frames_written): | |
"""Emulate an I/O limited step that returns a frame, | |
e.g. reading from a quick-to-decode file. Note that we could instead simulate | |
a CPU intensive task here and the resulting benchmark runs much faster | |
when using multiprocessing than multithreading. | |
:param Tuple[int, int] np_arr_shape: Dimension of the numpy array to be produced. | |
:param int frames_written: | |
""" | |
frame = np.ones(np_arr_shape) * frames_written |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in range(n_frames): | |
# produce the frame | |
np_arr = prepare_random_frame(np_arr_shape) | |
# consume the frame and do some example processing | |
_ = np_arr.astype("uint8").copy() * 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def seekTo(cap, position): | |
''' | |
Work around bug in OpenCV set method: https://github.com/opencv/opencv/issues/9053 | |
The alternative routine to seek in the video file, a bit slow. | |
Required because FFMPEG can seek only to closest I-frames and we | |
have to manually read all the P-frames until we reach the position | |
''' | |
positiontoset = position | |
pos = -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
cap = cv2.VideoCapture("myvideo.mkv") | |
while(True): | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
if not ret: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuxo pipefail | |
# If running this script on a Greengrass v2 device, it should return a dictionary containing temporary credentials. | |
# If it fails, check if the THING_NAME, ROLE_ALIAS and IOT_GET_CREDENTIAL_ENDPOINT are correct | |
# IOT_GET_CREDENTIAL_ENDPOINT can be verified via running ` aws iot describe-endpoint --endpoint-type iot:CredentialProvider --output text` | |
# on a different device with sufficent IAM to run this command, in the same AWS account and region. | |
THING_NAME=`sudo cat /greengrass/v2/config/effectiveConfig.yaml | grep -i thingName | awk '{ print $2 }' | tr -d '"'` | |
ROLE_ALIAS=`sudo cat /greengrass/v2/config/effectiveConfig.yaml | grep -i rolealias | awk '{ print $2 }' | tr -d '"'` | |
IOT_GET_CREDENTIAL_ENDPOINT=`sudo cat /greengrass/v2/config/effectiveConfig.yaml | grep iotCredEndpoint | awk '{print $2}' | tr -d '"'` |