Example #1
0
def img_sum(img, plane_index=0):
  boxm2_batch.init_process("vilImageSumProcess")
  boxm2_batch.set_input_from_db(0,img)
  boxm2_batch.set_input_unsigned(1,plane_index)
  boxm2_batch.run_process()
  (id,type) = boxm2_batch.commit_output(0)
  value = boxm2_batch.get_output_double(id)
  return value
    batch.run_process()
    (imid, imtype) = batch.commit_output(0)
    norm_image = dbvalue(imid, imtype)

    # register the input image to the exp image, find the translation that needs to be added to img
    # so that mutual info is max with exp img of the world
    batch.init_process("ihogRegisterTranslationalProcess")
    batch.set_input_from_db(0, s_exp_img)      # from img
    batch.set_input_from_db(1, norm_image)  # to img
    batch.set_input_int(2, exh_search_rad)
    batch.run_process()
    (id, type) = batch.commit_output(0)
    tx = dbvalue(id, type)
    (id, type) = batch.commit_output(1)
    ty = dbvalue(id, type)
    offset_x = batch.get_output_double(tx.id)
    offset_y = batch.get_output_double(ty.id)

    [head, tail] = os.path.split(words[0])
    [iname, ext] = os.path.splitext(tail)

    off_fname = output_path + "/" + iname + "_offsets.txt"
    print off_fname

    batch.init_process("bhdfsGenerateFileProcess")
    batch.set_input_string(0, off_fname)
    batch.set_input_string(1, str(offset_x) + " " + str(offset_y) + "\n")
    batch.run_process()

mytime = time.clock()
print "time passed: " + str(mytime) + " secs which is " + str(mytime / 60) + " minutes.\n"