コード例 #1
0
ファイル: scene02.cpp プロジェクト: bestpaul1985/YesYesNo
//--------------------------------------------------------------
void scene02::keyPressed(int key){
    
    switch (key) {
        case OF_KEY_UP:
            dirLoadIndex++;
            if (dirLoadIndex>=(int)dir.size()) {
                dirLoadIndex=0;
            }
            loadLUT(dir.getPath(dirLoadIndex));
            
            break;
        case OF_KEY_DOWN:
            dirLoadIndex--;
            if (dirLoadIndex<0) {
                dirLoadIndex=dir.size()-1;
            }
            loadLUT(dir.getPath(dirLoadIndex));
            break;
            
        case ' ':
           
            if (photoAction == STAND_BY) {
                photoAction = COUNT_DOWN;
            }
            
            break;
    }

    
}
コード例 #2
0
ファイル: scene02.cpp プロジェクト: bestpaul1985/YesYesNo
//--------------------------------------------------------------
void scene02::setup(){
    
    photoAction = STAND_BY;
    counter = -1;
#ifdef _USE_4k_SCREEN
    
    if( !ofFile::doesFileExist("11to16.bin") ){
        ofSystemAlertDialog("Make sure you have 11to16.bin, xTable.bin and zTable.bin in your data folder!");
        ofExit();
    }
    
//    kinect.open();

    camWidth = 1920;
    camHeight = 1080;
    //---------------------------LUT
    dir.allowExt("cube");
	dir.listDir("LUTs/");
	dir.sort();
    dirLoadIndex=0;
    loadLUT(dir.getPath(dirLoadIndex));
	
	lutImg.allocate(camWidth, camHeight, OF_IMAGE_COLOR);
    lutPos.set(-lutImg.getWidth()*0.5f, lutImg.getHeight()*0.5f, 0);
    
	vector<ofVideoDevice> devices = vidGrabber.listDevices();
    for(int i = 0; i < devices.size(); i++){
		cout << devices[i].id << ": " << devices[i].deviceName;
        if( devices[i].bAvailable ){
            cout << endl;
        }else{
            cout << " - unavailable " << endl;
        }
	}
    
    grabWidth = 1080;
    grabHeight = 1080;
    
    //------------------------taking photo
    motor.loadImage("images/DL1000A_L4_RED_FRONT.png");
    countImage[0].loadImage("number1.png");
    countImage[1].loadImage("number2.png");
    countImage[2].loadImage("number3.png");
    color.set(255,0);
    
    //----------------------shader
    shader.load("photobooth_shaders/noise.vert", "photobooth_shaders/noise.frag");
    myFbo.allocate(camHeight,camWidth, GL_RGBA, 4);
    shaderFbo.allocate(camHeight, camWidth, GL_RGBA, 4);
    
#else
    camWidth = 960;
    camHeight = 540;
    //---------------------------LUT
    dir.allowExt("cube");
	dir.listDir("LUTs/");
	dir.sort();
    dirLoadIndex=0;
    loadLUT(dir.getPath(dirLoadIndex));
	
	lutImg.allocate(camWidth, camHeight, OF_IMAGE_COLOR);
    lutPos.set(-lutImg.getWidth()*0.5f, lutImg.getHeight()*0.5f, 0);
    
    //we can now get back a list of devices.
	vector<ofVideoDevice> devices = vidGrabber.listDevices();
    for(int i = 0; i < devices.size(); i++){
		cout << devices[i].id << ": " << devices[i].deviceName;
        if( devices[i].bAvailable ){
            cout << endl;
        }else{
            cout << " - unavailable " << endl;
        }
	}
    //------------------------------video grabber
	vidGrabber.setDeviceID(0);
	vidGrabber.setDesiredFrameRate(60);
    
	vidGrabber.setVerbose(true);
	vidGrabber.initGrabber(camWidth,camHeight);
    
    grabWidth = 520;
    grabHeight = 520;
    
    photoData 	= new unsigned char[grabWidth*grabHeight*3];
    grabTexture.allocate(2160, 2160,GL_RGB);
    
    //------------------------taking photo
    motor.loadImage("images/DL1000A_L4_RED_FRONT.png");
    countImage[0].loadImage("number1.png");
    countImage[1].loadImage("number2.png");
    countImage[2].loadImage("number3.png");
    color.set(255,0);
    
    //----------------------shader
    shader.load("photobooth_shaders/noise.vert", "photobooth_shaders/noise.frag");
    myFbo.allocate(camWidth, camHeight, GL_RGBA, 4);
    shaderFbo.allocate(camWidth, camHeight, GL_RGBA, 4);
    
#endif
    
  
    
    

}
コード例 #3
0
ファイル: camcapture.cpp プロジェクト: k29/PathPlanning
CamError CamCapture::init()
{
    if(isInit==true)
        return CAM_SUCCESS;

    //Loading lookup table
    if(doLUT == true)
    {
        printf("Loading lookup tables...");
        if(loadLUT(REDC)==false||loadLUT(BLUEC)==false||loadLUT(YELLOWC)==false||loadLUT(GREENC)==false||loadLUT(WHITEC)==false||loadLUT(BLACKC)==false)
        {
            printf("Unable to open LUT\n");
            return CAM_FAILURE;
        }
        printf("Loaded.\n");
    }
    //Initializing camera
	error = busMgr.GetCameraFromIndex(0, &guid);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return CAM_FAILURE;
    }

  	vm = FlyCapture2::VIDEOMODE_640x480Y8;
    fr = FlyCapture2::FRAMERATE_60;

    error = cam.Connect(&guid);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return CAM_FAILURE;
    }

    cam.SetVideoModeAndFrameRate(vm, fr);
    //Starting the capture
    error = cam.StartCapture();
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
       	return CAM_FAILURE;
    }

    cam.RetrieveBuffer(&rawImage);
    // Size variables cannot dynamically changed. Must be defined in constructor
    // width_var_full = rawImage.GetCols();
    // height_var_full = rawImage.GetRows();
    bayerimg = cvCreateImage(cvSize(rawImage.GetCols(), rawImage.GetRows()), 8, 1);
    rgbimg_full = cvCreateImage(cvSize(rawImage.GetCols(), rawImage.GetRows()), 8, 3);
    rgbimg = cvCreateImage(cvSize((rawImage.GetCols()*small_percent)/100, (rawImage.GetRows()*small_percent)/100), 8, 3);
    rgbimg_small = cvCreateImage(cvSize((rawImage.GetCols()*small_percent2)/100, (rawImage.GetRows()*small_percent2)/100), 8, 3);

#ifdef CAMCAPTURE_DEBUG
    showSeg = cvCreateImage(cvSize(rgbimg->width, rgbimg->height), 8, 3);
#endif

    // width_var = rgbimg->width;
    // height_var = rgbimg->height;
    isInit = true;
    return CAM_SUCCESS;

}