Browse Source

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

master
Sam Black 14 years ago
parent
commit
94cdfae6d3
  1. 42
      ee4h/count_dark_pixels.py
  2. BIN
      ee4h/ffs.JPG
  3. BIN
      ee4h/mouth.bmp

42
ee4h/count_dark_pixels.py

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
ee4h/mouth.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Loading…
Cancel
Save