scriptContext* Mission::addContext( missionNode *node )
{
    scriptContext *context = makeContext( node );
    contextStack  *stack   = runtime.cur_thread->exec_stack.back();
    stack->contexts.push_back( context );

    debug( 5, node, SCRIPT_RUN, "added context for this node" );
    printRuntime();

    return context;
}
int main(int argc, char **argv){ 
	t = clock();
	cout << "calculating..." << endl;

    Params *par = new Params();
    // par->put("input_type.char","diffs");
    par->put("input_type.char","fulls");
    par->put("header_size.int",30.0);
    par->put("footnote_size.int",30.0);  
    par->put("camera_type.char","reconyx");
    par->put("diff_thres.int",60.0);
    par->put("median_size.int",9.0);
    par->put("output_image.char","out.png");
    par->put("input_images.char","images.txt");
    par->put("output_file.char","output.txt");
    par->put("draw_images.int",1.0);
    par->put("match_images.int",0.0);
    // par->put("match_images.int",1.0);
    par->put("image_width.int",340);
    par->put("image_height.int",280);
    par->put("min_coverage.float",0.007);
    par->put("max_coverage.float",0.80);
    par->put("confidence_thres.float",0.24);
    par->put("conf_factor.float",10);

    for(int i=1;i<argc;i++){ 
        if(!strcmp(argv[i],"-p")){
            par->load(argv[i+1]);
        }else if(!strcmp(argv[i],"-i")){
            par->put("input_images.char",argv[i+1]);
        }else if(!strcmp(argv[i],"-o")){
            par->put("output_file.char",argv[i+1]);
        }
    }

    vector<char *> filenames;
    vector<BB> bbs;
    loadFileNames(par->getString("input_images.char"),filenames);
    if(filenames.size()<1){ return 1; }
    
    printRuntime(t, clock(), "Load file names");

    float conf_factor = par->getValue("conf_factor.float");
    ofstream textoutput(par->getString("output_file.char"));

    // cout << "TEST01" << endl;
    // cout << par->getString("input_type.char") << endl;
    // cout << filenames[10] << endl;

    if(!strcmp(par->getString("input_type.char"),"fulls")){
		//clock_t temp_t = t;
        for(uint i=0; i<filenames.size(); i+=3){
            int sel = processSet(par, filenames, i, bbs, clock());
			
			//temp_t = printRuntime(temp_t, clock(), "dataset");
			
            if(bbs.size()>0){
                textoutput <<  filenames[i] << " " << bbs[0].valid << " " << bbs[sel].sx << " " << bbs[sel].sy << " " <<  bbs[sel].ex-bbs[sel].sx << " " << bbs[sel].ey-bbs[sel].sy  << " " << bbs[sel].confidence   << " " << bbs[sel].coverage  <<  "\n";
                // textoutput <<  filenames[i] << " " << bbs.size() << " " << bbs[sel].ex << " " << bbs[sel].ey << " " << bbs[sel].w << " " << bbs[sel].h << " " << bbs[sel].x << " " << bbs[sel].y << "\n";
                
            }else{
                textoutput <<  filenames[i] << " " << 0 << " " << 0 << " " << 0 << " " <<  0 << " " << 0  << " " << 0   << " " << 0  << "\n";
            }
            //cout << i << " " << filenames[i] << " of " << filenames.size() <<" bbs.size " <<  bbs.size()<< endl;

            bbs.clear();
        }
    }else{
        // (input_type.char == "diffs") --> computeDifferences(images)
        int sel = processSet(par, filenames, -1, bbs, clock());
        //textoutput << 0 << endl;
        if(bbs.size()>0){
            if(bbs[0].valid){
                //currently outputting this to output file
                textoutput <<  filenames[1] << " " << 1 << " " << round(conf_factor*bbs[sel].confidence) << " " << bbs[sel].sx << " " << bbs[sel].sy << " " <<  bbs[sel].ex-bbs[sel].sx << " " << bbs[sel].ey-bbs[sel].sy <<endl;
            }
        }
    }

    textoutput.close();
    
    printRuntime(t, clock(), "All of main");
    cout << "TESTOUT" << endl;

    //par->save("params.par");
    delete par;
    return 0;
}