Skip to content

Instantly share code, notes, and snippets.

@robsears
robsears / OverlayImage.py
Created December 11, 2012 17:21
Overlay an image in OpenCV using Python
# Adapted from http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/
from cv2 import *
src = cv.LoadImage("image.jpg") # Load a source image
overlay = cv.LoadImage("ghost.png") # Load an image to overlay
posx = 170 # Define a point (posx, posy) on the source
posy = 100 # image where the overlay will be placed
S = (0.5, 0.5, 0.5, 0.5) # Define blending coefficients S and D
D = (0.5, 0.5, 0.5, 0.5)
@robsears
robsears / OverlayImage.cpp
Created December 11, 2012 16:40
Overlay an image in OpenCV using C++
# OverlayImage function reproduced from: http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/
void OverlayImage(IplImage* src, IplImage* overlay, CvPoint location, CvScalar S, CvScalar D) {
for(int x=0;xwidth;x++)
{
if(x+location.x >= src->width) continue;
for(int y=0;yheight;y++)
{
if(y+location.y>=src->height) continue;
@robsears
robsears / wxpython-joystick4.pyw
Created October 24, 2012 02:33
wxPython Joystick Example 4
# Import wx objects
import wx
# Taken from wxPython demos:
haveJoystick = True
if wx.Platform == "__WXMAC__":
haveJoystick = False
# Create a few global variables so we can tweak alignment in the GUI window
X_LABEL = 10
@robsears
robsears / wxpython-joystick3.pyw
Created October 24, 2012 02:32
wxPython Joystick Example 3
# Import wx objects
import wx
# Taken from wxPython demos:
haveJoystick = True
if wx.Platform == "__WXMAC__":
haveJoystick = False
# Create a few global variables so we can tweak alignment, etc
X_LABEL = 10
@robsears
robsears / wxpython-joystick2.pyw
Created October 24, 2012 02:31
wxPython Joystick Example 2
# wx.Joystick example number 2
# Import wx objects
import wx
# Taken from wxPython demos:
haveJoystick = True
if wx.Platform == "__WXMAC__":
haveJoystick = False
# Create a few global variables so we can tweak alignment, etc
@robsears
robsears / wxpython-joystick1.pyw
Created October 24, 2012 02:30
wxPython Joystick Example 1
# Simplest possible wx.Joystick example
# Import wx objects
import wx
# Taken from wxPython demos:
haveJoystick = True
if wx.Platform == "__WXMAC__":
haveJoystick = False
# The main frame
@robsears
robsears / wxpython-joystick5.pyw
Created October 23, 2012 04:27
wxPython Joystick Example 5
# Import wx objects
import wx
# Taken from wxPython demos:
MAX_BUTTONS = 16 # This comes from a limit in Python dealing with binary numbers I guess. More info on line 209
haveJoystick = True
if wx.Platform == "__WXMAC__":
haveJoystick = False
# Create a few global variables so we can tweak alignment in the GUI window