Skip to content

Instantly share code, notes, and snippets.

View cv_sample_connectedComponents2.py
from subprocess import call
from pylab import *
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.patches import Rectangle
from time import sleep
import cv2
# Read template image
templateImageGray = cv2.imread("./images/templateImage.png", cv2.IMREAD_GRAYSCALE)
templateImageGray = cv2.resize(templateImageGray, (0, 0), fx=16, fy=16, interpolation=cv2.INTER_CUBIC)
View simpleImageSelector.py
import os
from glob import glob
import cv2
import numpy as np
from numpy import arange
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backend_bases import key_press_handler
View cropBmp.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This software is released under the MIT License, see below.
#----------------License----------------
#The MIT License (MIT)
#
#Copyright (c) <2015> <Kei Minagawa>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
View timecount.py
from PySide.QtGui import *
from PySide.QtCore import QTimer
app = QApplication([])
widget = QWidget()
textbox = QLineEdit()
startbutton = QPushButton("start/stop")
resetbutton = QPushButton("reset")
timelabel = QLabel("00:00:00")
counttimer = QTimer()
hboxlayout = QHBoxLayout()
View simplePaintApp.py
from PySide.QtGui import QApplication, QMainWindow, QAction, QActionGroup, QWidget, QCursor, QPainter
from PySide.QtCore import QTimer
import PySide.QtCore as QtCore
class W(QWidget):
def __init__(self):
QWidget.__init__(self)
self.resize(400,400)
self.myIsMousePressing = False
self.p = QPainter(self)
View memo.el
(defun my-open-new-memo ()
(interactive)
(let ((my-regexp "\\([0-9]+\\)[.]memo")
(my-max 1)
(my-matched-num 0)
(file-list (directory-files "~/.emacs.d/memo/")))
(dolist (i file-list)
(setq my-matched-num (string-to-number (replace-regexp-in-string my-regexp "\\1" i)))
(if (< my-max my-matched-num)
(setq my-max my-matched-num)))
View index.html
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
var globalTestItemNo = 1;
var TESTITEMNUM;
var DIVIDEDIMGNUM;
function globalTestItemNo2testName(globalTestItemNo){
View cvDrawStar
# convert image to numpy array
im = array(Image.open('./data/empire.jpg')) #return numpy array
# show
imshow(im, interpolation='nearest')#or interpolation='None'
# star point
x = [100,100,400,400]
y = [200,500,200,500]
View cvRotate
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#rotate clockwise
out = pil_im.rotate(45)
#show
out.show()
View cvResizeImage
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
#be careful it may change aspect ratio
out = pil_im.resize((128,128))
#show
out.show()
You can’t perform that action at this time.