示例#1
0
def gradient(img):
    bstm_batch.init_process("vilGradientProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.run_process()
    # x image
    (id, type) = bstm_batch.commit_output(0)
    dIdx = dbvalue(id, type)
    # y image
    (id, type) = bstm_batch.commit_output(1)
    dIdy = dbvalue(id, type)
    # mag image
    (id, type) = bstm_batch.commit_output(2)
    magImg = dbvalue(id, type)
    return dIdx, dIdy, magImg
示例#2
0
def trajectory_next(trajectory):
    bstm_batch.init_process("bstmViewTrajectoryNextProcess")
    bstm_batch.set_input_from_db(0, trajectory)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cam = dbvalue(id, type)
    return cam
示例#3
0
def load_projective_camera(file_path):
    bstm_batch.init_process("vpglLoadProjCameraProcess")
    bstm_batch.set_input_string(0, file_path)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cam = dbvalue(id, type)
    return cam
示例#4
0
def rgb2gray(img):
    bstm_batch.init_process("vilRGBToGreyProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    outimg = dbvalue(id, type)
    return outimg
def load_perspective_camera(file_path) :
  bstm_batch.init_process("vpglLoadPerspectiveCameraProcess");
  bstm_batch.set_input_string(0, file_path);
  bstm_batch.run_process();
  (id,type) = bstm_batch.commit_output(0);
  cam = dbvalue(id,type);
  return cam;
示例#6
0
def convert_image(img, type="byte"):
    bstm_batch.init_process("vilConvertPixelTypeProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_string(1, type)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cimg = dbvalue(id, type)
    return cimg
示例#7
0
def close_image(img, disk_radius):
    bstm_batch.init_process("vilImageClosingDiskProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_float(1, disk_radius)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cimg = dbvalue(id, type)
    return cimg
示例#8
0
def load_scene(scene_str):
    #print("Loading a Scene from file: ", scene_str);
    bstm_batch.init_process("bstmLoadSceneProcess")
    bstm_batch.set_input_string(0, scene_str)
    bstm_batch.run_process()
    (scene_id, scene_type) = bstm_batch.commit_output(0)
    scene = dbvalue(scene_id, scene_type)
    return scene
示例#9
0
def binary_img_op(img1, img2, operation="sum"):
    bstm_batch.init_process("vilBinaryImageOpProcess")
    bstm_batch.set_input_from_db(0, img1)
    bstm_batch.set_input_from_db(1, img2)
    bstm_batch.set_input_string(2, operation)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    out = dbvalue(id, type)
    return out
示例#10
0
def gradient_angle(Ix, Iy):
    bstm_batch.init_process("vilGradientAngleProcess")
    bstm_batch.set_input_from_db(0, Ix)
    bstm_batch.set_input_from_db(1, Iy)
    bstm_batch.run_process()
    # x image
    (id, type) = bstm_batch.commit_output(0)
    angleImg = dbvalue(id, type)
    return angleImg
示例#11
0
def threshold_image(img, value, threshold_above=True):
    bstm_batch.init_process("vilThresholdImageProcess")
    bstm_batch.set_input_from_db(0,img)
    bstm_batch.set_input_float(1,value)
    bstm_batch.set_input_bool(2,threshold_above)
    bstm_batch.run_process()
    (id,type) = bstm_batch.commit_output(0)
    mask = dbvalue(id,type)
    return mask
示例#12
0
def threshold_image(img, value, threshold_above=True, id=255):
    bstm_batch.init_process("vilThresholdImageProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_float(1, value)
    bstm_batch.set_input_bool(2, threshold_above)
    bstm_batch.set_input_unsigned(3, id)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    mask = dbvalue(id, type)
    return mask
示例#13
0
def resize(img, ni, nj, pixel="float"):
    bstm_batch.init_process("vilResampleProcess")
    bstm_batch.set_input_from_db(0,img)
    bstm_batch.set_input_int(1, ni)
    bstm_batch.set_input_int(2, nj)
    bstm_batch.set_input_string(3, pixel);
    bstm_batch.run_process()
    (id,type) = bstm_batch.commit_output(0)
    img = dbvalue(id,type)
    return img
示例#14
0
def convert_to_generic_camera(cam_in, ni, nj, level=0):
    bstm_batch.init_process('vpglConvertToGenericCameraProcess')
    bstm_batch.set_input_from_db(0, cam_in)
    bstm_batch.set_input_unsigned(1, ni)
    bstm_batch.set_input_unsigned(2, nj)
    bstm_batch.set_input_unsigned(3, level)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    generic_cam = dbvalue(id, type)
    return generic_cam
示例#15
0
def persp2gen(pcam, ni, nj, level=0):
    bstm_batch.init_process("vpglConvertToGenericCameraProcess")
    bstm_batch.set_input_from_db(0, pcam)
    bstm_batch.set_input_unsigned(1, ni)
    bstm_batch.set_input_unsigned(2, nj)
    bstm_batch.set_input_unsigned(3, level)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    gcam = dbvalue(id, type)
    return gcam
示例#16
0
def resize(img, ni, nj, pixel="float"):
    bstm_batch.init_process("vilResampleProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_int(1, ni)
    bstm_batch.set_input_int(2, nj)
    bstm_batch.set_input_string(3, pixel)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    img = dbvalue(id, type)
    return img
示例#17
0
def ocl_info():
  #print("Init Manager");
  bstm_batch.init_process("boclInitManagerProcess");
  bstm_batch.run_process();
  (id, type) = bstm_batch.commit_output(0);
  mgr = dbvalue(id, type);

  print("Get OCL info");
  bstm_batch.init_process("bocl_info_process");
  bstm_batch.set_input_from_db(0,mgr)
  bstm_batch.run_process();
示例#18
0
def crop_image(img, i0, j0, ni, nj):
    bstm_batch.init_process("vilCropImageProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_unsigned(1, i0)
    bstm_batch.set_input_unsigned(2, j0)
    bstm_batch.set_input_unsigned(3, ni)
    bstm_batch.set_input_unsigned(4, nj)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    img_out = dbvalue(id, type)
    return img_out
示例#19
0
def crop_image(img, i0, j0, ni, nj):
    bstm_batch.init_process("vilCropImageProcess")
    bstm_batch.set_input_from_db(0, img)
    bstm_batch.set_input_unsigned(1, i0)
    bstm_batch.set_input_unsigned(2, j0)
    bstm_batch.set_input_unsigned(3, ni)
    bstm_batch.set_input_unsigned(4, nj)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    img_out = dbvalue(id, type)
    return img_out
示例#20
0
def ocl_info():
    #print("Init Manager");
    bstm_batch.init_process("boclInitManagerProcess")
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    mgr = dbvalue(id, type)

    print("Get OCL info")
    bstm_batch.init_process("bocl_info_process")
    bstm_batch.set_input_from_db(0, mgr)
    bstm_batch.run_process()
示例#21
0
def init_trajectory(scene, startInc, endInc, radius, ni=1280, nj=720) :
  bstm_batch.init_process("bstmViewInitTrajectoryProcess");
  bstm_batch.set_input_from_db(0, scene);
  bstm_batch.set_input_double(1, float(startInc) );  #incline0
  bstm_batch.set_input_double(2, float(endInc) ); #incline1
  bstm_batch.set_input_double(3, float(radius) ); #radius
  bstm_batch.set_input_unsigned(4, ni); #ni
  bstm_batch.set_input_unsigned(5, nj); #nj
  bstm_batch.run_process();
  (id,type) = bstm_batch.commit_output(0);
  trajectory = dbvalue(id,type);
  return trajectory;
示例#22
0
def init_trajectory(scene, startInc, endInc, radius, ni=1280, nj=720):
    bstm_batch.init_process("bstmViewInitTrajectoryProcess")
    bstm_batch.set_input_from_db(0, scene)
    bstm_batch.set_input_double(1, float(startInc))  # incline0
    bstm_batch.set_input_double(2, float(endInc))  # incline1
    bstm_batch.set_input_double(3, float(radius))  # radius
    bstm_batch.set_input_unsigned(4, ni)  # ni
    bstm_batch.set_input_unsigned(5, nj)  # nj
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    trajectory = dbvalue(id, type)
    return trajectory
示例#23
0
def render(scene, device, cache, cam, time=0, ni=1624, nj=1224, render_label=False) :
  if cache.type == "bstm_cache_sptr" :
    print "bstm_batch CPU render grey and vis not yet implemented";
    return;
  elif cache.type == "bstm_opencl_cache_sptr" and device :
    bstm_batch.init_process("bstmOclRenderExpectedImageProcess");
    bstm_batch.set_input_from_db(0,device);
    bstm_batch.set_input_from_db(1,scene);
    bstm_batch.set_input_from_db(2,cache);
    bstm_batch.set_input_from_db(3,cam);
    bstm_batch.set_input_unsigned(4,ni);
    bstm_batch.set_input_unsigned(5,nj);
    bstm_batch.set_input_float(6,time);
    bstm_batch.set_input_bool(7,render_label);
    bstm_batch.run_process();
    (id,type) = bstm_batch.commit_output(0);
    exp_image = dbvalue(id,type);
    (id,type) = bstm_batch.commit_output(1);
    vis_image = dbvalue(id,type);
    return exp_image,vis_image;
  else :
    print "ERROR: Cache type not recognized: ", cache.type;
示例#24
0
def update_change(scene, device, cache, cam, img, time, mask_img = None):
    bstm_batch.init_process("bstmOclUpdateChangeProcess");
    bstm_batch.set_input_from_db(0,device);
    bstm_batch.set_input_from_db(1,scene);
    bstm_batch.set_input_from_db(2,cache);
    bstm_batch.set_input_from_db(3,cam);
    bstm_batch.set_input_from_db(4,img);
    bstm_batch.set_input_from_db(5,mask_img);
    bstm_batch.set_input_float(6,time);
    bstm_batch.run_process();
    (id,type) = bstm_batch.commit_output(0);
    cd_img = dbvalue(id,type);
    return cd_img;
示例#25
0
def update_change(scene, device, cache, cam, img, time, mask_img=None):
    bstm_batch.init_process("bstmOclUpdateChangeProcess")
    bstm_batch.set_input_from_db(0, device)
    bstm_batch.set_input_from_db(1, scene)
    bstm_batch.set_input_from_db(2, cache)
    bstm_batch.set_input_from_db(3, cam)
    bstm_batch.set_input_from_db(4, img)
    bstm_batch.set_input_from_db(5, mask_img)
    bstm_batch.set_input_float(6, time)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cd_img = dbvalue(id, type)
    return cd_img
示例#26
0
def load_image(file_path):
    bstm_batch.init_process("vilLoadImageViewProcess")
    bstm_batch.set_input_string(0, file_path)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    (ni_id, ni_type) = bstm_batch.commit_output(1)
    (nj_id, nj_type) = bstm_batch.commit_output(2)
    ni = bstm_batch.get_output_unsigned(ni_id)
    nj = bstm_batch.get_output_unsigned(nj_id)
    img = dbvalue(id, type)
    bstm_batch.remove_data(ni_id)
    bstm_batch.remove_data(nj_id)
    return img, ni, nj
示例#27
0
def render(scene, device, cache, cam, time=0, ni=1624, nj=1224, render_label=False):
    if cache.type == "bstm_cache_sptr":
        print "bstm_batch CPU render grey and vis not yet implemented"
        return
    elif cache.type == "bstm_opencl_cache_sptr" and device:
        bstm_batch.init_process("bstmOclRenderExpectedImageProcess")
        bstm_batch.set_input_from_db(0, device)
        bstm_batch.set_input_from_db(1, scene)
        bstm_batch.set_input_from_db(2, cache)
        bstm_batch.set_input_from_db(3, cam)
        bstm_batch.set_input_unsigned(4, ni)
        bstm_batch.set_input_unsigned(5, nj)
        bstm_batch.set_input_float(6, time)
        bstm_batch.set_input_bool(7, render_label)
        bstm_batch.run_process()
        (id, type) = bstm_batch.commit_output(0)
        exp_image = dbvalue(id, type)
        (id, type) = bstm_batch.commit_output(1)
        vis_image = dbvalue(id, type)
        return exp_image, vis_image
    else:
        print "ERROR: Cache type not recognized: ", cache.type
示例#28
0
def load_image(file_path):
    bstm_batch.init_process("vilLoadImageViewProcess")
    bstm_batch.set_input_string(0, file_path)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    (ni_id, ni_type) = bstm_batch.commit_output(1)
    (nj_id, nj_type) = bstm_batch.commit_output(2)
    ni = bstm_batch.get_output_unsigned(ni_id)
    nj = bstm_batch.get_output_unsigned(nj_id)
    img = dbvalue(id, type)
    bstm_batch.remove_data(ni_id)
    bstm_batch.remove_data(nj_id)
    return img, ni, nj
示例#29
0
def load_opencl(scene_str, device_string="gpu"):
    scene = load_scene(scene_str)

    ###############################################################
    # Create cache, opencl manager, device, and gpu cache
    ###############################################################
    #print("Create Main Cache");
    bstm_batch.init_process("bstmCreateCacheProcess")
    bstm_batch.set_input_from_db(0, scene)
    bstm_batch.set_input_string(1, "lru")
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cache = dbvalue(id, type)

    #print("Init Manager");
    bstm_batch.init_process("boclInitManagerProcess")
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    mgr = dbvalue(id, type)

    #print("Get Gpu Device");
    bstm_batch.init_process("boclGetDeviceProcess")
    bstm_batch.set_input_string(0, device_string)
    bstm_batch.set_input_from_db(1, mgr)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    device = dbvalue(id, type)

    #print("Create Gpu Cache");
    bstm_batch.init_process("bstmOclCreateCacheProcess")
    bstm_batch.set_input_from_db(0, device)
    bstm_batch.set_input_from_db(1, scene)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    openclcache = dbvalue(id, type)

    return scene, cache, mgr, device, openclcache
示例#30
0
def load_opencl(scene_str, device_string="gpu"):
  scene = load_scene(scene_str);

  ###############################################################
  # Create cache, opencl manager, device, and gpu cache
  ###############################################################
  #print("Create Main Cache");
  bstm_batch.init_process("bstmCreateCacheProcess");
  bstm_batch.set_input_from_db(0,scene);
  bstm_batch.set_input_string(1,"lru");
  bstm_batch.run_process();
  (id,type) = bstm_batch.commit_output(0);
  cache = dbvalue(id, type);

  #print("Init Manager");
  bstm_batch.init_process("boclInitManagerProcess");
  bstm_batch.run_process();
  (id, type) = bstm_batch.commit_output(0);
  mgr = dbvalue(id, type);

  #print("Get Gpu Device");
  bstm_batch.init_process("boclGetDeviceProcess");
  bstm_batch.set_input_string(0,device_string)
  bstm_batch.set_input_from_db(1,mgr)
  bstm_batch.run_process();
  (id, type) = bstm_batch.commit_output(0);
  device = dbvalue(id, type);

  #print("Create Gpu Cache");
  bstm_batch.init_process("bstmOclCreateCacheProcess");
  bstm_batch.set_input_from_db(0,device)
  bstm_batch.set_input_from_db(1,scene)
  bstm_batch.run_process();
  (id, type) = bstm_batch.commit_output(0);
  openclcache = dbvalue(id, type);

  return scene, cache, mgr, device, openclcache;
示例#31
0
def load_perspective_camera_from_kml_file(NI, NJ, kml_file):
    bstm_batch.init_process("vpglLoadPerspCameraFromKMLFileProcess")
    bstm_batch.set_input_unsigned(0, NI)
    bstm_batch.set_input_unsigned(1, NJ)
    bstm_batch.set_input_string(2, kml_file)
    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cam = dbvalue(id, type)
    (id, type) = bstm_batch.commit_output(1)
    longitude = bstm_batch.get_output_double(id)
    (id, type) = bstm_batch.commit_output(2)
    latitude = bstm_batch.get_output_double(id)
    (id, type) = bstm_batch.commit_output(3)
    altitude = bstm_batch.get_output_double(id)
    return cam, longitude, latitude, altitude
示例#32
0
def change_detect(scene, device, cache, cam, img, time, mask_img=None, raybelief="", max_mode=False) :
    bstm_batch.init_process("bstmOclChangeDetectionProcess");
    bstm_batch.set_input_from_db(0,device);
    bstm_batch.set_input_from_db(1,scene);
    bstm_batch.set_input_from_db(2,cache);
    bstm_batch.set_input_from_db(3,cam);
    bstm_batch.set_input_from_db(4,img);
    bstm_batch.set_input_from_db(5,mask_img);
    bstm_batch.set_input_string(6, raybelief);
    bstm_batch.set_input_bool(7, max_mode);
    bstm_batch.set_input_float(8, time);

    bstm_batch.run_process();
    (id,type) = bstm_batch.commit_output(0);
    cd_img = dbvalue(id,type);
    return cd_img;
示例#33
0
def change_detect(scene, device, cache, cam, img, time, mask_img=None, raybelief="", max_mode=False):
    bstm_batch.init_process("bstmOclChangeDetectionProcess")
    bstm_batch.set_input_from_db(0, device)
    bstm_batch.set_input_from_db(1, scene)
    bstm_batch.set_input_from_db(2, cache)
    bstm_batch.set_input_from_db(3, cam)
    bstm_batch.set_input_from_db(4, img)
    bstm_batch.set_input_from_db(5, mask_img)
    bstm_batch.set_input_string(6, raybelief)
    bstm_batch.set_input_bool(7, max_mode)
    bstm_batch.set_input_float(8, time)

    bstm_batch.run_process()
    (id, type) = bstm_batch.commit_output(0)
    cd_img = dbvalue(id, type)
    return cd_img
示例#34
0
def render_change(scene, device, cache, cam, time=0, ni=1624, nj=1224):
    if cache.type == "bstm_cache_sptr":
        print "bstm_batch CPU render grey and vis not yet implemented"
        return
    elif cache.type == "bstm_opencl_cache_sptr" and device:
        bstm_batch.init_process("bstmOclRenderExpectedChangeProcess")
        bstm_batch.set_input_from_db(0, device)
        bstm_batch.set_input_from_db(1, scene)
        bstm_batch.set_input_from_db(2, cache)
        bstm_batch.set_input_from_db(3, cam)
        bstm_batch.set_input_unsigned(4, ni)
        bstm_batch.set_input_unsigned(5, nj)
        bstm_batch.set_input_float(6, time)
        bstm_batch.run_process()
        (id, type) = bstm_batch.commit_output(0)
        exp_image = dbvalue(id, type)
        return exp_image
    else:
        print "ERROR: Cache type not recognized: ", cache.type
示例#35
0
def render_change(scene, device, cache, cam, time=0, ni=1624, nj=1224) :
  if cache.type == "bstm_cache_sptr" :
    print "bstm_batch CPU render grey and vis not yet implemented";
    return;
  elif cache.type == "bstm_opencl_cache_sptr" and device :
    bstm_batch.init_process("bstmOclRenderExpectedChangeProcess");
    bstm_batch.set_input_from_db(0,device);
    bstm_batch.set_input_from_db(1,scene);
    bstm_batch.set_input_from_db(2,cache);
    bstm_batch.set_input_from_db(3,cam);
    bstm_batch.set_input_unsigned(4,ni);
    bstm_batch.set_input_unsigned(5,nj);
    bstm_batch.set_input_float(6, time );
    bstm_batch.run_process();
    (id,type) = bstm_batch.commit_output(0);
    exp_image = dbvalue(id,type);
    return exp_image;
  else :
    print "ERROR: Cache type not recognized: ", cache.type;
示例#36
0
def bundle2scene(bundle_file, img_dir, app_model="bstm_mog3_grey", isalign=True, out_dir="", timeSteps=32):
    if app_model == "bstm_mog3_grey":
        nobs_model = "bstm_num_obs"
    else:
        print "ERROR appearance model not recognized!!!", app_model
        return

    # run process
    bstm_batch.init_process("bstmBundleToSceneProcess")
    bstm_batch.set_input_string(0, bundle_file)
    bstm_batch.set_input_string(1, img_dir)
    bstm_batch.set_input_string(2, app_model)
    bstm_batch.set_input_string(3, nobs_model)
    bstm_batch.set_input_bool(4, isalign)
    bstm_batch.set_input_unsigned(5, timeSteps)
    bstm_batch.set_input_string(6, out_dir)
    bstm_batch.run_process()
    (scene_id, scene_type) = bstm_batch.commit_output(0)
    uscene = dbvalue(scene_id, scene_type)
    return uscene
示例#37
0
def bundle2scene(bundle_file, img_dir, app_model="bstm_mog3_grey", isalign= True, out_dir="", timeSteps = 32) :
  if app_model == "bstm_mog3_grey" :
    nobs_model = "bstm_num_obs";
  else:
    print "ERROR appearance model not recognized!!!", app_model;
    return

  #run process
  bstm_batch.init_process("bstmBundleToSceneProcess");
  bstm_batch.set_input_string(0, bundle_file);
  bstm_batch.set_input_string(1, img_dir);
  bstm_batch.set_input_string(2, app_model);
  bstm_batch.set_input_string(3, nobs_model);
  bstm_batch.set_input_bool(4, isalign);
  bstm_batch.set_input_unsigned(5, timeSteps);
  bstm_batch.set_input_string(6, out_dir);
  bstm_batch.run_process();
  (scene_id, scene_type) = bstm_batch.commit_output(0);
  uscene = dbvalue(scene_id, scene_type);
  return uscene;