Пример #1
0
def tag(photo):

    global dindex, uindex, ignored

    url = photo["photo"]["source"]

    if url in dindex:
        detection = dindex[url]
    else:
        return

    detection = dindex[url]
    pos = 0
    for tag in photo["photo"]["tags"]["data"]:
        width = int(photo["photo"]["width"])
        height = int(photo["photo"]["height"])

        tx = int(float(tag["x"]) * width / 100)
        ty = int(float(tag["y"]) * height / 100)

        det_faces = [common.convert_to_img_coords(t, width, height) for t in detection["tags"]]
        ix = common.is_point_contained(det_faces, tx, ty)

        if not (tag["id"] in uindex):
            ignored += 1

        if ix >= 0 and tag["id"] in uindex:
            face_user = "******" + tag["id"] + "@wicknicks"
            # print 'Found', face_user, 'at', ix, 'tid:', detection['tags'][ix]['tid']
            save_tag(face_user, detection["tags"][ix]["tid"], url)
            time.sleep(0.5)
        # else:
        #  print 'No takers for', pos
        pos += 1
Пример #2
0
def match_faces(test_pic): 
  global uindex
  
  url = test_pic['photo']['source']
  
  #detection_results = find_detection_result(url)
  #if detection_results == None:
  #  detection_results = detect_faces(url)
  #  save_detection_results(detection_results)
  # print 'Faces: ', len(detection_results['tags'])

  detection_results = detect_faces(url)
  
  width = detection_results['width']
  height = detection_results['height']

  det_faces = [convert_to_img_coords(t, width, height) for t in detection_results['tags']]

  global count, user_id
  
  pos = 0
  for tag in test_pic['photo']['tags']['data']:
    tx = int (float(tag['x']) * width / 100)
    ty = int (float(tag['y']) * height / 100)
    ix = common.is_point_contained(det_faces, tx, ty)
    
    if ix >= 0 and tag['id'] in uindex :
      face_user = '******' + tag['id'] + '@wicknicks';
      # print 'Found', face_user, 'at', ix, 'tid:', detection_results['tags'][ix]['tid']
      save_tag(face_user, detection_results['tags'][ix]['tid'], url);
    pos += 1
    if (tag['id'] == user_id and ix != -1): count = count+1
Пример #3
0
def match_faces(photo, user_id):
  url = photo['source']
  rt = False

  dresults = detect(photo)
  if dresults == None: return rt;
  
  width = dresults['width']
  height = dresults['height']

  det_faces = [detector.convert_to_img_coords(t, width, height) for t in dresults['tags']]
  for tag in photo['tags']['data']:
    tx = int ( float(tag['x']) * width / 100 )
    ty = int ( float(tag['y']) * height / 100 )
    ix = common.is_point_contained(det_faces, tx, ty)
    #if ix < 0:
    #  print 'Did not find user', tag['name'] ,'in', photo['id']
    if ix >= 0 and tag['id'] == user_id:
      face_user = '******' + tag['id'] + '@setoreh'
      detector.save_tag(face_user, dresults['tags'][ix]['tid'], url);
      #print 'Saving ', face_user, url
      rt = rt or True

  return rt