def __init__(self, index, type):
        self.id = index  # unsigned integer
        self.type = type  # string


dir = "/Users/isa/Experiments/super3d/scene/expectedImgs_2"
test_frames = [8, 112, 96, 208]

for frame in test_frames:
    boxm_batch.init_process("vilLoadImageViewProcess")
    boxm_batch.set_input_string(0, dir + "/predicted_img_mask_%(#)05d.tiff" % {"#": frame})
    boxm_batch.run_process()
    (id, type) = boxm_batch.commit_output(0)
    vis_img = dbvalue(id, type)

    boxm_batch.init_process("vilThresholdImageProcess")
    boxm_batch.set_input_from_db(0, vis_img)
    boxm_batch.set_input_float(1, 0.99)
    boxm_batch.set_input_bool(2, True)
    boxm_batch.run_process()
    (id, type) = boxm_batch.commit_output(0)
    mask_img = dbvalue(id, type)

    boxm_batch.init_process("vilSaveImageViewProcess")
    boxm_batch.set_input_from_db(0, mask_img)
    boxm_batch.set_input_string(1, dir + "/binary_mask_%(#)05d.tiff" % {"#": frame})
    boxm_batch.run_process()

    boxm_batch.remove_data(vis_img.id)
    boxm_batch.remove_data(mask_img.id)
  boxm_batch.run_process();

  

  boxm_batch.init_process("vilLoadImageViewProcess");
  boxm_batch.set_input_string(0,original_img_dir + "/frames_%(#)05d.tif"%{"#":frame});
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  true_img = dbvalue(id,type);

  boxm_batch.init_process("vilImageSSDProcess");
  boxm_batch.set_input_from_db(0,pred_img_byte);
  boxm_batch.set_input_from_db(1,true_img);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  ssd = dbvalue(id,type);
  ssd_val = boxm_batch.get_output_float(ssd.id);
  
  ssd_vals.append(ssd_val);
  ssd_avg = ssd_avg + ssd_val;
  
  boxm_batch.remove_data(pred_img.id)
  boxm_batch.remove_data(true_img.id)
  
  
ssd_file = dir + "/ssd.txt"
f = open(ssd_file, 'w');
f.write(str(ssd_vals));
f.write("\n");
f.write(str(ssd_avg/(npixels*len(test_frames))));
f.close();
Beispiel #3
0
    (id, type) = boxm_batch.commit_output(0)
    image = dbvalue(id, type)

    boxm_batch.init_process("vilImageSizeProcess")
    boxm_batch.set_input_from_db(0, image)
    boxm_batch.run_process()
    (ni_id, type) = boxm_batch.commit_output(0)
    (nj_id, type) = boxm_batch.commit_output(1)
    ni = boxm_batch.get_input_unsigned(ni_id)
    nj = boxm_batch.get_input_unsigned(nj_id)
    if ni > nj:
        sizes.append(ni)
    else:
        sizes.append(nj)

    boxm_batch.remove_data(image.id)

# set up the connectivity table to be used for computing tracks from the
# matches
boxm_batch.init_process("baplCreateConnTableProcess")
boxm_batch.set_input_int(0, img_cnt)
boxm_batch.run_process()
(id, type) = boxm_batch.commit_output(0)
conn_table = dbvalue(id, type)

for i in range(0, img_cnt, 1):
    print("Loading Image")
    boxm_batch.init_process("vilLoadImageViewProcess")
    boxm_batch.set_input_string(0, img_path + img_name % (i * every_nth + 1))
    boxm_batch.run_process()
    (id, type) = boxm_batch.commit_output(0)
  boxm_batch.set_input_unsigned(2,1280);
  boxm_batch.set_input_unsigned(3,720);
  boxm_batch.set_input_bool(4,0);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  expected = dbvalue(id,type);
  (id,type) = boxm_batch.commit_output(1);
  mask = dbvalue(id,type);
  
  print("saving expected image");
  boxm_batch.init_process("vilSaveImageViewProcess");
  boxm_batch.set_input_from_db(0,expected);
  boxm_batch.set_input_string(1,expected_fname % it);
  boxm_batch.run_process();

  boxm_batch.remove_data(expected.id);
  boxm_batch.remove_data(mask.id);
    
  if ( (do_refine) & (it+1 < num_its) ):    
    print("Refining Scene");
    boxm_batch.init_process("boxmRefineSceneProcess");
    boxm_batch.set_input_from_db(0,scene);
    boxm_batch.set_input_float(1,refine_prob);
    boxm_batch.set_input_bool(2,False);
    boxm_batch.run_process();
  
  boxm_batch.remove_data(cam.id);
  boxm_batch.remove_data(image.id);

  print("Save Scene");
  boxm_batch.init_process("boxmSaveOccupancyRawProcess");
    
if not os.path.isdir(grey_dir + '/'):
    os.mkdir(grey_dir + '/');
    
    
rgb_imgs = glob.glob1(rgb_dir, '*.png');

for img in rgb_imgs:

    #tif_img_name = os.path.splitext(img)[0] + '.tif';
    
    boxm_batch.init_process("vilLoadImageViewProcess");
    boxm_batch.set_input_string(0,rgb_dir + '/' + img);
    boxm_batch.run_process();
    (id,type) = boxm_batch.commit_output(0);
    rgb_img = dbvalue(id,type);

    
    boxm_batch.init_process("vilRGBToGreyProcess");
    boxm_batch.set_input_from_db(0,rgb_img);
    boxm_batch.run_process();
    (id,type) = boxm_batch.commit_output(0);
    grey_img = dbvalue(id,type);

    boxm_batch.init_process("vilSaveImageViewProcess");
    boxm_batch.set_input_from_db(0,grey_img);
    boxm_batch.set_input_string(1,grey_dir + '/' + img);
    boxm_batch.run_process();

    boxm_batch.remove_data(rgb_img.id)
    boxm_batch.remove_data(grey_img.id)
  (id,type) = boxm_batch.commit_output(0);
  image = dbvalue(id,type);
  
  boxm_batch.init_process("vilImageSizeProcess");
  boxm_batch.set_input_from_db(0, image);
  boxm_batch.run_process();
  (ni_id, type) = boxm_batch.commit_output(0);
  (nj_id, type) = boxm_batch.commit_output(1);
  ni=boxm_batch.get_input_unsigned(ni_id);
  nj=boxm_batch.get_input_unsigned(nj_id);
  if ni > nj:
    sizes.append(ni);
  else:
    sizes.append(nj);

  boxm_batch.remove_data(image.id);
    
# set up the connectivity table to be used for computing tracks from the matches
boxm_batch.init_process("baplCreateConnTableProcess");
boxm_batch.set_input_int(0, img_cnt);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
conn_table = dbvalue(id,type);

for i in range(0,img_cnt,1):
  print("Loading Image");
  boxm_batch.init_process("vilLoadImageViewProcess");
  boxm_batch.set_input_string(0,img_path + img_name % (i*every_nth+1));
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  image = dbvalue(id,type);