diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0aa4a07 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*haar* diff --git a/cat.png b/cat.png deleted file mode 100644 index 2950f50..0000000 Binary files a/cat.png and /dev/null differ diff --git a/cat2.png b/cat2.png deleted file mode 100644 index 159fd27..0000000 Binary files a/cat2.png and /dev/null differ diff --git a/dir.py b/dir.py new file mode 100644 index 0000000..47f1135 --- /dev/null +++ b/dir.py @@ -0,0 +1,9 @@ + +import os + +cat_dir = "img/cat" +dog_dir = "img/dog" + +for directory in [cat_dir, dog_dir]: + for fn in os.listdir(directory): + print directory, fn \ No newline at end of file diff --git a/dog.png b/dog.png deleted file mode 100644 index 189cf78..0000000 Binary files a/dog.png and /dev/null differ diff --git a/dog2.png b/dog2.png deleted file mode 100644 index 2919b7d..0000000 Binary files a/dog2.png and /dev/null differ diff --git a/facer.rb b/facer.rb new file mode 100644 index 0000000..6e520b4 --- /dev/null +++ b/facer.rb @@ -0,0 +1,41 @@ +require 'rubygems' +require 'opencv' + +face_detectors = %w( + /usr/local/share/opencv/haarcascades/haarcascade_frontalface_default.xml +).collect { |fd| OpenCV::CvHaarClassifierCascade::load(fd) } + + +file_names = Dir.glob(ARGV[0] || "/Users/sandro/Ruby/image_labs/lib/facer/euruko2/*.jpg") + +file_names.each_with_index do |file_name,i| + + face_rectangles = [] + opencv_load = OpenCV::IplImage.load(file_name) + face_detectors.each_with_index do |face_detector,k| + face_detector.detect_objects(opencv_load).each do |rect| + face_rectangles << [ + rect.top_left.x, rect.top_left.y, + rect.top_right.x - rect.top_left.x, + rect.bottom_left.y - rect.top_left.y + ] + end + end + + File.open("#{File.basename(file_name)}.html","w") do |file| + file.write <<-HTML + +
+ #{ face_rectangles.collect do |(x,y,w,h)| + "" + end.join("\n") } + + + HTML + end + + puts "End #{file_name}" + +end + diff --git a/find_lines.py b/find_lines.py index d43b693..c497a97 100755 --- a/find_lines.py +++ b/find_lines.py @@ -1,42 +1,70 @@ #!/usr/bin/env python -import numpy as np -from math import pi -import cv2 -import cv -import sys +import cv2, cv, sys, math, os, numpy +from scipy.spatial import KDTree -if len(sys.argv) > 1: - fn = sys.argv[1] - print 'loading %s ...' % fn - img1 = cv2.imread(fn, 0) - img = cv.LoadImage(fn, cv.CV_LOAD_IMAGE_GRAYSCALE) - size = cv.GetSize(img) +def extractFeatures(label): - temp = cv.CreateImage(size, img.depth, img.nChannels) - print temp - cv.Smooth(img, temp) + directory = "img/" + label + "/" - canny = cv2.Canny(temp, 50, 100) - color_dst = cv2.cvtColor(canny, cv2.COLOR_GRAY2BGR) - lines = cv2.HoughLinesP(canny, 1, pi/90, 20, np.array([]), 5) + features = [] - try: - for line in lines[0]: - cv2.line(color_dst, (line[0], line[1]), (line[2], line[3]), cv.RGB(255,0,0), 1, 8) - except: - pass + for fn in os.listdir(directory): - print lines[0].size + img = cv2.imread(directory + fn, 0) - cv2.namedWindow("Original") - cv2.imshow("Original", img) + #temp = cv.CreateImage((100,100), cv.CV_8U, 1) + #cv.Smooth(img, temp) - cv2.namedWindow('Lines image') - cv2.imshow('Lines image', color_dst) + canny = cv2.Canny(img, 50, 100) + color_dst = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) - cv2.waitKey() + # find colored + black_pixels = numpy.count_nonzero(img) + + # find lines lines + lines = cv2.HoughLinesP(canny, 1, math.pi/360, 5, None, 10, 1) + + lengths = [] + angles = [] + try: + for line in lines[0]: + x1, y1, x2, y2 = line + #cv2.line(color_dst, (x1, y1), (x2, y2), cv.RGB(255,0,0), 1, 8) + length = int(math.sqrt(math.pow((x1-x2), 2) + math.pow((y1-y2), 2))) + lengths.append(length) + + angle = int(math.degrees(math.atan((y1-y2) / (x1-x2)))) + angles.append(angle) + except: + pass + + # print out everything + lines_count = len(lengths) + mid_length = sum(lengths) / lines_count + mid_angle = sum(angles) / lines_count + + features.append([[lines_count, mid_length, mid_angle, black_pixels], label]) + + #cv2.namedWindow("Original") + #cv2.imshow("Original", img) + + #cv2.namedWindow('Lines image ' + fn) + #cv2.imshow('Lines image ' + fn, color_dst) + + return features -else: - print "Please give a image path" \ No newline at end of file +if __name__ == "__main__": + arr = extractFeatures("cat") + extractFeatures("dog") + test_label = arr[0][1] + test_feature = arr[0][0] + labels = map(lambda a: a[1], arr)[1:] + features = map(lambda a: a[0], arr)[1:] + + tree = KDTree(features) + d, i = tree.query(test_feature) + + + print test_label + " is predicted to be a " + labels[i] + diff --git a/img/.DS_Store b/img/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/img/.DS_Store differ diff --git a/img/cat/1.png b/img/cat/1.png new file mode 100644 index 0000000..f5d2fa2 Binary files /dev/null and b/img/cat/1.png differ diff --git a/img/cat/10.png b/img/cat/10.png new file mode 100644 index 0000000..d5db6d1 Binary files /dev/null and b/img/cat/10.png differ diff --git a/img/cat/11.png b/img/cat/11.png new file mode 100644 index 0000000..7ec5c71 Binary files /dev/null and b/img/cat/11.png differ diff --git a/img/cat/12.png b/img/cat/12.png new file mode 100644 index 0000000..3d6faf4 Binary files /dev/null and b/img/cat/12.png differ diff --git a/img/cat/13.png b/img/cat/13.png new file mode 100644 index 0000000..97efb02 Binary files /dev/null and b/img/cat/13.png differ diff --git a/img/cat/14.png b/img/cat/14.png new file mode 100644 index 0000000..4fed457 Binary files /dev/null and b/img/cat/14.png differ diff --git a/img/cat/15.png b/img/cat/15.png new file mode 100644 index 0000000..3ab6f91 Binary files /dev/null and b/img/cat/15.png differ diff --git a/img/cat/16.png b/img/cat/16.png new file mode 100644 index 0000000..5ce067f Binary files /dev/null and b/img/cat/16.png differ diff --git a/img/cat/17.png b/img/cat/17.png new file mode 100644 index 0000000..ccca4a3 Binary files /dev/null and b/img/cat/17.png differ diff --git a/img/cat/18.png b/img/cat/18.png new file mode 100644 index 0000000..d528bbe Binary files /dev/null and b/img/cat/18.png differ diff --git a/img/cat/19.png b/img/cat/19.png new file mode 100644 index 0000000..aff8023 Binary files /dev/null and b/img/cat/19.png differ diff --git a/img/cat/2.png b/img/cat/2.png new file mode 100644 index 0000000..81e417b Binary files /dev/null and b/img/cat/2.png differ diff --git a/img/cat/20.png b/img/cat/20.png new file mode 100644 index 0000000..fe2d584 Binary files /dev/null and b/img/cat/20.png differ diff --git a/img/cat/21.png b/img/cat/21.png new file mode 100644 index 0000000..df90a5c Binary files /dev/null and b/img/cat/21.png differ diff --git a/img/cat/22.png b/img/cat/22.png new file mode 100644 index 0000000..1443637 Binary files /dev/null and b/img/cat/22.png differ diff --git a/img/cat/23.png b/img/cat/23.png new file mode 100644 index 0000000..37aa2db Binary files /dev/null and b/img/cat/23.png differ diff --git a/img/cat/24.png b/img/cat/24.png new file mode 100644 index 0000000..ea1a480 Binary files /dev/null and b/img/cat/24.png differ diff --git a/img/cat/25.png b/img/cat/25.png new file mode 100644 index 0000000..50ce53f Binary files /dev/null and b/img/cat/25.png differ diff --git a/img/cat/26.png b/img/cat/26.png new file mode 100644 index 0000000..6c5a51c Binary files /dev/null and b/img/cat/26.png differ diff --git a/img/cat/27.png b/img/cat/27.png new file mode 100644 index 0000000..29c263b Binary files /dev/null and b/img/cat/27.png differ diff --git a/img/cat/28.png b/img/cat/28.png new file mode 100644 index 0000000..b5f0db8 Binary files /dev/null and b/img/cat/28.png differ diff --git a/img/cat/29.png b/img/cat/29.png new file mode 100644 index 0000000..dd8f10c Binary files /dev/null and b/img/cat/29.png differ diff --git a/img/cat/3.png b/img/cat/3.png new file mode 100644 index 0000000..a3b1a53 Binary files /dev/null and b/img/cat/3.png differ diff --git a/img/cat/30.png b/img/cat/30.png new file mode 100644 index 0000000..843acb5 Binary files /dev/null and b/img/cat/30.png differ diff --git a/img/cat/31.png b/img/cat/31.png new file mode 100644 index 0000000..201a406 Binary files /dev/null and b/img/cat/31.png differ diff --git a/img/cat/32.png b/img/cat/32.png new file mode 100644 index 0000000..4c91e9c Binary files /dev/null and b/img/cat/32.png differ diff --git a/img/cat/33.png b/img/cat/33.png new file mode 100644 index 0000000..c61f711 Binary files /dev/null and b/img/cat/33.png differ diff --git a/img/cat/34.png b/img/cat/34.png new file mode 100644 index 0000000..d5b689f Binary files /dev/null and b/img/cat/34.png differ diff --git a/img/cat/35.png b/img/cat/35.png new file mode 100644 index 0000000..0f5d0de Binary files /dev/null and b/img/cat/35.png differ diff --git a/img/cat/36.png b/img/cat/36.png new file mode 100644 index 0000000..2dccd69 Binary files /dev/null and b/img/cat/36.png differ diff --git a/img/cat/37.png b/img/cat/37.png new file mode 100644 index 0000000..8d03b22 Binary files /dev/null and b/img/cat/37.png differ diff --git a/img/cat/38.png b/img/cat/38.png new file mode 100644 index 0000000..612dac4 Binary files /dev/null and b/img/cat/38.png differ diff --git a/img/cat/39.png b/img/cat/39.png new file mode 100644 index 0000000..9d35a1e Binary files /dev/null and b/img/cat/39.png differ diff --git a/img/cat/4.png b/img/cat/4.png new file mode 100644 index 0000000..4c086da Binary files /dev/null and b/img/cat/4.png differ diff --git a/img/cat/40.png b/img/cat/40.png new file mode 100644 index 0000000..a19812c Binary files /dev/null and b/img/cat/40.png differ diff --git a/img/cat/41.png b/img/cat/41.png new file mode 100644 index 0000000..69a98b0 Binary files /dev/null and b/img/cat/41.png differ diff --git a/img/cat/42.png b/img/cat/42.png new file mode 100644 index 0000000..df116d8 Binary files /dev/null and b/img/cat/42.png differ diff --git a/img/cat/43.png b/img/cat/43.png new file mode 100644 index 0000000..bdd369c Binary files /dev/null and b/img/cat/43.png differ diff --git a/img/cat/44.png b/img/cat/44.png new file mode 100644 index 0000000..1412a5a Binary files /dev/null and b/img/cat/44.png differ diff --git a/img/cat/45.png b/img/cat/45.png new file mode 100644 index 0000000..d66018c Binary files /dev/null and b/img/cat/45.png differ diff --git a/img/cat/46.png b/img/cat/46.png new file mode 100644 index 0000000..cccbdfe Binary files /dev/null and b/img/cat/46.png differ diff --git a/img/cat/47.png b/img/cat/47.png new file mode 100644 index 0000000..54a6aed Binary files /dev/null and b/img/cat/47.png differ diff --git a/img/cat/48.png b/img/cat/48.png new file mode 100644 index 0000000..42e850f Binary files /dev/null and b/img/cat/48.png differ diff --git a/img/cat/49.png b/img/cat/49.png new file mode 100644 index 0000000..f8cfda4 Binary files /dev/null and b/img/cat/49.png differ diff --git a/img/cat/5.png b/img/cat/5.png new file mode 100644 index 0000000..e77bc3a Binary files /dev/null and b/img/cat/5.png differ diff --git a/img/cat/50.png b/img/cat/50.png new file mode 100644 index 0000000..376b471 Binary files /dev/null and b/img/cat/50.png differ diff --git a/img/cat/51.png b/img/cat/51.png new file mode 100644 index 0000000..9b89c58 Binary files /dev/null and b/img/cat/51.png differ diff --git a/img/cat/52.png b/img/cat/52.png new file mode 100644 index 0000000..e2f3a11 Binary files /dev/null and b/img/cat/52.png differ diff --git a/img/cat/54.png b/img/cat/54.png new file mode 100644 index 0000000..e7ac183 Binary files /dev/null and b/img/cat/54.png differ diff --git a/img/cat/55.png b/img/cat/55.png new file mode 100644 index 0000000..27c3a6a Binary files /dev/null and b/img/cat/55.png differ diff --git a/img/cat/56.png b/img/cat/56.png new file mode 100644 index 0000000..f6ede4b Binary files /dev/null and b/img/cat/56.png differ diff --git a/img/cat/57.png b/img/cat/57.png new file mode 100644 index 0000000..921f054 Binary files /dev/null and b/img/cat/57.png differ diff --git a/img/cat/58.png b/img/cat/58.png new file mode 100644 index 0000000..7a59712 Binary files /dev/null and b/img/cat/58.png differ diff --git a/img/cat/59.png b/img/cat/59.png new file mode 100644 index 0000000..ec6ba49 Binary files /dev/null and b/img/cat/59.png differ diff --git a/img/cat/6.png b/img/cat/6.png new file mode 100644 index 0000000..7e0112e Binary files /dev/null and b/img/cat/6.png differ diff --git a/img/cat/60.png b/img/cat/60.png new file mode 100644 index 0000000..bf4a0c8 Binary files /dev/null and b/img/cat/60.png differ diff --git a/img/cat/61.png b/img/cat/61.png new file mode 100644 index 0000000..553a327 Binary files /dev/null and b/img/cat/61.png differ diff --git a/img/cat/62.png b/img/cat/62.png new file mode 100644 index 0000000..952732f Binary files /dev/null and b/img/cat/62.png differ diff --git a/img/cat/63.png b/img/cat/63.png new file mode 100644 index 0000000..793a5f4 Binary files /dev/null and b/img/cat/63.png differ diff --git a/img/cat/64.png b/img/cat/64.png new file mode 100644 index 0000000..b37c608 Binary files /dev/null and b/img/cat/64.png differ diff --git a/img/cat/65.png b/img/cat/65.png new file mode 100644 index 0000000..8410e61 Binary files /dev/null and b/img/cat/65.png differ diff --git a/img/cat/7.png b/img/cat/7.png new file mode 100644 index 0000000..1f7c5da Binary files /dev/null and b/img/cat/7.png differ diff --git a/img/cat/8.png b/img/cat/8.png new file mode 100644 index 0000000..f48b06d Binary files /dev/null and b/img/cat/8.png differ diff --git a/img/cat/9.png b/img/cat/9.png new file mode 100644 index 0000000..da7634b Binary files /dev/null and b/img/cat/9.png differ diff --git a/img/dog/1.png b/img/dog/1.png new file mode 100644 index 0000000..aea3814 Binary files /dev/null and b/img/dog/1.png differ diff --git a/img/dog/10.png b/img/dog/10.png new file mode 100644 index 0000000..8d79e2b Binary files /dev/null and b/img/dog/10.png differ diff --git a/img/dog/11.png b/img/dog/11.png new file mode 100644 index 0000000..6f1e0e1 Binary files /dev/null and b/img/dog/11.png differ diff --git a/img/dog/12.png b/img/dog/12.png new file mode 100644 index 0000000..aa4ef1d Binary files /dev/null and b/img/dog/12.png differ diff --git a/img/dog/13.png b/img/dog/13.png new file mode 100644 index 0000000..a6b84bb Binary files /dev/null and b/img/dog/13.png differ diff --git a/img/dog/14.png b/img/dog/14.png new file mode 100644 index 0000000..81a7e2b Binary files /dev/null and b/img/dog/14.png differ diff --git a/img/dog/15.png b/img/dog/15.png new file mode 100644 index 0000000..69aaca4 Binary files /dev/null and b/img/dog/15.png differ diff --git a/img/dog/16.png b/img/dog/16.png new file mode 100644 index 0000000..ec4911e Binary files /dev/null and b/img/dog/16.png differ diff --git a/img/dog/17.png b/img/dog/17.png new file mode 100644 index 0000000..50a5d18 Binary files /dev/null and b/img/dog/17.png differ diff --git a/img/dog/18.png b/img/dog/18.png new file mode 100644 index 0000000..4f4d834 Binary files /dev/null and b/img/dog/18.png differ diff --git a/img/dog/19.png b/img/dog/19.png new file mode 100644 index 0000000..ebc4cb7 Binary files /dev/null and b/img/dog/19.png differ diff --git a/img/dog/2.png b/img/dog/2.png new file mode 100644 index 0000000..ffa6fc0 Binary files /dev/null and b/img/dog/2.png differ diff --git a/img/dog/20.png b/img/dog/20.png new file mode 100644 index 0000000..e94c52b Binary files /dev/null and b/img/dog/20.png differ diff --git a/img/dog/21.png b/img/dog/21.png new file mode 100644 index 0000000..b2eb6c3 Binary files /dev/null and b/img/dog/21.png differ diff --git a/img/dog/22.png b/img/dog/22.png new file mode 100644 index 0000000..c55cc3f Binary files /dev/null and b/img/dog/22.png differ diff --git a/img/dog/23.png b/img/dog/23.png new file mode 100644 index 0000000..4dd14c1 Binary files /dev/null and b/img/dog/23.png differ diff --git a/img/dog/24.png b/img/dog/24.png new file mode 100644 index 0000000..14c919a Binary files /dev/null and b/img/dog/24.png differ diff --git a/img/dog/25.png b/img/dog/25.png new file mode 100644 index 0000000..2f4ee1b Binary files /dev/null and b/img/dog/25.png differ diff --git a/img/dog/26.png b/img/dog/26.png new file mode 100644 index 0000000..0d70713 Binary files /dev/null and b/img/dog/26.png differ diff --git a/img/dog/27.png b/img/dog/27.png new file mode 100644 index 0000000..cef11c5 Binary files /dev/null and b/img/dog/27.png differ diff --git a/img/dog/28.png b/img/dog/28.png new file mode 100644 index 0000000..6039765 Binary files /dev/null and b/img/dog/28.png differ diff --git a/img/dog/29.png b/img/dog/29.png new file mode 100644 index 0000000..55659a8 Binary files /dev/null and b/img/dog/29.png differ diff --git a/img/dog/3.png b/img/dog/3.png new file mode 100644 index 0000000..ed9ba37 Binary files /dev/null and b/img/dog/3.png differ diff --git a/img/dog/30.png b/img/dog/30.png new file mode 100644 index 0000000..84f258a Binary files /dev/null and b/img/dog/30.png differ diff --git a/img/dog/31.png b/img/dog/31.png new file mode 100644 index 0000000..7ad6c5d Binary files /dev/null and b/img/dog/31.png differ diff --git a/img/dog/32.png b/img/dog/32.png new file mode 100644 index 0000000..00cf110 Binary files /dev/null and b/img/dog/32.png differ diff --git a/img/dog/33.png b/img/dog/33.png new file mode 100644 index 0000000..8b72422 Binary files /dev/null and b/img/dog/33.png differ diff --git a/img/dog/34.png b/img/dog/34.png new file mode 100644 index 0000000..4d15bd4 Binary files /dev/null and b/img/dog/34.png differ diff --git a/img/dog/35.png b/img/dog/35.png new file mode 100644 index 0000000..e433d3e Binary files /dev/null and b/img/dog/35.png differ diff --git a/img/dog/36.png b/img/dog/36.png new file mode 100644 index 0000000..d8068d2 Binary files /dev/null and b/img/dog/36.png differ diff --git a/img/dog/37.png b/img/dog/37.png new file mode 100644 index 0000000..db6b481 Binary files /dev/null and b/img/dog/37.png differ diff --git a/img/dog/38.png b/img/dog/38.png new file mode 100644 index 0000000..db0eef2 Binary files /dev/null and b/img/dog/38.png differ diff --git a/img/dog/39.png b/img/dog/39.png new file mode 100644 index 0000000..4a0184e Binary files /dev/null and b/img/dog/39.png differ diff --git a/img/dog/4.png b/img/dog/4.png new file mode 100644 index 0000000..bd6de71 Binary files /dev/null and b/img/dog/4.png differ diff --git a/img/dog/40.png b/img/dog/40.png new file mode 100644 index 0000000..604d295 Binary files /dev/null and b/img/dog/40.png differ diff --git a/img/dog/41.png b/img/dog/41.png new file mode 100644 index 0000000..a98a2ce Binary files /dev/null and b/img/dog/41.png differ diff --git a/img/dog/43.png b/img/dog/43.png new file mode 100644 index 0000000..63cdd31 Binary files /dev/null and b/img/dog/43.png differ diff --git a/img/dog/44.png b/img/dog/44.png new file mode 100644 index 0000000..69ea750 Binary files /dev/null and b/img/dog/44.png differ diff --git a/img/dog/45.png b/img/dog/45.png new file mode 100644 index 0000000..29b40fa Binary files /dev/null and b/img/dog/45.png differ diff --git a/img/dog/46.png b/img/dog/46.png new file mode 100644 index 0000000..b58b32e Binary files /dev/null and b/img/dog/46.png differ diff --git a/img/dog/47.png b/img/dog/47.png new file mode 100644 index 0000000..7684a17 Binary files /dev/null and b/img/dog/47.png differ diff --git a/img/dog/48.png b/img/dog/48.png new file mode 100644 index 0000000..75b8b6f Binary files /dev/null and b/img/dog/48.png differ diff --git a/img/dog/49.png b/img/dog/49.png new file mode 100644 index 0000000..fe738c9 Binary files /dev/null and b/img/dog/49.png differ diff --git a/img/dog/5.png b/img/dog/5.png new file mode 100644 index 0000000..9db7f19 Binary files /dev/null and b/img/dog/5.png differ diff --git a/img/dog/50.png b/img/dog/50.png new file mode 100644 index 0000000..cbd10cd Binary files /dev/null and b/img/dog/50.png differ diff --git a/img/dog/51.png b/img/dog/51.png new file mode 100644 index 0000000..b823d74 Binary files /dev/null and b/img/dog/51.png differ diff --git a/img/dog/52.png b/img/dog/52.png new file mode 100644 index 0000000..1a00fad Binary files /dev/null and b/img/dog/52.png differ diff --git a/img/dog/53.png b/img/dog/53.png new file mode 100644 index 0000000..7089f5d Binary files /dev/null and b/img/dog/53.png differ diff --git a/img/dog/54.png b/img/dog/54.png new file mode 100644 index 0000000..4581dcc Binary files /dev/null and b/img/dog/54.png differ diff --git a/img/dog/55.png b/img/dog/55.png new file mode 100644 index 0000000..c9192dd Binary files /dev/null and b/img/dog/55.png differ diff --git a/img/dog/56.png b/img/dog/56.png new file mode 100644 index 0000000..1b0267d Binary files /dev/null and b/img/dog/56.png differ diff --git a/img/dog/57.png b/img/dog/57.png new file mode 100644 index 0000000..9a27022 Binary files /dev/null and b/img/dog/57.png differ diff --git a/img/dog/58.png b/img/dog/58.png new file mode 100644 index 0000000..1cfba41 Binary files /dev/null and b/img/dog/58.png differ diff --git a/img/dog/59.png b/img/dog/59.png new file mode 100644 index 0000000..0c40a55 Binary files /dev/null and b/img/dog/59.png differ diff --git a/img/dog/6.png b/img/dog/6.png new file mode 100644 index 0000000..c3d0b81 Binary files /dev/null and b/img/dog/6.png differ diff --git a/img/dog/60.png b/img/dog/60.png new file mode 100644 index 0000000..e069f57 Binary files /dev/null and b/img/dog/60.png differ diff --git a/img/dog/61.png b/img/dog/61.png new file mode 100644 index 0000000..4269f2d Binary files /dev/null and b/img/dog/61.png differ diff --git a/img/dog/62.png b/img/dog/62.png new file mode 100644 index 0000000..57f858c Binary files /dev/null and b/img/dog/62.png differ diff --git a/img/dog/63.png b/img/dog/63.png new file mode 100644 index 0000000..e80c861 Binary files /dev/null and b/img/dog/63.png differ diff --git a/img/dog/64.png b/img/dog/64.png new file mode 100644 index 0000000..9ddf64a Binary files /dev/null and b/img/dog/64.png differ diff --git a/img/dog/7.png b/img/dog/7.png new file mode 100644 index 0000000..6922a37 Binary files /dev/null and b/img/dog/7.png differ diff --git a/img/dog/8.png b/img/dog/8.png new file mode 100644 index 0000000..b156b3a Binary files /dev/null and b/img/dog/8.png differ diff --git a/img/dog/9.png b/img/dog/9.png new file mode 100644 index 0000000..e241d0b Binary files /dev/null and b/img/dog/9.png differ diff --git a/surf.py b/surf.py new file mode 100644 index 0000000..fac6a85 --- /dev/null +++ b/surf.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import cv2, sys + +#Create object to read images from camera 0 +#cam = cv2.VideoCapture(0) + +#Initialize SURF object +surf = cv2.SURF(85) + +#Set desired radius +rad = 2 + +#while True: +#Get image from webcam and convert to greyscale +#ret, img = cam.read() +fn = sys.argv[1] +gray = cv2.imread(fn, 0) +#gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + +#Detect keypoints and descriptors in greyscale image +keypoints, descriptors = surf.detect(gray) + +#Draw a small red circle with the desired radius +#at the (x, y) location for each feature found +for kp in keypoints: + x = int(kp.pt[0]) + y = int(kp.pt[1]) + cv2.circle(img, (x, y), rad, (0, 0, 255)) + +#Display colour image with detected features +cv2.imshow("features", img) + +#Sleep infinite loop for ~10ms +#Exit if user presses