data_dir = "c:/Experiments/object_recognition/bvpl/CapitolSiteHigh/cropped_world"
output_dir = "c:/Experiments/object_recognition/bvpl/CapitolSiteHigh/gauss_xx_kernel"
#param_dir = "c:/Projects/vxl/vxl/contrib/brl/contrib/lemsvxl/src/contrib/isabel/params"


print("Load Voxel Grid");
bvpl_batch.init_process("bvxmLoadGridProcess");
bvpl_batch.set_input_string(0, data_dir +"/KL_gaussf1_cropped.vox");
bvpl_batch.set_input_string(1,"bsta_gauss_f1");
bvpl_batch.run_process();
(world_id,world_type)= bvpl_batch.commit_output(0);
world = dbvalue(world_id,world_type);

print("Creating 3D edge kernel");
bvpl_batch.init_process("bvplCreateGauss3dXXKernelVectorProcess");
bvpl_batch.set_input_float(0, 1.5);  #Sigma1
bvpl_batch.set_input_float(1, 2);  #Sigma2 
bvpl_batch.set_input_float(2, 2);  #Sigma3
bvpl_batch.run_process();
(kernel_id,kernel_type)= bvpl_batch.commit_output(0);
kernel_vector = dbvalue(kernel_id,kernel_type);

print("Running Operator");
bvpl_batch.init_process("bvplVectorOperatorProcess");
bvpl_batch.set_input_from_db(0,world );
bvpl_batch.set_input_from_db(1,kernel_vector);
bvpl_batch.set_input_string(2,"bsta_gauss_f1");
bvpl_batch.set_input_string(3,"gauss_convolution");
bvpl_batch.set_input_string(4, output_dir + "/gauss_xx_response_c.vox");
bvpl_batch.set_input_string(5, output_dir + "/gauss_xx_orientations_c.vox");
bvpl_batch.run_process();
# Script to run find 2d corners on appearance grid
# Author : Isabel Restrepo
#8-31-2009
import bvpl_batch
import time
import os
import sys
#time.sleep(30);
bvpl_batch.register_processes();
bvpl_batch.register_datatypes();

class dbvalue:
  def __init__(self, index, type):
    self.id = index    # unsigned integer
    self.type = type   # string
find_corners = 1;
load_corners = 0;
pair_corners = 1;
save_corners_vrml = 0;
save_pairs_vrml = 0;
save_centers_vrml = 0;
corner_length = 3;
corner_width = 3;
corner_thickness =1;
data_dir = sys.argv[1];
output_dir = sys.argv[2];
directions = sys.argv[3];
num_corners = int(sys.argv[4]);
print("Data Dir");
print data_dir;
# Script to run find 2d corners on appearance grid
# Author : Isabel Restrepo
#8-31-2009
import bvpl_batch
import time
#time.sleep(30);
bvpl_batch.register_processes();
bvpl_batch.register_datatypes();

class dbvalue:
  def __init__(self, index, type):
    self.id = index    # unsigned integer
    self.type = type   # string
find_corners = 1;
pair_corners = 1;
save_corners_vrml = 1;
save_hue = 0;
data_dir = "/Users/isa/Experiments/CapitolSFM/few_windows"

output_dir = "/Users/isa/Experiments/CapitolSFM/few_windows/ocp+app/main_corners_331"
directions = "main_corners"
if (find_corners):
	print("Load Voxel Grid");
	bvpl_batch.init_process("bvxmLoadGridProcess");
	bvpl_batch.set_input_string(0, data_dir +"/KL_gaussf1.vox");
	bvpl_batch.set_input_string(1,"bsta_gauss_f1");
	bvpl_batch.run_process();
	(world_id,world_type)= bvpl_batch.commit_output(0);
	app_grid = dbvalue(world_id,world_type);
	
if save_centers_vrml :

  print("Converting ID to Hue ");
  bvpl_batch.init_process("bvplConvertPairToHueProcess");
  bvpl_batch.set_input_from_db(0,pairs_grid );
  bvpl_batch.set_input_from_db(1,wc_kernel_vector);
  bvpl_batch.set_input_string(2, output_dir + "/hue_centers.vox");
  bvpl_batch.set_input_string(3, output_dir + "/hue.svg");
  bvpl_batch.run_process();
  (hue_grid_id,hue_grid_type)= bvpl_batch.commit_output(0);
  centers_hue_grid = dbvalue(hue_grid_id,hue_grid_type);

  print("Writing Orientation Grid");
  bvpl_batch.init_process("bvxmSaveRGBAGridVrmlProcess");
  bvpl_batch.set_input_from_db(0,centers_hue_grid);
  bvpl_batch.set_input_float(1,0.0);
  bvpl_batch.set_input_string(2,output_dir + "/all_centers.wrl");
  bvpl_batch.run_process();
	
if save_pairs_vrml :

  hue = 0.0;
  
  print("Visualize pairs");
  bvpl_batch.init_process("bvplVisualizeCornerPairsProcess");
  bvpl_batch.set_input_from_db(0,pairs );
  bvpl_batch.set_input_unsigned(1,0);
  bvpl_batch.set_input_string(2,output_dir +   "/all_lines.wrl");
  bvpl_batch.set_input_bool(3, 1);
  bvpl_batch.set_input_float(4, hue);
  bvpl_batch.run_process();