Python OpenCV Facial Detection On OSX

Just a code snippet to demo Python script using OpenCV import cv2, time cap = cv2.VideoCapture(0) time.sleep(1) cascade = cv2.CascadeClassifier(“haarcascade_frontalface_alt.xml”) def detect(image): #faces = cascade.detectMultiScale(img, 1.1, 2, cv2.cv.CV_HAAR_SCALE_IMAGE, (20,20), (200,200)) faces = cascade.detectMultiScale(image) for _face in faces: cv2.rectangle(image, (_face[0], _face[1]), (_face[0]+_face[2], _face[1]+_face[3]), (255,255,255)) def repeat(): ret, image = cap.read() detect(image) cv2.imshow(“w1”, image) cv2.waitKey(1) while True:… Read More »

RequireJS + Zurb Foundation

“use strict”; require.config({ baseUrl: ‘static’, paths: { jquery: ‘bower_components/jquery/dist/jquery’, foundation: ‘bower_components/foundation/js/foundation’, }, shim: { ‘foundation’: { deps: [‘jquery’] }, } }); require([‘foundation’], function(f){ $(function(){ alert(1); }); });

django-rest-framework: api versioning

Django Rest Framework is a very solid api framework, but it doesn’t provide out-of-box versioning mechanism, here is my attempt to implement version specific APIs. The goal is to achieve something like http://localhost:8000/api/(resource)/ http://localhost:8000/api/v1/(resource)/ plus allowing clients to specify the version in request header (X-Version), here is how we did it. Structure in side the… Read More »

My Vim Configuration

I have been using vim for a few years now and had been using my very own vim configuration, mainly with Nerdtree and CtrlP, in the past few days I have discovered a well packaged vim configuration with lots of plugins. But shortly I discovered that the tab space is set to 2, which I… Read More »

Django CMS Haystack 2.0 Search Index

Currently django-cms-search doesn’t support haystack 2.0 yet, so here is my modified version to work on haystack 2.0 based on import datetime from haystack import indexes from cms.models.managers import PageManager from cms.models.pagemodel import Page from cms.models.pluginmodel import CMSPlugin class PageIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=False) pub_date = indexes.DateTimeField(model_attr=’publication_date’, null=True) login_required = indexes.BooleanField(model_attr=’login_required’) url = indexes.CharField(model_attr=’get_absolute_url’)… Read More »