Skip to content

Instantly share code, notes, and snippets.

View clungzta's full-sized avatar

Alex McClung clungzta

View GitHub Profile
@clungzta
clungzta / Passwordless SSH
Last active July 30, 2016 02:38
Creates a private key to connect to a remote host without having to enter a password
$ ssh-keygen
*enter*
*enter*
*enter*
$ ssh-copy-id [remote-user]@[remote-host]
{
"type": "DeviceConfiguration",
"general": {
"hostname": "RouterA"
},
"interfaces": [
{
"name": "lo0",
"type": "ethernet",
"addresses": [
import cv2
import numpy as np
from matplotlib import pyplot as plt
img1 = cv2.imread('/home/alex/Downloads/snapshot (2).jpg',0) #queryimage # left image
img2 = cv2.imread('/home/alex/Downloads/snapshot (1).jpg',0) #trainimage # right image
sift = cv2.xfeatures2d.SIFT_create()
# find the keypoints and descriptors with SIFT
@clungzta
clungzta / kalman2d_opencv3.py
Last active November 21, 2018 21:42
Simple 2D Kalman filter for OpenCV3
'''
kalman2d_opencv3 - Simple 2D Kalman filter for OpenCV3
Based on http://stackoverflow.com/questions/29012038/is-there-any-example-of-cv2-kalmanfilter-implementation
Copyright (C) 2017 Alex McClung
This code is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
@clungzta
clungzta / mask_centre_of_mass.py
Last active February 5, 2017 06:23
Find the centre of mass (mean position of all non-zero points) of a cv2 (np uint8) binary mask. (a python numpy implementation of the first method here http://stackoverflow.com/a/14999043)
def centre_of_mass(mask):
"""
@brief Finds the centre of mass of a cv2 (np uint8) binary mask. Does not use cv2.moments or contours
@param mask The binary mask image
@return The spatial centre of mass of the mask.
"""
Y, X = np.mgrid[0:mask.shape[0]:1, 0:mask.shape[1]:1]
@clungzta
clungzta / libsurvive_quickstart.md
Last active February 8, 2017 23:55
Instructions to quickly test out the libsurvive (https://github.com/cnlohr/libsurvive) open source driver for HTC Vive tracking

Hardware

  1. Mount the lighthouse beacons according to mounting/hardware setup instructions here.
  2. Power up the: beacons, HMD (headset), watchmans (controllers)
  3. Plug in USB cable from link box to computer (HDMI cable can be ignored if only using the position tracking with libsurvive)

Software

Ensure external dependencies are installed They are listed in libsurvive readme

#!/usr/bin/env python
import sys
import rospy
import cv2
import video
import numpy as np
from mosse import MOSSE
from std_msgs.msg import String
from sensor_msgs.msg import Image
# from common import draw_str, RectSelector
@clungzta
clungzta / rgbd_imgpoint_to_tf.py
Last active August 23, 2021 13:19
Generate a ROS TF frame from a recified image point using an RGBD camera (uses rectified rgb and depth rect). Tested with Kinect v1
#!/usr/bin/env python
import os
import tf
import sys
import cv2
import time
import rospy
import random
import pprint
import image_geometry
<launch>
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch" />
<include file="$(find dn_object_detect)/launch/objdetect.launch" />
<include file="$(find dn_display_demo)/launch/display_demo.launch" />
</launch>
@clungzta
clungzta / bgsub.py
Created March 10, 2017 06:16
Playing around with background subtraction in OpenCV
import os
import cv2
import numpy as np
#Try block for OpenCV 2/3 version compatabillity
try:
fgbg = cv2.BackgroundSubstractor()
except:
fgbg = cv2.BackgroundSubtractorMOG2()