Skip to content

Instantly share code, notes, and snippets.

@joshdoe
joshdoe / test_videomixer_pos.py
Created July 1, 2020 11:20
GStreamer Python example showing changing of videomixer position
import os
import sys
import time
def _prepend_env_path(name, value):
os.environ[name] = os.pathsep.join(value +
os.environ.get(name, "").split(os.pathsep))
CONFIGURED_GSTREAMER_PATH = r'C:\gstreamer\1.17\x86_64'
_prepend_env_path("PATH", [os.path.join(CONFIGURED_GSTREAMER_PATH, 'bin')])
sys.path.insert(0, os.path.join(CONFIGURED_GSTREAMER_PATH, 'lib', 'python3.7', 'site-packages'))
@joshdoe
joshdoe / button.py
Last active August 29, 2015 14:03
For PsychoPy: BoxLayout and GridLayout to auto-layout stimuli, Button and ButtonGrid to allow single or multiple selections from a list of choices
#!/usr/bin/env python2
'''Creates a buttonff of given width and height
as a special case of a :class:`~psychopy.visual.ShapeStim`'''
# Part of the PsychoPy library
# Copyright (C) 2014 Jonathan Peirce
# Distributed under the terms of the GNU General Public License (GPL).
import numpy as np
@joshdoe
joshdoe / vbmp_mapproxy.yaml
Created March 25, 2014 14:13
MapProxy configuration file for caching Virginia Base Mapping Program (VBMP) orthoimagery to be used in OpenStreetMap editors
# MapProxy configuration file for caching Virginia Base Mapping Program (VBMP) orthoimagery to be used in OpenStreetMap editors
# Tile service (compatible with OSM/etc.)
# first tile: http://localhost:8080/tiles/osm/webmercator/0/0/0.png
services:
demo:
tms:
use_grid_names: true
# origin for /tiles service
origin: 'nw'
@joshdoe
joshdoe / ataaps_interface_enhancements.user.js
Created January 13, 2014 15:45
Chrome and Firefox/Greasemonkey user script that allows arrow keys to move between cells on the ATAAPS labor screen, shows leave information when hovering over link, and other enhancements.
// ==UserScript==
// @match https://ataaps.csd.disa.mil/*
// @description Allows arrow keys to move between cells on the ATAAPS labor screen, shows leave information when hovering over link, and other enhancements.
// @name ATAAPS Interface Enhancements
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
@joshdoe
joshdoe / ogr2poly.py
Created December 5, 2011 18:15
Script to convert OGR supported files to OSM polygon filter file format, now found http://trac.openstreetmap.org/browser/applications/utils/osm-extract/polygons/ogr2poly.py
#!/usr/bin/env python
# Update: A newer version can be found in the OSM SVN:
# http://trac.openstreetmap.org/browser/applications/utils/osm-extract/polygons/ogr2poly.py
# This converts OGR supported files (Shapefile, GPX, etc.) to the polygon
# filter file format [1] supported by Osmosis and other tools. It also
# includes buffering and simplifying. This allows point or line features
# to be used when creating POLY files, but in this case buffering must
# be used.
@joshdoe
joshdoe / cost_points_to_poly.py
Created September 1, 2011 15:16
GRASS script to convert cost points generated by pgRouting's driving_distance() to polygons of 1/4 mile increments
#!/usr/bin/env python
import os
import atexit
import sys
import subprocess
gisbase = os.environ['GISBASE'] = '/usr/lib/grass64'
gisdbase = os.path.join(os.environ['HOME'], 'grassdata')
location = 'fairfax'
@joshdoe
joshdoe / pyside_pygst_on_windows.py
Created August 2, 2011 13:56
PySide (Qt) + PyGst (GStreamer) on Microsoft Windows
import sys
# needed for casting PyCObject to void pointer
from ctypes import pythonapi, c_void_p, py_object
from PySide.QtCore import *
from PySide.QtGui import *
import gobject
import pygst
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class JoshD_Deinterlace implements PlugInFilter {
protected ImagePlus image;
class GstPlayer(object):
sub_area = 0
middle_area = 0
nAccumFrames = 0
def __init__(self, videowidget):
self.playing = False
self.vw = videowidget
self.vw.player = self