Skip to content

Instantly share code, notes, and snippets.

View i-namekawa's full-sized avatar

Iori Namekawa i-namekawa

  • Basel, Switzerland
View GitHub Profile
@i-namekawa
i-namekawa / paddedzoom.py
Last active April 10, 2024 22:56
zoom in/out an image (numpy array) while keeping the original shape.
import cv2
def paddedzoom(img, zoomfactor=0.8):
'''
Zoom in/out an image while keeping the input image shape.
i.e., zero pad when factor<1, clip out when factor>1.
there is another version below (paddedzoom2)
'''
@i-namekawa
i-namekawa / compare_MPL_cmaps.py
Last active September 23, 2015 09:28
display default MPL colormaps
from pylab import *
val=range(4)
cmaps = [('Sequential', ['Blues', 'BuGn', 'BuPu',
'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd',
'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu',
'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']),
('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool', 'copper',
'gist_heat', 'gray', 'hot', 'pink',
'spring', 'summer', 'winter']),
@i-namekawa
i-namekawa / record_panda_screen.py
Last active August 29, 2015 14:25
How to record the panda app screen as avi using ffmpeg
import subprocess, sys
from direct.showbase.ShowBase import ShowBase
from panda3d.core import ClockObject
cmdstring = ('ffmpeg.exe', # put it in the same dir
'-y', # overwrite the file w/o warning
'-r', '%f' % 30.0, # frame rate of encoded video
'-an', # no audio
'-analyzeduration', '0', # skip auto codec analysis
@i-namekawa
i-namekawa / numpy_texture_panda3d.py
Created July 16, 2015 08:38
Use Numpy array for panda3d texture, video player example
from __future__ import division
import os
import cv2
import numpy as np
from panda3d.core import Texture, CardMaker
from direct.showbase.ShowBase import ShowBase
@i-namekawa
i-namekawa / copy2clipboard.py
Created May 19, 2015 22:32
copy a matplotlib figure to clipboard as BMP
from cStringIO import StringIO
from time import sleep
from PIL import Image
import win32clipboard
def copy2clipboard(fig=None):
'''
copy a matplotlib figure to clipboard as BMP on windows
@i-namekawa
i-namekawa / copy_headers.py
Created April 30, 2015 13:53
script to copy Geany header etc to C:/libs on Windows
#!/usr/bin/env python
import glob, os, shutil
VERSION = '1.25'
DEST = r'C:/libs'
# header files
shutil.rmtree(r'%s\include\geany' % DEST, ignore_errors=True)
shutil.copytree(r'geany-%s\include\geany' % VERSION, r'%s\include\geany' % DEST)
@i-namekawa
i-namekawa / Basel Weekend Weather Analysis.ipynb
Created April 27, 2015 09:53
Basel Weekend Weather Analysis IPython NB version
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@i-namekawa
i-namekawa / BaselWeatherAnalysis.py
Last active September 29, 2015 09:09
Basel weather analysis
import datetime
from bs4 import BeautifulSoup
import pandas as pd
import requests
def getData(year=2014, month=1, proxies={}):
url = 'http://en.tutiempo.net/climate/%02d-%d/ws-66010.html' % (month, year)
@i-namekawa
i-namekawa / change_fps.py
Last active March 6, 2017 01:11
multiprocessing ffmpeg
import multiprocessing, os, Queue, subprocess, sys
from time import sleep
class Worker(multiprocessing.Process):
'''http://jeetworks.org/node/81 modified example in the comments'''
def __init__(self, work_queue):
# base class initialization
multiprocessing.Process.__init__(self)
@i-namekawa
i-namekawa / setup.py
Created November 2, 2014 18:47
setup.py for Pymagor py2exe packaging
# ======================================================== #
# File automagically generated by GUI2Exe version 0.5.3
# Copyright: (c) 2007-2012 Andrea Gavana
# ======================================================== #
# Let's start with some default (for me) imports...
from distutils.core import setup
from py2exe.build_exe import py2exe