[Tickets #10420] Re: Face similarity indexing is incorrect/broken

bugs at horde.org bugs at horde.org
Tue Oct 4 07:53:04 UTC 2011


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/10420
------------------------------------------------------------------------------
  Ticket             | 10420
  Updated By         | thpo+horde at dotrc.de
  Summary            | Face similarity indexing is incorrect/broken
  Queue              | Ansel
  Version            | Git master
  Type               | Bug
  State              | Assigned
  Priority           | 1. Low
  Milestone          | 2.0
  Patch              |
  Owners             | Michael Rubinsky
------------------------------------------------------------------------------


thpo+horde at dotrc.de (2011-10-04 07:53) wrote:

I've seen you have started to implement the correct face indexing in  
git. Great! Just a hint: when you create the face indexes you will  
miss out the last one (str_len - word_len == 0).

Furthermore, there ist a call to a function "updatec" that does not exist.
And in getSignatureMatches() the f.image_id has to be part of the "GROUP BY".

Here is my diff for these issues:
--- a/ansel/lib/Faces/Base.php
+++ b/ansel/lib/Faces/Base.php
@@ -555,7 +555,7 @@ class Ansel_Faces_Base
          try {
              $GLOBALS['ansel_db']->update('UPDATE ansel_images SET  
image_faces = '
                  . count($fids) . ' WHERE image_id = ' . $image->id);
-            $GLOBALS['ansel_db']->updatec('UPDATE ansel_shares '
+            $GLOBALS['ansel_db']->update('UPDATE ansel_shares '
                  . 'SET attribute_faces = attribute_faces + ' . count($fids)
                  . ' WHERE share_id = ' . $image->gallery);
          } catch (Horde_Db_Exception $e) {
@@ -654,7 +654,7 @@ class Ansel_Faces_Base
          $str_len = strlen($signature);
          $GLOBALS['ansel_db']->delete('DELETE FROM ansel_faces_index  
WHERE face_id = ' . $face_id);
          $q = 'INSERT INTO ansel_faces_index (face_id,  
index_position, index_part) VALUES (?, ?, ?)';
-        for ($i = 0; $i < $str_len - $word_len; $i++) {
+        for ($i = 0; $i <= $str_len - $word_len; $i++) {
              $data = array(
                  $face_id,
                  $i,
@@ -807,7 +807,7 @@ class Ansel_Faces_Base
          $word_len = $GLOBALS['conf']['faces']['search'];
          $str_len = strlen($signature);
          $indexes = array();
-        for ($i = 0; $i < $str_len - $word_len; $i++) {
+        for ($i = 0; $i <= $str_len - $word_len; $i++) {
              $sig = new Horde_Db_Value_Binary(substr($signature, $i,  
$word_len));
              $indexes[] = '(index_position = ' . $i . ' AND  
index_part = ' . $sig->quote($GLOBALS['ansel_db']) . ')';
          }
@@ -822,7 +822,7 @@ class Ansel_Faces_Base
          if ($indexes) {
              $sql .= ' AND (' . implode(' OR ', $indexes) . ')';
          }
-        $sql .= ' GROUP BY i.face_id, f.face_name HAVING  
count(i.face_id) > 0 '
+        $sql .= ' GROUP BY i.face_id, f.face_name, f.image_id HAVING  
count(i.face_id) > 0 '
              . 'ORDER BY count(i.face_id) DESC';
          $sql = $GLOBALS['ansel_db']->addLimitOffset(
              $sql,






More information about the bugs mailing list