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/20 04:39:02 UTC

svn commit: r1424280 - in /labs/alike/trunk: demo/demo-conf.xml demo/run_desc_extractor.py src/python/conf.py src/python/desc_extractor.py

Author: koji
Date: Thu Dec 20 03:39:02 2012
New Revision: 1424280

URL: http://svn.apache.org/viewvc?rev=1424280&view=rev
Log:
create xml for settings and move parameters to the xml. Currently, only python programs use the xml config

Added:
    labs/alike/trunk/demo/demo-conf.xml
    labs/alike/trunk/src/python/conf.py
Modified:
    labs/alike/trunk/demo/run_desc_extractor.py
    labs/alike/trunk/src/python/desc_extractor.py

Added: labs/alike/trunk/demo/demo-conf.xml
URL: http://svn.apache.org/viewvc/labs/alike/trunk/demo/demo-conf.xml?rev=1424280&view=auto
==============================================================================
--- labs/alike/trunk/demo/demo-conf.xml (added)
+++ labs/alike/trunk/demo/demo-conf.xml Thu Dec 20 03:39:02 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<config>
+
+  <visualDescriptorsExtraction>
+    <!-- method should be one of sift, surf or orb -->
+    <method>orb</method>
+    <descDir>
+      <normalfs>desc</normalfs>
+      <hdfs>input-vectors</hdfs>
+    </descDir>
+  </visualDescriptorsExtraction>
+
+  <clustering k="1000">
+    <outDir>output-clusters</outDir>
+    <cluster method="kmeans">
+      <param name="maxIter">10</param>
+      <param name="cd">0.01</param>
+      <param name="init">init-clusters</param>
+    </cluster>
+    <dump file="result-centroids.txt"/>
+  </clustering>
+
+  <vectorQuantization>
+    <fieldNames>
+      <imageFileFieldName>imgFile</imageFileFieldName>
+      <queryFieldName>query</queryFieldName>
+      <histogramFieldName>histogram</histogramFieldName>
+    </fieldNames>
+    <indexer class="org.apache.alike.SolrStandardXMLIndexer">
+      <histogramMatcher class="LeastSquaresHistogramMatcher"/>
+      <param name="file">solr-demo-data.xml</param>
+    </indexer>
+  </vectorQuantization>
+
+</config>

Modified: labs/alike/trunk/demo/run_desc_extractor.py
URL: http://svn.apache.org/viewvc/labs/alike/trunk/demo/run_desc_extractor.py?rev=1424280&r1=1424279&r2=1424280&view=diff
==============================================================================
--- labs/alike/trunk/demo/run_desc_extractor.py (original)
+++ labs/alike/trunk/demo/run_desc_extractor.py Thu Dec 20 03:39:02 2012
@@ -17,13 +17,16 @@
 
 import os
 import desc_extractor as de
+import conf
 
 IMAGES_DIR = 'ukbench/full'
 MAX_IMGS = 100 * 4
 
+cfg = conf.Conf('demo-conf.xml')
+
 for fl in os.listdir(IMAGES_DIR)[:MAX_IMGS]:
 
   fi = IMAGES_DIR + '/' + fl
   fo = 'desc/' + fl[:fl.find('.')] + '.txt'
 
-  de.extract_desc(fi, fo)
+  de.extract_desc(cfg.detector(), fi, fo)

Added: labs/alike/trunk/src/python/conf.py
URL: http://svn.apache.org/viewvc/labs/alike/trunk/src/python/conf.py?rev=1424280&view=auto
==============================================================================
--- labs/alike/trunk/src/python/conf.py (added)
+++ labs/alike/trunk/src/python/conf.py Thu Dec 20 03:39:02 2012
@@ -0,0 +1,41 @@
+"""
+ 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.
+"""
+
+from xml.etree.ElementTree import *
+import cv2
+
+class Conf:
+
+  def __init__(self, confFile):
+    tree = parse(confFile)
+    self.config = tree.getroot()
+    self.m = self.config.findtext('.//visualDescriptorsExtraction/method')
+    if self.m == 'sift':
+      self.det = cv2.SIFT()
+    elif self.m == 'surf':
+      # self.det = cv2.SURF(400,4,2,1)   # extended (dim=64)
+      self.det = cv2.SURF(400,4,2,0)   # dim=64
+    elif self.m == 'orb':
+      self.det = cv2.ORB(400)
+    else:
+      return None
+
+  def method(self):
+    return self.m
+
+  def detector(self):
+    return self.det

Modified: labs/alike/trunk/src/python/desc_extractor.py
URL: http://svn.apache.org/viewvc/labs/alike/trunk/src/python/desc_extractor.py?rev=1424280&r1=1424279&r2=1424280&view=diff
==============================================================================
--- labs/alike/trunk/src/python/desc_extractor.py (original)
+++ labs/alike/trunk/src/python/desc_extractor.py Thu Dec 20 03:39:02 2012
@@ -19,10 +19,7 @@ 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
+def extract_desc(detector, fi, fo):
 
   im_orig = cv2.imread(fi)
   im_lowers = cv2.pyrDown(im_orig)



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