Skip to content

Instantly share code, notes, and snippets.

View akameco's full-sized avatar

akameco akameco

  • Japan, Tokyo
View GitHub Profile
import cv2
import sys
import os.path
def detect(filename, cascade_file="./lbpcascade_animeface.xml"):
# ファイルがなければエラー
if not os.path.isfile(cascade_file):
raise RuntimeError("{}: not found".format(cascade_file))
# カスケードのロード
@akameco
akameco / detect-movie.py
Created November 2, 2016 03:24
OpenCV+anime faceで動画のアニメ顔認識
# coding=utf-8
import sys
import os.path
import datetime
import numpy as np
import cv2
def export(filename, output="output.m4v"):
@akameco
akameco / main.py
Created November 2, 2016 15:37
OpenCVで教師データの作成
# coding=utf-8
import sys
import numpy as np
import cv2
def split_image(filename):
cascade_file="./lbpcascade_animeface.xml"
cascade = cv2.CascadeClassifier(cascade_file)
if cascade.empty():
@akameco
akameco / iterator.js
Created February 3, 2017 22:49
クラスとイテレラブル
class Store {
constructor() {
this.obj = {}
}
get(key) {
return this.obj[key]
}
set(key, val) {
this.obj[key] = val
}
@akameco
akameco / pandas.ipynb
Created February 14, 2017 07:39
pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// @flow
import React from 'react';
import styled, {keyframes, css} from 'styled-components';
function transform(percent: number, scale: number = 1) {
return css`
${percent}% {
transform: scale(${scale});
}
`;
// @flow
import * as I from 'immutable'
export function defineRecord<T: Object>(
name: string,
spec: T
): (init: $Shape<T>) => Record<T> {
return I.Record(spec, name)
}
@akameco
akameco / App.js
Created July 28, 2017 17:17
Typing Demo
// @flow
import React, { Component } from 'react'
import EventListener from 'react-event-listener'
import lodash from 'lodash'
import catNames from './catNames'
import './App.css'
type TargetType = string
const Target = ({ word, active }: { word: TargetType, active: boolean }) =>
@akameco
akameco / test.js
Last active August 14, 2017 19:40
mock console.log
// @flow
const sum = (a, b) => a + b
test('sum', () => {
expect(sum(1, 2)).toBe(3)
})
const spyLog = jest.spyOn(console, 'log')
spyLog.mockImplementation(x => x)