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
# Install packages needed | |
sudo apt install gpsd gpsd-clients pps-tools | |
########################### | |
## Add the following lines to /boot/config.txt to set the port used for the PPS h/w input (in this case GPIO pin 18) | |
# The next lines are for GPS PPS signals | |
dtoverlay=pps-gpio,gpiopin=18 | |
########################### | |
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
# Download correct driver from http://downloads.fars-robotics.net/wifi-drivers/8188fu-drivers/ | |
# For example, for kernel version 4.14.79, download the following driver: | |
wget http://downloads.fars-robotics.net/wifi-drivers/8188fu-drivers/8188fu-4.14.79-1159.tar.gz | |
# Extract the driver | |
tar zxvf 8188fu-4.14.79-1159.tar.gz | |
# Install the driver | |
sudo ./install.sh |
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
# Interpolate video frames for a higher frame rate | |
ffmpeg -i source.mp4 -filter:v minterpolate -r 25 result.mp4 | |
ffmpeg -i source.mp4 -vf minterpolate=50,tblend=all_mode=average,framestep=2 result.mp4 | |
# Change the framerate (to 5 fps) of an input h264 raw video and convert to mkv | |
ffmpeg -r 5 -i input.h264 -vcodec copy output.mkv | |
# Crop a video to the bottom right quarter | |
ffmpeg -i in.mp4 -filter:v "crop=in_w/2:in_h/2:in_w/2:in_h/2" -c:a copy out.mp4 |
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
# Fetch files on remotehost modified within the last 7 days | |
rsync -av user@remotehost:'`find /home/user/* -mtime -7 -print`' . |
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 python | |
# Program to calculate the sky brightness of a JPEG image of the night sky | |
# Assumptions: | |
# The EXIF data for the image contains the following valid tags: | |
# ISOSpeedRatings, ApertureValue, ExposureTime | |
import numpy as np | |
import argparse | |
import PIL.Image |
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 | |
# Read in the image | |
image_file = 'original.jpg' | |
image = cv2.imread(image_file) | |
overlay = image.copy() | |
output = image.copy() | |
height, width = image.shape[:2] | |
# Stamp the image lower right corner and write it |
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
# Generate a spiral pattern, moving outwards from the centre position (0,0) | |
# The size parameter sets the size of the spiral "shell" | |
SIZE = 5 | |
x, y = 0, 0 | |
dx, dy = 0, -1 | |
for i in range(SIZE**2): | |
if (x == y) or (x < 0 and x == -y) or (x > 0 and x == 1-y): | |
dx, dy = -dy, dx |
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
# Separate an image into RGB channels. Filenames 1, 2, 3 for red, green and blue respectively | |
convert image.jpg -channel RGB -separate channels_%d.png | |
# Convert an image to grayscale | |
convert image.jpg -set colorspace Gray -separate -average image.png | |
# Threshold an image | |
convert -threshold 75 image.jpg image-thresh.jpg | |
# Combine images using max pixel values of each image |
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 picamera | |
import picamera.array | |
import time, datetime | |
# Use the motiondetector analyze callback to annotate the video with a UTC time stamp | |
class MotionDetector(picamera.array.PiMotionAnalysis): | |
def analyze(self, a): | |
camera.annotate_text = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] | |
with picamera.PiCamera() as camera: |
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
# Find a point that is mutually closest to two or more 3d lines in a least-squares sense. | |
# Based on: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#In_three_dimensions_2 | |
import numpy as np | |
# Create two or more 3d lines in the form of a matrix [[x1,y1,z1], [x2,y2,z2]] | |
lines = [] | |
lines.append(np.asmatrix([[ 4, 0,0], [1,1,4]])) | |
lines.append(np.asmatrix([[-3,-2,0], [4,2,3]])) | |
lines.append(np.asmatrix([[ 0, 0,0], [2,2,6]])) | |
lines.append(np.asmatrix([[ 1, 2,0], [2,0,6]])) |
NewerOlder