예제 #1
0
//--------------------------------------------------------------
void testApp::setup(){

	camWidth 		= 640;	// try to grab at this size.
	camHeight 		= 480;
	appWidth        = ofGetWidth();
	appHeight       = ofGetHeight();
	mytimeThen		= 0.0f;
	myframeRate     = 0.0f;
	myframes        = 0.0f;

	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);

    videoGrabber.setDeviceID(0);


    Libdc1394Grabber *sdk = new Libdc1394Grabber;
	//sdk->setFormat7(VID_FORMAT7_0);
	sdk->listDevices();
	sdk->setDiscardFrames(true);
	sdk->set1394bMode(false);
	//sdk->setROI(0,0,320,200);
	//sdk->setDeviceID("b09d01008bc69e:0");

	ofxIIDCSettings *settings = new ofxIIDCSettings;
	settings->setXMLFilename("firewireSettings.xml");

	videoGrabber.setVerbose(true);
    bool result = videoGrabber.initGrabber( camWidth, camHeight, VID_FORMAT_YUV422, VID_FORMAT_RGB, 30, true, sdk, settings );

    //bool result = vidGrabber.initGrabber( camWidth, camHeight, VID_FORMAT_YUV422, VID_FORMAT_RGB, 30 );
	// or like this:
	//bool result = vidGrabber.initGrabber( camWidth, camHeight, VID_FORMAT_GREYSCALE, VID_FORMAT_GREYSCALE, 30, true, new Libdc1394Grabber);
	// or like this:
	//bool result = vidGrabber.initGrabber( camWidth, camHeight, VID_FORMAT_YUV411, VID_FORMAT_RGB, 30, true, new Libdc1394Grabber, new ofxIIDCSettings);



	if(result) {
	    ofLog(OF_LOG_VERBOSE,"Camera successfully initialized.");
	} else {
	    ofLog(OF_LOG_FATAL_ERROR,"Camera failed to initialize.");
	}

}
예제 #2
0
void tricks::vision::Camera::setup(int width, int height, string testVideoFile, string imagesFolder) {
	
	saveNextFrame = false;
	
	
#ifndef TEST_WITH_VIDEO
#ifdef _WIN32
	--
	firewire.setDeviceID(0);
	sdk = new FlyCaptureGrabber;
	sdk->listDevices();

	

#else
    Libdc1394Grabber *sdk = new Libdc1394Grabber;
	
	sdk->listDevices();
	sdk->setDiscardFrames(true);
	sdk->set1394bMode(false);
	char path[512];
	getcwd(path, 512);
	printf("Working directory: %s\n", ofToDataPath("", true).c_str());
	
#endif

	
	ofxIIDCSettings *settings = new ofxIIDCSettings;
	settings->setXMLFilename("mySettingsFile.xml");

	firewire.setVerbose(true);
	
#ifdef CAM_GREYSCALE
	bool result = firewire.initGrabber( width, height, VID_FORMAT_GREYSCALE, VID_FORMAT_GREYSCALE, 30, true, sdk, settings );
#else
	bool result = firewire.initGrabber( width, height, VID_FORMAT_YUV422, VID_FORMAT_RGB, 30, true, sdk, settings );
#endif
    canDoFirewire = result;

#ifdef _WIN32
	// setup the gui
	printf("Setted up gui\n");
	myGui.setup();
	myGui.addListener(this);
	
	int numProps = sdk->getNumProperties();
	for(int i = 0; i < numProps; i++) {
		string name;
		float value = 0;
		float min = 0;
		float max = 0;
		sdk->getPropertyInfo(i, name, value, min, max);
		float *f = new float;
		*f = value;
		printf("Value %f\n", value);
		//if(name=="BRIGHTNESS") max = 1024;
		myGui.addSlider(name, *f, min, max);
		cameraPropsIds[name] = i;
	}
#endif

	
#endif
	if(imagesFolder!="no-images") {
		this->imagesFolder = imagesFolder;
		imagePos = -1;
		nextImage();
	}
	canDoCamera = false;
#ifndef TEST_WITH_VIDEO
	if(result) {
		mode = CAMERA_MODE_FIREWIRE;
	} else if(videoGrabber.initGrabber(width, height)) {
		mode = CAMERA_MODE_QUICKTIME;
        canDoCamera = true;
	} else 
#endif
	{
		if(testVideoFile=="") {
			ofLogError("Video file path was empty, not gonna do a whole lot now");
		} else {
			printf("Trying to load %s\n", ofToDataPath(testVideoFile).c_str());
		}
		if(!testDataPlayer.loadMovie(testVideoFile)) {
			ofLogError("Couldn't load the movie, not gonna do shit now! %s", testVideoFile.c_str());
		}
		else {
			testDataPlayer.play();
			mode = CAMERA_MODE_RECORDED;
		}
	}
	
}