Browse Source

Add ee4h, add bits to script file, near function complete HTK wrapper

master
Sam Black 11 years ago
parent
commit
94cdfae6d3
3 changed files with 42 additions and 0 deletions
  1. +42
    -0
      ee4h/count_dark_pixels.py
  2. BIN
      ee4h/ffs.JPG
  3. BIN
      ee4h/mouth.bmp

+ 42
- 0
ee4h/count_dark_pixels.py View File

@@ -0,0 +1,42 @@
#! /usr/bin/env python

import sys

# import OpenCV bindings
from opencv.cv import *
from opencv.highgui import *

# Give Window a name
win_name = "Test"

# Load source image and create blank image objects
if sys.argv[1] != None:
file = sys.argv[1]
else:
file = "../../face.bmp"
source = cvLoadImage (file)
grey = cvCreateImage (cvSize (source.width, source.height), 8, 1)
output = cvCreateImage (cvSize (source.width, source.height), 8, 1)

# Convert to greyscale
cvCvtColor (source, grey, CV_BGR2GRAY)

# Convert to black and white based on threshold of 50
cvThreshold(grey, output, 50, 255, CV_THRESH_BINARY);

count = 0

# Count number of dark pixels
for i in output:
for j in i:
if j == 255:
count += 1

print "Number of dark pixels: " + str(count)

# Display output
cvNamedWindow (win_name, CV_WINDOW_AUTOSIZE)
cvShowImage(win_name, output)

# Quit on keypress
cvWaitKey (0)

BIN
ee4h/ffs.JPG View File

Before After
Width: 256  |  Height: 64  |  Size: 2.9 KiB

BIN
ee4h/mouth.bmp View File

Before After

Loading…
Cancel
Save