Skip to content

Instantly share code, notes, and snippets.

View wwj718's full-sized avatar

wwj718

View GitHub Profile
@wwj718
wwj718 / opencv_video_to_pygame.py
Created January 24, 2018 13:50 — forked from radames/opencv_video_to_pygame.py
OpenCV VideoCapture running on PyGame
import pygame
from pygame.locals import *
import cv2
import numpy as np
import sys
camera = cv2.VideoCapture(0)
pygame.init()
pygame.display.set_caption("OpenCV camera stream on Pygame")
screen = pygame.display.set_mode([1280,720])
# pip install opencv-python
# python3.6.2
#!/usr/bin/env python
# encoding: utf-8
import numpy as np
import cv2
cap = cv2.VideoCapture('/Users/wwj/Documents/pets.mp4')
#!/usr/bin/env python
# encoding: utf-8
'''
python3.6.2
'''
from moviepy.editor import *
import pygame
pygame.display.set_caption('Hello World!')
#!/usr/bin/env python
# encoding: utf-8
import pygame
'''
说明
osx python2.7 pygame1.9.2b6
pygame目前只支持python2
# mac 下的安装过程参考: http://blog.just4fun.site/install-pygame-on-Mac-OSX.html
@wwj718
wwj718 / badusb_kbmap.txt
Last active January 19, 2018 13:33
micropython的键值映射
bit 0: left control
bit 1: left shift
bit 2: left alt
bit 3: left GUI (Win/Apple/Meta key)
bit 4: right control
bit 5: right shift
bit 6: right alt
bit 7: right GUI
#################3
#!/usr/bin/env python
# encoding: utf-8
import turtle
import time
# 处理python2/python3兼容性
try:
input = raw_input
except NameError:
@wwj718
wwj718 / microbit_serial.py
Last active April 20, 2018 07:25
microbit serial input/output
'''
pc 控制microbit
双工通道 编程风格类似socket
'''
## pc
import serial
ser = serial.Serial('/dev/tty.usbmodem1412', 9600, timeout=5)
data = "abc".encode("utf-8")
# data = bytes('abc\n',"UTF-8")
ser.write(data)
!function(a, b, c, d) {
"use strict";
function e(a) {
return ("string" == typeof a || a instanceof String) && (a = a.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, "")),
a
}
var f = function(b) {
for (var c = b.length, d = a("head"); c--; )
0 === d.has("." + b[c]).length && d.append('<meta class="' + b[c] + '" />')
};
!function(a, b, c, d) {
"use strict";
function e(a) {
return ("string" == typeof a || a instanceof String) && (a = a.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, "")),
a
}
var f = function(b) {
for (var c = b.length, d = a("head"); c--; )
0 === d.has("." + b[c]).length && d.append('<meta class="' + b[c] + '" />')
};
!function(a, b, c, d) {
"use strict";
function e(a) {
return ("string" == typeof a || a instanceof String) && (a = a.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, "")),
a
}
var f = function(b) {
for (var c = b.length, d = a("head"); c--; )
0 === d.has("." + b[c]).length && d.append('<meta class="' + b[c] + '" />')
};