def detect():
  ''' Given a classifier, return a set of locations
      from which we will draw on our final image
      strong = (h, curr_fpr, curr_fnr, big_theta)
      h = (alpha_t, h_t, featureIdx , polar, thresh)


  '''
  cascade = np.load("./data/cascades/cascade_2000.npy")
  feat_index = np.load("./data/features/feat_index.npy")
  test_idx, test_imgs = trim()
  
 

  for strong in cascade:
    h         = strong[0]
    big_theta = strong[3]
    h_test    = [] # all rounds of boosting
    h_single  = np.zeros(len(test_imgs)) # One round of boosting

    for weak in h:
      alpha_t   = weak[0]
      thresh    = weak[4]
      parity    = weak[3]
      featureIdx= weak[2]
      feature   = feat_index[featureIdx]

      for i in range(len(test_imgs)):
        img_gray = test_imgs[i]
        h_single[i] = apply_weak_classifier(img_gray,thresh,parity,feature)

      h_test.append(tuple( (alpha_t, h_single) ))
    signed_test = calc_classifiers(h_test,big_theta)

    # remove all the zeros in the signed_test
    remove_idx = []
    for j in range(len(signed_test)):
      if signed_test[j] == 0 :
        remove_idx.append(j)

    # remove images and corresponding indexes
    test_imgs = np.delete(test_imgs, remove_idx, axis = 0)
    test_idx  = np.delete(test_idx, remove_idx, axis = 0)


  draw("out.png",test_idx)
def apply_validation(h,valid,feat_index,label,truth,big_theta):
  ''' CHANGED ZERO TO NEG
    Input:
        h = (alpha, h_t, featureIdx, polar, thresh) 2d array T entries
        valid = dictionary containing all validation rectangles
        feat_index = lookup table for all features
        label = truth vector for all training images

      Output:
        Current false positive and false negative rates
      Find big theta, and run the validation set and 
      training set on that
  '''
  pos_list = valid["pos"]
  neg_list = valid["neg"]
  combined = pos_list+neg_list # first half is positive, second is negative

  h_valid  = [] # all rounds of boosting
  h_valid_temp = np.zeros(len(combined)) # One round of boosting
  
  # create the shfited classifier
  for t in range(len(h)):
    alpha_t = h[t][0]
    thresh  = h[t][4]
    parity  = h[t][3]
    feature = feat_index[h[t][2]]
    # creates h_i
    print "Applying the weak classificaiton to a validation data"
    for i in range(len(combined)):
      # for each image in combined, apply the weak classifier
      img_gray = combined[i]

      # classified array of 1,0, 800x1
      h_valid_temp[i] = apply_weak_classifier(img_gray,thresh,parity,feature)
    
    h_valid.append(tuple(( alpha_t, h_valid_temp )))

  # print "MY BIG THETA IS :", big_theta

  return test_big_theta(big_theta, h_valid, truth, label, h)