Skip to content

Instantly share code, notes, and snippets.

import time
import os
dirdl = '/home/Anon/Downloads/'
dirp = '/home/Anon/Pictures/'
dirv = '/home/Anon/Videos/'
dird = '/home/Anon/Documents/'
dirm = '/home/Anon/Music/'
dirs = [dirp, dirv, dird, dirdl, dirm]
while True:
time.sleep(10)
@steveway
steveway / opencvvideoclock.py
Last active April 19, 2017 15:19
This loops a videofile and shows the time on top.
# To simulate netcat: https://gist.github.com/leonjza/f35a7252babdf77c8421
# Test Cython for dithering: http://docs.cython.org/en/latest/src/tutorial/numpy.html
import numpy as np
from time import localtime, strftime, time, sleep
import cv2
import sys
use_cython = True
if use_cython:
@steveway
steveway / raw2gmv.py
Created April 11, 2017 15:41
Port of raw2gmv.c to Python
# //====================================================
# // raw2gmv 1.0a - raw to geekmaster video transcoder
# // Copyright (C) 2012 by geekmaster, with MIT license:
# // http://www.opensource.org/licenses/mit-license.php
# //----------------------------------------------------
##include <stdio.h> // stdin,stdout
# typedef unsigned char u8; typedef unsigned int u32;
# int main(void) {
# u8 o,to,tb,wb0[800*600]; u32 x,y,xi,yi,c=250,b=120; // c=contrast, b=brightness
# while (fread(wb0,800*600,1,stdin)) for (y=0;y<800;y++) { xi=y; tb=0;
@steveway
steveway / gmvplayer.py
Last active May 16, 2017 09:48
A videoplayer able to play back gmv and gzipped gmv files
import numpy as np
import cv2
import gzip
import sys, os
from time import sleep, time
def main():
width = 600
height = 800
@steveway
steveway / st_dither.py
Created April 18, 2017 15:51
Belongs to the opencvvideoclock.py, test using cython for this.
import numpy as np
def apply_ordered_dither(inputarray, bayer_map, bayer_size):
width, height = inputarray.shape
for y in range(height):
for x in range(width):
inputarray[x, y] = 0 if inputarray[x, y] < bayer_map[x % bayer_size, y % bayer_size] else 255
return inputarray
@steveway
steveway / st_dither2.pyx
Last active April 19, 2017 09:16
Cython version of the ordered dither function, immensely faster!
import numpy as np
cimport numpy as np
cimport cython
DTYPE = np.double
ctypedef np.double_t DTYPE_t
DTYPE2 = np.uint8
ctypedef np.uint8_t DTYPE2_t
@cython.boundscheck(False) # turn off bounds-checking for entire function
@steveway
steveway / gmplay_with_addon.c
Last active May 7, 2019 00:09
This should add the ability to overlay images on a gmv video.
//====================================================
// gmplay 2.1 - geekmaster's kindle video player
// Copyright (C) 2012 by geekmaster, with MIT license:
// http://www.opensource.org/licenses/mit-license.php
// Modified by Stefan Murawski ([email protected])
//----------------------------------------------------
// Tested on DX,DXG,K3,K4main,K4diags,K5main,K5diags.
//----------------------------------------------------
#include <sys/ioctl.h> // ioctl
#include <sys/mman.h> // mmap, munmap
@steveway
steveway / create_clock.py
Created November 9, 2017 15:23
Create Clock images with separate masks.
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFont, ImageOps
import numpy as np
import os
width = 600
halfwidth = width/2
avatarsize = 48
height = 800
background_color = (255, 255, 255, 0)
from pybrain.structure import FeedForwardNetwork
from pybrain.structure import LinearLayer, SigmoidLayer
from pybrain.structure import FullConnection
from pybrain.rl.agents import LearningAgent
from PIL import Image, ImageDraw, ImageFont, ImageOps
import numpy as np
import copy
def mse(imageA, imageB):
# the 'Mean Squared Error' between the two images is the
from PIL import Image, ImageDraw, ImageFont, ImageOps
import numpy as np
import random
try:
unichr
except NameError:
unichr = chr
def render(input_arr):
output = input_arr