Skip to content

Instantly share code, notes, and snippets.

@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
@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-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-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-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 / 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 / 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 / OverlayPNG.py
Created December 11, 2012 17:24
Overlay a transparent PNG in OpenCV using Python
# Adapted from http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/
# Note: This code assumes a PNG with a Color->Transparency, with black as the alpha color
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
@robsears
robsears / gist:4260561
Created December 11, 2012 17:44
Overlay a transparent PNG on video feed using OpenCV and wxPython
# Adapted from http://www.aishack.in/2010/07/transparent-image-overlays-in-opencv/
import wx
from cv2 import *
capture = cv.CaptureFromCAM(0)
overlay = cv.LoadImage("ghost.png")
posx = 0
posy = 0
xdir = 1
@robsears
robsears / wxHello.cpp
Created December 16, 2012 07:07
A simple Hello World program for wxWidgets. Taken without alteration from http://www.wxwidgets.org/docs/tutorials/hworld.txt
/*
* hworld.cpp
* http://www.wxwidgets.org/docs/tutorials/hworld.txt
*/
#include <wx\wx.h>
class MyApp: public wxApp
{
virtual bool OnInit();