You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by ko...@apache.org on 2012/12/09 16:11:56 UTC

svn commit: r1419003 - in /labs/alike/trunk: ./ demo/ demo/README.txt demo/desc/ demo/run_desc_extractor.py pom.xml src/ src/main/ src/main/java/ src/main/resources/ src/python/ src/python/desc_extractor.py src/test/ src/test/java/ src/test/resources/

Author: koji
Date: Sun Dec  9 15:11:55 2012
New Revision: 1419003

URL: http://svn.apache.org/viewvc?rev=1419003&view=rev
Log:
add python programs

Added:
    labs/alike/trunk/demo/   (with props)
    labs/alike/trunk/demo/README.txt
    labs/alike/trunk/demo/desc/   (with props)
    labs/alike/trunk/demo/run_desc_extractor.py
    labs/alike/trunk/pom.xml
    labs/alike/trunk/src/
    labs/alike/trunk/src/main/
    labs/alike/trunk/src/main/java/
    labs/alike/trunk/src/main/resources/
    labs/alike/trunk/src/python/
    labs/alike/trunk/src/python/desc_extractor.py
    labs/alike/trunk/src/test/
    labs/alike/trunk/src/test/java/
    labs/alike/trunk/src/test/resources/
Modified:
    labs/alike/trunk/   (props changed)

Propchange: labs/alike/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Dec  9 15:11:55 2012
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Propchange: labs/alike/trunk/demo/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Dec  9 15:11:55 2012
@@ -0,0 +1,2 @@
+101_ObjectCategories
+101_ObjectCategories.tar.gz

Added: labs/alike/trunk/demo/README.txt
URL: http://svn.apache.org/viewvc/labs/alike/trunk/demo/README.txt?rev=1419003&view=auto
==============================================================================
--- labs/alike/trunk/demo/README.txt (added)
+++ labs/alike/trunk/demo/README.txt Sun Dec  9 15:11:55 2012
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+1. change to this directory
+
+$ cd demo
+
+2. download Caltech 101
+
+$ wget http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz
+
+3. unzip the tar file
+
+$ tar xvzf 101_ObjectCategories.tar.gz
+
+4. remove existing subdirectories of desc directory before running extoractor
+
+$ rm -Rf desc/*
+
+5. run extractor program
+
+$ export PYTHONPATH=../src/python; python run_desc_extractor.py

Propchange: labs/alike/trunk/demo/desc/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Dec  9 15:11:55 2012
@@ -0,0 +1 @@
+*

Added: labs/alike/trunk/demo/run_desc_extractor.py
URL: http://svn.apache.org/viewvc/labs/alike/trunk/demo/run_desc_extractor.py?rev=1419003&view=auto
==============================================================================
--- labs/alike/trunk/demo/run_desc_extractor.py (added)
+++ labs/alike/trunk/demo/run_desc_extractor.py Sun Dec  9 15:11:55 2012
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import desc_extractor as de
+
+IMAGES_DIR = '101_ObjectCategories'
+SUB_DIRS = ['Faces', 'dollar_bill', 'chair', 'cougar_face', 'elephant', 'car_side']
+MAX_IMGS = 30
+
+for sub_dir in SUB_DIRS:
+  isd = IMAGES_DIR + '/' + sub_dir
+  os.makedirs('desc/' + sub_dir)
+  for fl in os.listdir(isd)[:MAX_IMGS]:
+
+    fi = IMAGES_DIR + '/' + sub_dir + '/' + fl
+    fo = 'desc/' + sub_dir + '/' + fl[:fl.find('.')] + '.txt'
+
+    de.extract_desc(fi, fo)

Added: labs/alike/trunk/pom.xml
URL: http://svn.apache.org/viewvc/labs/alike/trunk/pom.xml?rev=1419003&view=auto
==============================================================================
--- labs/alike/trunk/pom.xml (added)
+++ labs/alike/trunk/pom.xml Sun Dec  9 15:11:55 2012
@@ -0,0 +1,19 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.alike</groupId>
+  <artifactId>alike-core</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <name>Apache alike</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.mahout</groupId>
+      <artifactId>mahout-core</artifactId>
+      <version>0.8-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-jcl</artifactId>
+      <version>1.7.2</version>
+    </dependency>
+  </dependencies>
+</project>

Added: labs/alike/trunk/src/python/desc_extractor.py
URL: http://svn.apache.org/viewvc/labs/alike/trunk/src/python/desc_extractor.py?rev=1419003&view=auto
==============================================================================
--- labs/alike/trunk/src/python/desc_extractor.py (added)
+++ labs/alike/trunk/src/python/desc_extractor.py Sun Dec  9 15:11:55 2012
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import cv2
+import numpy as np
+
+def extract_desc(fi, fo):
+
+  # detector = cv2.SURF(400,4,2,1) # extended (dim=128)
+  detector = cv2.SURF(400,4,2,0)   # dim=64
+
+  im_orig = cv2.imread(fi)
+  im_lowers = cv2.pyrDown(im_orig)
+  im_gray = cv2.cvtColor(im_lowers,cv2.COLOR_BGR2GRAY)
+  kps, descs = detector.detectAndCompute(im_gray,None)
+
+  fdo = open(fo, 'w')
+
+  fdo.write(fi + '\n')
+  fdo.write(str(len(descs)) + '\n')
+  for desc in descs:
+    for v in desc:
+      fdo.write(str(v) + ' ')
+    fdo.write('\n')
+
+  fdo.close



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org