def run(self):
        while not self.kill_received:
             # get a task
            try:
                job = self.work_queue.get_nowait()
            except Queue.Empty:
                break
                
            dbrec3d_batch.register_processes();
            dbrec3d_batch.register_datatypes();
            
            start_time = time.time();
            dbrec3d_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");

            dbrec3d_batch.init_process("bofKMeansSubsampleProcess");
            dbrec3d_batch.set_input_string(0, job.bof_path);
            dbrec3d_batch.set_input_string(1, job.starting_means_path);
            dbrec3d_batch.set_input_double(2, job.fraction);
            dbrec3d_batch.set_input_unsigned(3, job.max_it);
            dbrec3d_batch.set_input_string(4, job.file_out);
            dbrec3d_batch.run_process();
            
            dbrec3d_batch.clear();
            dbrec3d_batch.reset_stdout();
            print ("Runing time for worker:", self.name)
            print(time.time() - start_time);
Ejemplo n.º 2
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();
            
            dbrec3d_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");
            dbrec3d_batch.init_process("bofKMeansTrainProcess");
            dbrec3d_batch.set_input_string(0, job.bof_path);
            dbrec3d_batch.set_input_string(1, job.starting_means_path);
            dbrec3d_batch.set_input_int(2, job.scene_id);
            dbrec3d_batch.set_input_int(3, job.block_i);
            dbrec3d_batch.set_input_int(4, job.block_j);
            dbrec3d_batch.set_input_int(5, job.block_k);
            dbrec3d_batch.set_input_unsigned(6, job.max_it);
            dbrec3d_batch.set_input_string(7, job.file_out);
            dbrec3d_batch.run_process();
            
            dbrec3d_batch.clear();
            dbrec3d_batch.reset_stdout();
 
            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();
            
            dbrec3d_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");

            dbrec3d_batch.init_process("bof_sample_statistics_process");
            dbrec3d_batch.set_input_from_db(0,job.categories);
            dbrec3d_batch.set_input_from_db(1,job.global_pca);
            dbrec3d_batch.set_input_unsigned(2, job.scene_id);
            dbrec3d_batch.set_input_string(3, job.file_out);
            dbrec3d_batch.run_process();
            
            dbrec3d_batch.clear();
            dbrec3d_batch.reset_stdout();

 
            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();
            
            dbrec3d_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");

            dbrec3d_batch.init_process("bofKMeansOnVectorProcess");
            dbrec3d_batch.set_input_string(0, job.cm_i_file);
            dbrec3d_batch.set_input_from_db(1, job.CM_set);
            dbrec3d_batch.set_input_unsigned(2, job.max_it);
            dbrec3d_batch.set_input_string(3, job.fm_i_file);
            dbrec3d_batch.run_process();
            
            dbrec3d_batch.clear();
            dbrec3d_batch.reset_stdout();

 
            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();
         dbrec3d_batch.set_stdout('logs/log_' + str(os.getpid())+ ".txt");
         
         dbrec3d_batch.init_process("bof_learn_category_codebook_salient_process");
         dbrec3d_batch.set_input_from_db(0,job.categories);
         dbrec3d_batch.set_input_unsigned(1, job.class_id);
         dbrec3d_batch.set_input_unsigned(2, job.num_means);
         dbrec3d_batch.set_input_double(3, job.fraction);
         dbrec3d_batch.set_input_unsigned(4, job.J);
         dbrec3d_batch.set_input_unsigned(5, job.max_it);
         dbrec3d_batch.set_input_float(6, job.top_p);
         dbrec3d_batch.set_input_string(7, job.class_mean_dir);
         dbrec3d_batch.run_process();
         
         
         dbrec3d_batch.clear();
         dbrec3d_batch.reset_stdout();
Ejemplo n.º 6
0
  def __init__(self, index, type):
    self.id = index    # unsigned integer
    self.type = type   # string

#grad_scene_path = "/Users/isa/Experiments/boxm_scili_full/steerable_filters_alpha/steerable_gauss_3d_scene.xml"
#valid_scene_path = "/Users/isa/Experiments/boxm_scili_full/steerable_filters_alpha/valid_scene.xml"
#pcd_file = "/Users/isa/Experiments/pcl/tests/boxm_scili_full.pcd"

#Run k-means
pcl_dir = "/Users/isa/Experiments/pcl/tests"
fpfh_file =pcl_dir + "/fpfh_boxm_scili.pcd"; 
n_means = 50;
init_frac = 0.1;
init_iter = 10
max_iter = 500;
means_dir = pcl_dir + "/means_50_scili"

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


dbrec3d_batch.init_process("pcl_k_means_learning_process");
dbrec3d_batch.set_input_string(0, fpfh_file);
dbrec3d_batch.set_input_unsigned(1, n_means);
dbrec3d_batch.set_input_double(2,  init_frac);
dbrec3d_batch.set_input_unsigned(3,  init_iter);
dbrec3d_batch.set_input_unsigned(4,  max_iter);
dbrec3d_batch.set_input_string(5,  means_dir);
dbrec3d_batch.run_process();

Ejemplo n.º 7
0
#    dbrec3d_batch.run_process();
    
  #*********** Save a scene labeling objects for debigging purposes **************#
  
  print("Creating a Scene");
  dbrec3d_batch.init_process("boxmCreateSceneProcess");
  dbrec3d_batch.set_input_string(0, scene_in);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  scene= dbvalue(id, type);

  dbrec3d_batch.init_process("bofExamineGroundTruthProcess");
  dbrec3d_batch.set_input_from_db(0,scene);
  dbrec3d_batch.set_input_string(1,ply_path_out);
  dbrec3d_batch.set_input_string(2,obj_name);
  dbrec3d_batch.set_input_string(3,ply_path_out);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  scene_out= dbvalue(id, type);

  print("Save Scene");
  dbrec3d_batch.init_process("boxmSaveSceneRawProcess");
  dbrec3d_batch.set_input_from_db(0,scene_out);
  dbrec3d_batch.set_input_string(1, ply_path_out + "/drishti/labeled_scene_level_0");
  dbrec3d_batch.set_input_unsigned(2,0);
  dbrec3d_batch.set_input_unsigned(3,1);
  dbrec3d_batch.run_process();

  print ("Total running time: ");
  print(time.time() - start_time);
    
Ejemplo n.º 8
0
dbrec3d_batch.print_db();


print("Get the response")
dbrec3d_batch.init_process("dbrec3dGetResponseProcess");
dbrec3d_batch.set_input_int(0, 0);
dbrec3d_batch.run_process();
(scene_id, scene_type) = dbrec3d_batch.commit_output(0);
response_scene= dbvalue(scene_id, scene_type);

resolution = 0;
enforce_level = 1;

print("Convert to regular grid");
dbrec3d_batch.init_process("boxmSceneToBvxmGridProcess");
dbrec3d_batch.set_input_from_db(0,response_scene);
dbrec3d_batch.set_input_string(1, model_dir + "/dbrec3d_response.vox");
dbrec3d_batch.set_input_unsigned(2, resolution);
dbrec3d_batch.set_input_bool(3, enforce_level);
dbrec3d_batch.run_process();
(grid_id, grid_type) = dbrec3d_batch.commit_output(0);
grid = dbvalue(grid_id, grid_type);

print("Save Grid");
dbrec3d_batch.init_process("bvxmSaveGridRawProcess");
dbrec3d_batch.set_input_from_db(0,grid);
dbrec3d_batch.set_input_string(1,model_dir + "/dbrec3d_response.raw");
dbrec3d_batch.run_process();

Ejemplo n.º 9
0
  categories= dbvalue(id, type);
  
  #load class codebook
  class_id = 0;
  codebook_file = k_means_dir + "/class" + str(class_id) + "/lowest_sse_means.txt"
  dbrec3d_batch.init_process("bofInitCodebookProcess");
  dbrec3d_batch.set_input_string(0,codebook_file);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  codebook= dbvalue(id, type);

  #compute object weight for all testing objects    
  dbrec3d_batch.init_process("bof_class_probability_process");
  dbrec3d_batch.set_input_from_db(0,codebook);
  dbrec3d_batch.set_input_from_db(1,categories);
  dbrec3d_batch.set_input_unsigned(2, class_id);
  dbrec3d_batch.set_input_string(3, classification_dir);
  dbrec3d_batch.run_process();

  
#  #Begin multiprocessing
#  job_list=[];
#  start_time = time.time();
#
#  #Enqueue jobs
#  for scene_id in range (0, nscenes):
#      histogram_path = class_histograms_dir + "/scene_" + str(scene_id);
#      if not os.path.isdir(histogram_path +"/"):
#         os.mkdir(histogram_path +"/")
#         
#      current_job = bof_job(bof_dir, codebook , scene_id, histogram_path);
    print "Invalid CM Dir"
    sys.exit(-1); 
    
  FM_path = init_k_means_dir + "/FM";  
  if not os.path.isdir(FM_path +"/"):
    os.mkdir(FM_path +"/");   

  CM_files = glob.glob1(CM_path, 'CM*');
  num_mean_files = len(CM_files);


  #Combine all CM_i means into one set CM to be passed for k-means
  mean_file_sfx = CM_path + "/CM_" ;
  dbrec3d_batch.init_process("bofCombineMeansProcess");
  dbrec3d_batch.set_input_string(0, mean_file_sfx);
  dbrec3d_batch.set_input_unsigned(1, num_mean_files);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  CM_set= dbvalue(id, type);


  #Begin multiprocessing
  job_list=[];

  #Enqueue jobs    
  for CM_file in CM_files:
    cm_file = CM_path + "/" + CM_file;
    fm_file = FM_path + "/FM" + CM_file.strip('CM');
    current_job = bof_job(cm_file, CM_set, max_it, fm_file);
    job_list.append(current_job);
                              
  if not os.path.isdir(k_means_dir +"/"):
      print "Invalid k_means Dir"
      sys.exit(-1);
   

  FM_path = k_means_dir + "/FM";  
  if not os.path.isdir(FM_path +"/"):
      os.mkdir(FM_path +"/");   

  start_time = time.time();

  #Combine all CM_i means into one set CM to be passed for k-means
  mean_file_sfx = k_means_dir + "/class" ;
  dbrec3d_batch.init_process("bof_combine_category_means_process");
  dbrec3d_batch.set_input_string(0, mean_file_sfx);
  dbrec3d_batch.set_input_unsigned(1, nclasses);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  CM_set= dbvalue(id, type);

  saveout = sys.stdout   # save initial state of stdout

  #Begin multiprocessing
  job_list=[];
  
  #Enqueue jobs
  for class_id in range (0, nclasses):
      cm_file = mean_file_sfx + str(class_id) + "/lowest_sse_means.txt";
      fm_file = FM_path + "/FM_means_class" +  str(class_id) + ".txt";
      current_job = bof_job(cm_file, CM_set, max_it, fm_file);
      job_list.append(current_job);
Ejemplo n.º 12
0
  #Begin multiprocessing
  job_list=[];
  start_time = time.time();

  #load codebook
  codebook_file = k_means_dir + "/lowest_sse_means.txt"
  dbrec3d_batch.init_process("bofInitCodebookProcess");
  dbrec3d_batch.set_input_string(0,codebook_file);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  codebook= dbvalue(id, type);
  
  #load class/keypoints distributions
  dbrec3d_batch.init_process("bofLoadPXCProcess");
  dbrec3d_batch.set_input_from_db(0,codebook);
  dbrec3d_batch.set_input_string(1,class_histograms_dir);
  dbrec3d_batch.set_input_unsigned(2, ncategories);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  p_xc= dbvalue(id, type);
  

  #Enqueue jobs
  for scene_id in range(0, nscenes):
      current_job = bof_job(bof_dir, p_xc, codebook , scene_id, classification_dir);
      job_list.append(current_job);
                                
  execute_bof_jobs(job_list, num_cores);

  
    
#  convert_id_to_rgbcloud.py
#  voxels-at-lems
#
#  Created by Maria Isabel Restrepo on 11/15/11.
#  Copyright (c) 2011 Brown University. All rights reserved.


import dbrec3d_batch;
import os;
import optparse;

dbrec3d_batch.register_processes();
dbrec3d_batch.register_datatypes();

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


#Run k-means
pcl_dir = "/Users/isa/Experiments/pcl/tests"
id_pcd_file = pcl_dir + "/means_50_scili/class_id.pcd"
rgb_pcd_file = pcl_dir + "/means_50_scili/class_id_rgb.pcd"
nmeans = 50;

dbrec3d_batch.init_process("pcl_convert_id_to_rgb_process");
dbrec3d_batch.set_input_string(0, id_pcd_file);
dbrec3d_batch.set_input_string(1, rgb_pcd_file);
dbrec3d_batch.set_input_unsigned(2, nmeans);
dbrec3d_batch.run_process();
  dbrec3d_batch.init_process("bofLoadCategoryInfoProces");
  dbrec3d_batch.set_input_string(0, bof_dir);
  dbrec3d_batch.run_process();
  (id, type) = dbrec3d_batch.commit_output(0);
  categories= dbvalue(id, type);

  #learn codebook for a particular class
  class_id = 0;
  class_mean_dir = k_means_dir + "/class" + str(class_id);
  if not os.path.isdir(class_mean_dir +"/"):
      os.mkdir(class_mean_dir + "/" );

    
  dbrec3d_batch.init_process("bofLearnCategoryCodebookProcess");
  dbrec3d_batch.set_input_from_db(0,categories);
  dbrec3d_batch.set_input_unsigned(1, class_id);
  dbrec3d_batch.set_input_unsigned(2, num_means);
  dbrec3d_batch.set_input_double(3, fraction);
  dbrec3d_batch.set_input_unsigned(4, J);
  dbrec3d_batch.set_input_unsigned(5, max_it);
  dbrec3d_batch.set_input_string(6, class_mean_dir);
  dbrec3d_batch.run_process();

  
#  #Begin multiprocessing
#  job_list=[];
#  start_time = time.time();
#
#  #Enqueue jobs
#  for scene_id in range (0, nscenes):
#      histogram_path = class_histograms_dir + "/scene_" + str(scene_id);
Ejemplo n.º 15
0
    parser = optparse.OptionParser(description="Init BOF info")

    parser.add_option("--taylor_dir", action="store", dest="taylor_dir")
    parser.add_option("--bof_dir", action="store", dest="bof_dir")
    parser.add_option("--num_means", action="store", dest="num_means", type="int", default=50)

    options, args = parser.parse_args()

    taylor_dir = options.taylor_dir
    bof_dir = options.bof_dir
    num_means = options.num_means

    if not os.path.isdir(taylor_dir + "/"):
        print "Invalid taylor Dir"
        sys.exit(-1)

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

    start_time = time.time()

    dbrec3d_batch.init_process("bofInitInfoFileProcess")
    dbrec3d_batch.set_input_string(0, taylor_dir)
    dbrec3d_batch.set_input_unsigned(1, num_means)
    dbrec3d_batch.set_input_string(2, bof_dir)

    dbrec3d_batch.run_process()

    print ("Total running time: ")
    print (time.time() - start_time)