def run(self):
        while not self.kill_received:
            # get a task
            try:
                job = self.work_queue.get_nowait()
            except Queue.Empty:
                break

            start_time = time.time()

            print("Creating a Scene")
            boxm_batch.init_process("boxmCreateSceneProcess")
            boxm_batch.set_input_string(0, job.input_scene_path)
            boxm_batch.run_process()
            (scene_id, scene_type) = boxm_batch.commit_output(0)
            scene = dbvalue(scene_id, scene_type)

            print("Save Scene")
            boxm_batch.init_process("boxmSaveOccupancyRawProcess")
            boxm_batch.set_input_from_db(0, scene)
            boxm_batch.set_input_string(1, job.output_scene_path)
            boxm_batch.set_input_unsigned(2, 0)
            boxm_batch.set_input_unsigned(3, 1)
            boxm_batch.run_process()

            print("Runing time for worker:", self.name)
            print(time.time() - start_time)
 def run(self):
     while not self.kill_received:
          # get a task
         try:
             job = self.work_queue.get_nowait()
         except Queue.Empty:
             break
             
         start_time = time.time();    
         
         model_dir=job.model_dir;
         model_name =job.model_name;
         grey_offset = job.grey_offset;
         
         print("Model dir:")
         print model_dir
         print("Model Name:")
         print model_name
         
         
         print("Creating a Scene");
         boxm_batch.init_process("boxmCreateSceneProcess");
         boxm_batch.set_input_string(0,  model_dir + "/" + model_name + ".xml");
         boxm_batch.run_process();
         (scene_id, scene_type) = boxm_batch.commit_output(0);
         scene= dbvalue(scene_id, scene_type);
         
        
         print("Splitting the scene");
         boxm_batch.init_process("boxmSplitSceneProcess");
         boxm_batch.set_input_from_db(0, scene);
         boxm_batch.run_process();
         (scene_id, scene_type) = boxm_batch.commit_output(0);
         apm_scene = dbvalue(scene_id, scene_type);
         (scene_id, scene_type) = boxm_batch.commit_output(1);
         alpha_scene = dbvalue(scene_id, scene_type);
         
         print("Save Scene");
         boxm_batch.init_process("boxmSaveScene    RawProcess");
         boxm_batch.set_input_from_db(0,alpha_scene);
         boxm_batch.set_input_string(1,model_dir + "/drishti/alpha_scene");
         boxm_batch.set_input_unsigned(2,0);
         boxm_batch.set_input_unsigned(3,1);
         boxm_batch.run_process();
         
         #free memory
         boxm_batch.clear();
      
         print ("Runing time for worker:", self.name)
         print(time.time() - start_time);
         
         #output exit code in this case
         #important: having a result queue makes the execute_jobs wait for all jobs in the queue before exiting
         self.result_queue.put(0);
   def run(self):
       while not self.kill_received:
            # get a task
           try:
               job = self.work_queue.get_nowait()
           except Queue.Empty:
               break
               
           start_time = time.time();    
           
           model_dir=job.model_dir;
           ply_file =job.ply_file;
           grey_offset = job.grey_offset;
           
           boxm_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");
 
             
           boxm_batch.init_process("boxmCreateSceneProcess");
           boxm_batch.set_input_string(0, model_dir +"/pmvs_scene.xml");
           boxm_batch.run_process();
           (scene_id, scene_type) = boxm_batch.commit_output(0);
           scene= dbvalue(scene_id, scene_type);
           
           boxm_batch.init_process("boxm_create_scene_from_ply_process");
           boxm_batch.set_input_string(0,ply_file);
           boxm_batch.set_input_from_db(1,scene);
           boxm_batch.set_input_float(2,grey_offset);
           boxm_batch.run_process();
           (scene_id, scene_type) = boxm_batch.commit_output(0);
           scene = dbvalue(scene_id, scene_type);
           
           
           print("Save Scene");
           boxm_batch.init_process("boxmSaveSceneRawProcess");
           boxm_batch.set_input_from_db(0,scene);
           boxm_batch.set_input_string(1,model_dir + "/drishti/ply_scene");
           boxm_batch.set_input_unsigned(2,0);
           boxm_batch.set_input_unsigned(3,1);
           boxm_batch.run_process();
           
           #free memory
           boxm_batch.reset_stdout();
           boxm_batch.clear();
        
           print ("Runing time for worker:", self.name)
           print(time.time() - start_time);
           
           #output exit code in this case
           #important: having a result queue makes the execute_jobs wait for all jobs in the queue before exiting
           self.result_queue.put(0);
Exemple #4
0
import boxm_batch;
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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

print("Loading Scene");
boxm_batch.init_process("boxmLoadSceneProcess");
boxm_batch.set_input_string(0,"D:\\vj\\data\\CapitolSiteHigh\\boxm\\scene.xml");
boxm_batch.set_input_string(1,"apm_mog_grey");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,"camera_00116.txt");
boxm_batch.run_process();
(cam_id,cam_type)=boxm_batch.commit_output(0);
camera=dbvalue(cam_id, cam_type);

print("Rendering Image");
boxm_batch.init_process("boxmRenderExpectedProcess");
boxm_batch.set_input_from_db(0,scene);
boxm_batch.set_input_from_db(1,camera);
boxm_batch.set_input_unsigned(2,1280);
boxm_batch.set_input_unsigned(3,720);
boxm_batch.run_process();
around_imgs_dir = "/Users/isa/Experiments/DowntownBOXM_4_4_1/imgs360_refined"

if not os.path.isdir( model_imgs_dir + "/"):
  os.mkdir( model_imgs_dir + "/");

image_fnames = "/Volumes/vision/video/dec/Downtown/video/frame_%05d.png";
camera_fnames = "/Volumes/vision/video/dec/Downtown/cameras_KRT/camera_%05d.txt";
expected_fname = model_imgs_dir + "/expected_%05d.tiff";
image_id_fname = model_imgs_dir + "/schedule_refined.txt";
expected_fname_no_dir = "/expected_%05d.tiff"



print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/downtown_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Virtual Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fnames % 40);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
vcam = dbvalue(id,type);



import random;
schedule = [i for i in range(0,180,9)];
Exemple #6
0
out_video_site_file = "kermit_video_site.xml"

keys_available = 0          # if keys have already been extracted, just load them

# after finding F between a pair, all matches that are off by 0.6% of
# max(image_width, image_height) pixels are considered outliers
outlier_threshold_percentage = 0.6
# for an image pair to be connected in the image connectivity graph
min_number_of_matches = 16

imgs = []
sizes = []
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)
    boxm_batch.run_process()
    (id, type) = boxm_batch.commit_output(0)
    image = dbvalue(id, type)
    imgs.append(image)

    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:
#model_dir = "/Users/isa/Experiments/CapitolBOXM_6_4_4";
model_dir = "/Users/isa/Experiments/DowntownBOXM_3_3_1";
output_dir = model_dir;

#if not os.path.isdir( model_imgs_dir + "/"):
#  os.mkdir( model_imgs_dir + "/");

#camera_fname = "/Volumes/vision/video/dec/capitol_sfm_rotated/camera_top.txt";
camera_fname = "/Users/isa/Experiments/DowntownBOXM_3_3_1/camera_top.txt"
#camera_fname = "/Volumes/vision/video/dec/capitol_sfm_rotated/cameras_KRT/camera_00075.txt";
expected_fname = output_dir + "/expected_top.tiff";


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/downtown_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Top Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fname);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
top_cam = dbvalue(id,type);


# Generate Expected Image 
print("Generating Expected Image");
boxm_batch.init_process("boxmRenderExpectedRTProcess");
model_dir = "/Users/isa/Experiments/CapitolBOXM_6_4_4";
model_imgs_dir = "/Users/isa/Experiments/CapitolBOXM_6_4_4/imgs"
around_imgs_dir = "/Users/isa/Experiments/CapitolBOXM_6_4_4/imgs360_%03d"

if not os.path.isdir( model_imgs_dir + "/"):
  os.mkdir( model_imgs_dir + "/");

image_fnames = "/Volumes/vision/video/dec/CapitolSiteHigh/video_grey/frame_%05d.png";
camera_fnames = "/Volumes/vision/video/dec/capitol_sfm_rotated/cameras_KRT/camera_%05d.txt";
expected_fname = model_imgs_dir + "/expected_%05d.tiff";
image_id_fname = model_imgs_dir + "/schedule2.txt";
expected_fname_no_dir = "/expected_%05d.tiff"

print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/capitol_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Virtual Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fnames % 40);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
vcam = dbvalue(id,type);


nframes =255;
#import random;
#schedule = [i for i in range(0,nframes)];
import boxm_batch;
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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


model_dir = "/Users/isa/Experiments/CapitolBOXM";


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/alpha_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("*************************************");

#convert_alpha = 0;  #flag to convert alpha to probability value
#
#print("Splitting the scene");
#boxm_batch.init_process("boxmSplitSceneProcess");
#boxm_batch.set_input_from_db(0, scene);
#boxm_batch.set_input_bool(1, convert_alpha);
#boxm_batch.run_process();
#(scene_id, scene_type) = boxm_batch.commit_output(0);
#apm_scene = dbvalue(scene_id, scene_type);
if not os.path.isdir(rgb_dir + '/'):
    print "Invalid RGB Dir"
    sys.exit(-1);
    
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();
out_key_name="frame_%05d.key";
out_match_img_name="frame_%05d_with_keys_of_%05d.jpg";
out_match_img_refined_name="frame_%05d_with_keys_of_%05d_refined.jpg";
out_video_site_file="tracks.xml";
every_nth = 16;  # use every nth image of the video sequence to guarantee view disparity

keypoints_available = 0;

outlier_threshold = 9.0;    # after finding F between a pair, all matches that are off by 9.0 pixels are considered outliers
min_number_of_matches = 16;            # for an image pair to be connected in the image connectivity graph

sizes = [];
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);
  
  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);
# Capitol
model_dir = "/Users/isa/Experiments/CapitolBOXM_4_4_2";
model_imgs_dir = "/Users/isa/Experiments/CapitolBOXM_4_4_2/imgs"

if not os.path.isdir( model_imgs_dir + "/"):
  os.mkdir( model_imgs_dir + "/");

image_fnames = "/Volumes/vision/video/dec/CapitolSiteHigh/video_grey/frame_%05d.png";
camera_fnames = "/Volumes/vision/video/dec/capitol_sfm_rotated/cameras_KRT/camera_%05d.txt";
expected_fname = model_imgs_dir + "/expected_%05d.tiff";
image_id_fname = model_imgs_dir + "/schedule2.txt";

print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/capitol_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Virtual Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fnames % 40);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
vcam = dbvalue(id,type);


nframes =255;
#import random;
#schedule = [i for i in range(0,nframes)];
class dbvalue:
  def __init__(self, index, type):
    self.id = index    # unsigned integer
    self.type = type   # string


#Parse inputs
parser = optparse.OptionParser(description='Compute PCA Error Scene');
parser.add_option('--model_dir', action="store", dest="model_dir");
options, args = parser.parse_args();

model_dir = options.model_dir;

print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/boxm_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene= dbvalue(scene_id, scene_type);

print("*************************************");


print("Splitting the scene");
boxm_batch.init_process("boxmSplitSceneProcess");
boxm_batch.set_input_from_db(0, scene);
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
apm_scene = dbvalue(scene_id, scene_type);
(scene_id, scene_type) = boxm_batch.commit_output(1);
alpha_scene = dbvalue(scene_id, scene_type);
model_dir = options.model_dir;
model_name = options.model_name;

if len(model_dir) == 0:
  print "Missing Model Dir"
  sys.exit(-1);

if len(model_name) == 0:
  print "Missing Model Name"
  sys.exit(-1);


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/" + str(model_name) + ".xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("*************************************");


print("Filling internal nodes");
boxm_batch.init_process("boxm_fill_internal_cells_process");
boxm_batch.set_input_from_db(0, scene);
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
filled_scene = dbvalue(scene_id, scene_type);

import boxm_batch;
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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


model_dir="/Users/isa/Experiments/DowntownBOXM_12_12_4";

print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/mean_color_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene= dbvalue(scene_id, scene_type);

print("Save Scene");
boxm_batch.init_process("boxmSaveSceneRawProcess");
boxm_batch.set_input_from_db(0,scene);
boxm_batch.set_input_string(1, model_dir + "/raw_mean_scene");
boxm_batch.set_input_unsigned(2,0);
boxm_batch.set_input_unsigned(3,1);
boxm_batch.run_process();
    self.type = type   # string
    
#dir = "/Users/isa/Experiments/super3d/sr2_scene_sr2_images/expectedImgs_1" 

#dir = "/Users/isa/Experiments/super3d/sr2_3scene_sr2_images/expectedImgs_2" 

#dir = "/Users/isa/Experiments/super3d/scene_sr2_images/expectedImgs_2" 

#dir = "/Users/isa/Experiments/super3d/scene/expectedImgs_2" 

#dir = "/Volumes/vision/video/isabel/super3d/scili_experiment/normal_scene/expectedImgs_0"

dir = "/Users/isa/Experiments/super3d/scili_experiments_bicubic/sr2_scene_sr2_images/expectedImgs_0"
   
boxm_batch.init_process("vilLoadImageViewProcess");
boxm_batch.set_input_string(0,dir + "/exepected_var.tiff");
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
var_img = dbvalue(id,type);

boxm_batch.init_process("vilImageMeanProcess");
boxm_batch.set_input_from_db(0,var_img);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
mean = dbvalue(id,type);
mean_val = boxm_batch.get_output_float(mean.id);
 
  
mean_file = dir + "/mean_var.txt"
f = open(mean_file, 'w');
f.write(str(mean_val));
Exemple #17
0
camera_fnames = glob.glob("Z:/video/dec/CapitolSiteHigh/cameras_KRT/*.txt");

min_range = 10;
last_i = -min_range;
nframes = 145;

for x in range(125,nframes,1):
  i = random.randint(0,254);
  # try, try again if this frame is too close to the last
  while (abs(i - last_i) < min_range):
    i = random.randint(0,254);
  last_i = i;
  
  print("Loading Camera");
  boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
  boxm_batch.set_input_string(0,camera_fnames[i]);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  cam = dbvalue(id,type);
  
  print("Loading Image");
  boxm_batch.init_process("vilLoadImageViewProcess");
  boxm_batch.set_input_string(0,image_fnames[i]);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  image = dbvalue(id,type);
  
  print("Updating Scene");
  boxm_batch.init_process("boxmUpdateProcess");
  boxm_batch.set_input_from_db(0,image);
  boxm_batch.set_input_from_db(1,cam);
 def __init__(self, index, type):
   self.id = index # unsigned integer
   self.type = type # string


model_dir ="/Users/isa/Experiments/CapitolBOXM_6_4_4";
output_path = "/Users/isa/Experiments/tests/ocl_scene";
if not os.path.isdir( output_path + "/"):
  os.mkdir( output_path + "/");

max_mb = -1;


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0, model_dir + "/capitol_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Convert Scene");
boxm_batch.init_process("boxmOclConvertBoxmToOclProcess");
boxm_batch.set_input_from_db(0, scene);
boxm_batch.set_input_string(1, output_path);
boxm_batch.set_input_int(2, -1);
boxm_batch.set_input_bool(3, 0);
boxm_batch.run_process();


# print("Refine Scene");
# boxm_batch.init_process("boxmOclRefineProcess");
if len(model_dir) == 0:
  print "Missing Model Dir"
  sys.exit(-1);

if len(model_name) == 0:
  print "Missing Model Name"
  sys.exit(-1);

if len(model_out_name) == 0:
  print "Missing Model Out Name"
  sys.exit(-1);


boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/" + str(model_name) + ".xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("*************************************");

boxm_batch.init_process("boxm_remove_level0_process");
boxm_batch.set_input_from_db(0, scene);
boxm_batch.set_input_string(1, model_out_name);
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
restructured_scene = dbvalue(scene_id, scene_type);

print("*************************************");
boxm_batch.init_process("boxmSaveOccupancyRawProcess");

# write camera indices to file
image_ids = [];
fd = open(image_id_fname,"w");
print >>fd, len(camera_idx);
for c in camera_idx:
  img_id = "gray%d" % c;
  image_ids.append(img_id);
  print >>fd, img_id;
fd.close();

# load scene 
print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Virtual Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fname % 0);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
vcam = dbvalue(id,type);
vcam = dbvalue(id,type);

for it in range(0,num_its,1):
  for c in range(0,len(camera_idx),1):
    
boxm_batch.register_datatypes()

scene_path = "/Users/isa/Experiments/tests/ocl_scene/scene.xml"
camera_path = "/Volumes/vision/video/dec/capitol_sfm_rotated/cameras_KRT/camera_00040.txt"
image_path = "/Volumes/vision/video/dec/CapitolSiteHigh/video/frame_00040.png"
int_image_path = "/Volumes/vision/video/dec/CapitolSiteHigh/video_grey/frame_00040.png"


# scene_path = "F:/visdt/sceneocl/scene.xml";
# image_path ="f:/visdt/cd/_00113.png";
# int_image_path ="F:/visdt/imgs/gray00113.png";
# camera_path="f:/visdt/cameras_KRT/camera_00113.txt"

print ("Load Initial camera ")
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess")
boxm_batch.set_input_string(0, camera_path)
boxm_batch.run_process()
(id, type) = boxm_batch.commit_output(0)
cam = dbvalue(id, type)

print ("initializing ray tracing")
boxm_batch.init_process("boxmOclInitRenderProbeProcess")
boxm_batch.set_input_string(0, scene_path)
boxm_batch.set_input_from_db(1, cam)
boxm_batch.set_input_unsigned(2, 200)
boxm_batch.set_input_unsigned(3, 200)
boxm_batch.run_process()
(scene_id, scene_type) = boxm_batch.commit_output(0)
scene_mgr = dbvalue(scene_id, scene_type)

image2 = Image.open(int_image_path)
#dir = "/Volumes/vision/video/isabel/super3d/scili_experiment/sr2_scene_sr2_images/expectedImgs_0"
#original_img_dir = "/Volumes/vision/video/isabel/super3d/site12_superres"

#dir = "/Volumes/vision/video/isabel/super3d/scili_experiment/normal_scene/expectedImgs_0"
#original_img_dir ="/Volumes/vision/video/helicopter_providence/3d_models_3_11/site12/frames_grey"

dir = "/Users/isa/Experiments/super3d/scili_experiments_bicubic/sr2_scene_sr2_images/expectedImgs_0"
original_img_dir = "/Users/isa/Experiments/super3d/scili_experiments_bicubic/superresolved_imgs"
npixels = 720*1280*4
test_frames=[78, 196, 244, 42];
ssd_vals=[];
ssd_avg = 0;    
    
for frame in test_frames:
  boxm_batch.init_process("vilLoadImageViewProcess");
  boxm_batch.set_input_string(0,dir + "/predicted_img_%(#)05d.tiff"%{"#":frame});
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  pred_img = dbvalue(id,type);

  boxm_batch.init_process("vilConvertPixelTypeProcess");
  boxm_batch.set_input_from_db(0,pred_img);
  boxm_batch.set_input_string(1, "byte");
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  pred_img_byte = dbvalue(id,type);
  
  boxm_batch.init_process("vilSaveImageViewProcess");
  boxm_batch.set_input_from_db(0,pred_img_byte);
  boxm_batch.set_input_string(1,dir + "/predicted_img_%(#)05d.png"%{"#":frame});
  boxm_batch.run_process();
min_range = 10;
last_i = -min_range;
nframes = 145;

for x in range(125,nframes,1):
  print("*************************************************************************************");
  print x;
  i = random.randint(0,254);
  # try, try again if this frame is too close to the last
  while (abs(i - last_i) < min_range):
    i = random.randint(0,254);
  last_i = i;
  
  print("Loading Camera");
  boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
  boxm_batch.set_input_string(0,camera_fnames % i);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  cam = dbvalue(id,type);
  
  print("Loading Image");
  boxm_batch.init_process("vilLoadImageViewProcess");
  boxm_batch.set_input_string(0,image_fnames % i);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  image = dbvalue(id,type);
  
  print("Updating Scene");
  boxm_batch.init_process("boxmUpdateProcess");
  boxm_batch.set_input_from_db(0,image);
  boxm_batch.set_input_from_db(1,cam);
Exemple #24
0
out_video_site_file = "kermit_video_site.xml"

keys_available = 0  # if keys have already been extracted, just load them

# after finding F between a pair, all matches that are off by 0.6% of
# max(image_width, image_height) pixels are considered outliers
outlier_threshold_percentage = 0.6
# for an image pair to be connected in the image connectivity graph
min_number_of_matches = 16

imgs = []
sizes = []
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)
    boxm_batch.run_process()
    (id, type) = boxm_batch.commit_output(0)
    image = dbvalue(id, type)
    imgs.append(image)

    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:
  def __init__(self, index, type):
    self.id = index    # unsigned integer
    self.type = type   # string


# Synthetic 
model_dir = "/Users/isa/Experiments/Synthetic";
model_imgs_dir = "/Users/isa/Experiments/Synthetic/imgs"
camera_fnames = "/Users/isa/Documents/Scripts/python_voxel/bvxm/synth_world/cam_%d.txt";
image_fnames = "/Users/isa/Documents/Scripts/python_voxel/bvxm/synth_world/test_img%d.tif";
expected_fname = model_imgs_dir + "/expected_%d.tiff";


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

print("Loading Virtual Camera");
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess");
boxm_batch.set_input_string(0,camera_fnames % 40);
boxm_batch.run_process();
(id,type) = boxm_batch.commit_output(0);
vcam = dbvalue(id,type);


nframes =255;
import random;
schedule = [i for i in range(0,nframes)];
  if len(model_dir) == 0:
    print "Missing Model Dir"
    sys.exit(-1);
      
  if len(model_name) == 0:
    print "Missing Model Name"
    sys.exit(-1);
      
  if not os.path.isdir(model_dir +"/"):
    print "Invalid Model Dir"
    sys.exit(-1);


  print("Creating a Scene");
  boxm_batch.init_process("boxmCreateSceneProcess");
  boxm_batch.set_input_string(0,  model_dir + "/" + model_name + ".xml");
  boxm_batch.run_process();
  (scene_id, scene_type) = boxm_batch.commit_output(0);
  scene= dbvalue(scene_id, scene_type);

  #print("*************************************");
  #print("Save Scene");
  #boxm_batch.init_process("boxmSaveOccupancyRawProcess");
  #boxm_batch.set_input_from_db(0,scene);
  #boxm_batch.set_input_string(1,model_dir + "/" + model_name);
  #boxm_batch.set_input_unsigned(2,0);
  #boxm_batch.set_input_unsigned(3,1);
  #boxm_batch.run_process();

  print("*************************************");
  print("Computing Excpected Color Scene");
Exemple #27
0
out_video_site_file = "tracks.xml"
every_nth = 16  # use every nth image of the video sequence to guarantee view disparity

keypoints_available = 0

# after finding F between a pair, all matches that are off by 9.0 pixels
# are considered outliers
outlier_threshold = 9.0
# for an image pair to be connected in the image connectivity graph
min_number_of_matches = 16

sizes = []
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)

    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)
import boxm_batch;
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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


model_dir ="/Users/isa/Experiments/CapitolBOXM_1_1_1";


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/gaussf1_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
gauss_scene = dbvalue(scene_id, scene_type);

print("*************************************");


print("Computing Entropies");
boxm_batch.init_process("boxmComputeEntropyProcess");
boxm_batch.set_input_from_db(0, gauss_scene);
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
entropy_scene = dbvalue(scene_id, scene_type);

Exemple #29
0
import boxm_batch
boxm_batch.register_processes()
boxm_batch.register_datatypes()


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


print("Loading Scene")
boxm_batch.init_process("boxmLoadSceneProcess")
boxm_batch.set_input_string(0,
                            "D:\\vj\\data\\CapitolSiteHigh\\boxm\\scene.xml")
boxm_batch.set_input_string(1, "apm_mog_grey")
boxm_batch.run_process()
(scene_id, scene_type) = boxm_batch.commit_output(0)
scene = dbvalue(scene_id, scene_type)

print("Loading camera")
boxm_batch.init_process("vpglLoadPerspectiveCameraProcess")
boxm_batch.set_input_string(0, "camera_00116.txt")
boxm_batch.run_process()
(cam_id, cam_type) = boxm_batch.commit_output(0)
camera = dbvalue(cam_id, cam_type)

print("Rendering Image")
boxm_batch.init_process("boxmRenderExpectedProcess")
boxm_batch.set_input_from_db(0, scene)
boxm_batch.set_input_from_db(1, camera)
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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


model_dir = "/Users/isa/Experiments/CapitolBOXM";



print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
scene = dbvalue(scene_id, scene_type);

#print("Save Scene");
#boxm_batch.init_process("boxmSaveOccupancyRawProcess");
#boxm_batch.set_input_from_db(0,scene);
#boxm_batch.set_input_string(1,model_dir + "/scene");
#boxm_batch.set_input_unsigned(2,0);
#boxm_batch.set_input_unsigned(3,1);
#boxm_batch.run_process();

print("Crop Scene");
boxm_batch.init_process("boxmCropSceneProcess");
boxm_batch.set_params_process(model_dir + "/crop_scene_params.xml");
import boxm_batch;
boxm_batch.register_processes();
boxm_batch.register_datatypes();

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


model_dir ="/Users/isa/Experiments/CapitolBOXM_1_1_1";


print("Creating a Scene");
boxm_batch.init_process("boxmCreateSceneProcess");
boxm_batch.set_input_string(0,  model_dir +"/apm_scene.xml");
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
mog_scene = dbvalue(scene_id, scene_type);

print("*************************************");


print("Merging the scene");
boxm_batch.init_process("boxmMergeMixturesProcess");
boxm_batch.set_input_from_db(0, mog_scene);
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
gauss_scene = dbvalue(scene_id, scene_type);

boxm_batch.register_processes()
boxm_batch.register_datatypes()


class dbvalue:
    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})
Exemple #33
0
out_key_name="kermit%03d.key";
out_match_img_name="kermit%03d_with_keys_of%03d.jpg";
out_match_img_refined_name="kermit%03d_with_keys_of%03d_refined.jpg";
out_video_site_file="kermit_video_site.xml";

keys_available = 0;          # if keys have already been extracted, just load them

outlier_threshold_percentage = 0.6;    # after finding F between a pair, all matches that are off by 0.6% of max(image_width, image_height) pixels are considered outliers
min_number_of_matches = 16;            # for an image pair to be connected in the image connectivity graph

imgs = [];
sizes = [];
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);
  boxm_batch.run_process();
  (id,type) = boxm_batch.commit_output(0);
  image = dbvalue(id,type);
  imgs.append(image);
  
  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: