Ejemplo n.º 1
0
def runprobe(event):
    posx = event.x
    posy = event.y
    array2d = list()

    plt.figure(1)
    plt.clf()
    print ("Run ray tracing")
    boxm_batch.init_process("boxmOclRunRenderProbeProcess")
    boxm_batch.set_input_from_db(0, scene_mgr)
    boxm_batch.set_input_from_db(1, cam)
    boxm_batch.set_input_unsigned(2, posx)
    boxm_batch.set_input_unsigned(3, posy)
    boxm_batch.set_input_float(4, (image2.getpixel((posx, posy))) / 255.0)
    boxm_batch.run_process()

    for i in range(0, 10):
        (scene_id, scene_type) = boxm_batch.commit_output(i)
        array_1d = dbvalue(scene_id, scene_type)
        vallist = boxm_batch.get_bbas_1d_array_float(scene_id)
        array2d.append(vallist)

    for i in [1, 2, 3, 5]:
        plt.plot(array2d[0], array2d[i])
    # plt.plot(array2d[0],array2d[7]);
    plt.legend(("Omega", "Mean0", "Alpha", "Mean1"), loc="upper left")
    print (image2.getpixel((posx, posy))) / 255.0
    plt.show()
    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)
Ejemplo n.º 3
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;
         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);
Ejemplo n.º 5
0
def neighborchange(event):
    posx = event.x
    posy = event.y
    array2d = list()

    vallist = list()
    plt.figure(1)
    plt.clf()
    for i in (-1, 0):
        for j in (-1, 0):
            print ("Run ray tracing")
            boxm_batch.init_process("boxmOclRunRenderProbeProcess")
            boxm_batch.set_input_from_db(0, scene_mgr)
            boxm_batch.set_input_from_db(1, cam)
            boxm_batch.set_input_unsigned(2, posx + i)
            boxm_batch.set_input_unsigned(3, posy + j)
            boxm_batch.set_input_float(4, (image2.getpixel((posx, posy))) / 255.0)
            boxm_batch.run_process()
            (scene_id, scene_type) = boxm_batch.commit_output(10)
            x = boxm_batch.get_input_float(scene_id)
            vallist.append(x)
    print vallist
Ejemplo n.º 6
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


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();
Ejemplo n.º 7
0
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();
(img_id,img_type)=boxm_batch.commit_output(0);
(mask_id,mask_type)=boxm_batch.commit_output(1);
img = dbvalue(img_id, img_type);
mask = dbvalue(mask_id, mask_type);

boxm_batch.init_process("vilSaveImageViewProcess");
boxm_batch.set_input_from_db(0,img);
boxm_batch.set_input_string(1,"image.tiff");
boxm_batch.run_process();

boxm_batch.init_process("vilSaveImageViewProcess");
boxm_batch.set_input_from_db(0,mask);
boxm_batch.set_input_string(1,"mask.tiff");
Ejemplo n.º 8
0
model_dir = "/Users/isa/Experiments/helicopter_providence/boxm_scenes/site12"

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

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);


boxm_batch.init_process("boxmExploreCellsAtLevelProcess");
boxm_batch.set_input_from_db(0, scene);
boxm_batch.set_input_unsigned(1, 1); #level to explore
boxm_batch.run_process();
(scene_id, scene_type) = boxm_batch.commit_output(0);
level_scene = dbvalue(scene_id, scene_type);

print("Save Scene");
boxm_batch.init_process("boxmSaveSceneRawProcess");
boxm_batch.set_input_from_db(0,level_scene);
boxm_batch.set_input_string(1, model_dir + "/level1");
boxm_batch.set_input_unsigned(2,0);
boxm_batch.set_input_unsigned(3,1);
boxm_batch.run_process();
Ejemplo n.º 9
0
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()
(img_id, img_type) = boxm_batch.commit_output(0)
(mask_id, mask_type) = boxm_batch.commit_output(1)
img = dbvalue(img_id, img_type)
mask = dbvalue(mask_id, mask_type)

boxm_batch.init_process("vilSaveImageViewProcess")
boxm_batch.set_input_from_db(0, img)
boxm_batch.set_input_string(1, "image.tiff")
boxm_batch.run_process()

boxm_batch.init_process("vilSaveImageViewProcess")
boxm_batch.set_input_from_db(0, mask)
boxm_batch.set_input_string(1, "mask.tiff")
Ejemplo n.º 10
0
  
  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);
  boxm_batch.set_input_from_db(2,scene);
  boxm_batch.set_input_unsigned(3,0);
  boxm_batch.run_process();

  print("Refine Scene");
  boxm_batch.init_process("boxmRefineSceneProcess");
  boxm_batch.set_input_from_db(0,scene);
  boxm_batch.set_input_float(1,0.2);
  boxm_batch.set_input_bool(2,1);
  boxm_batch.run_process();

Ejemplo n.º 11
0
# 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)


def subone(y):
    return 1 - y


def mult(x, y):
    return x * y