Example #1
0
//--------------------------------------------------------------
void testApp::saveToDevice()
{
    weConnected = tcpClient.setup(ib->IP, 4321);
    tcpClient.setMessageDelimiter("\n");
    tcpClient.setVerbose(true);
    
    if(!tcpClient.isConnected())
    {
        weConnected=false;
        ofSystemAlertDialog("Uh-oh! Could not connect to the Rabbit!!! Try giving it some carrots.");
        return;
    }
    
    while(tcpClient.isConnected())
    {

        if(tcpClient.send(createCsvString()))
        {
            ofSystemAlertDialog("Yes! Upload successful!!!");
        }else
        {
            ofSystemAlertDialog("Whoops. Upload failed...");
        }
        
        tcpClient.close();
    }
    
    
    tcpClient.close();
    saveToDisk("OnRabbit.csv");

}
void ofxRGBDCaptureGui::loadDirectory(string path){
    if(path == ""){
        ofSystemAlertDialog("The Working directory empty. Resetting to bin/data/");
        loadDefaultDirectory();
        return;
    }
    
    ofDirectory workingDirPath(path);
    if(!workingDirPath.exists()){
        ofSystemAlertDialog("The Working directory empty. Resetting to bin/data/depthframes/");
        loadDefaultDirectory();     
        return;
    }
    
	workingDirectory = path;
	recorder.setRecordLocation(path+"/takes", "frame");
	ofDirectory dir(workingDirectory+"/calibration");
	if(!dir.exists()){
		dir.create(true);
	}
	alignment.loadState(workingDirectory+"/calibration/alignmentsave.xml");
	
	btnSetDirectory->setLabel(path);
	updateTakeButtons();
	ofxXmlSettings defaults;
	defaults.loadFile("defaults.xml");
	defaults.setValue("currentDir", path);
	defaults.saveFile("defaults.xml");
}
Example #3
0
bool THISTimeline::loadComposition(ofxXmlSettings compSettings)
{
	settings = compSettings;
	
	string sourceSequenceADirectory = settings.getValue("settings:source_directory_a", "");
	string sourceSequenceBDirectory = settings.getValue("settings:source_directory_b", "");
	string disortionSequenceDirectory = settings.getValue("settings:distortion_directory", "");
	string outputSequenceDirectory = settings.getValue("settings:output_directory", "");
	if(sourceSequenceADirectory != "" && ofDirectory::doesDirectoryExist(sourceSequenceADirectory)){
		sourceA->loadSequence(sourceSequenceADirectory);
	}
	else {
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Sequence A failed to load from directory " + sourceSequenceADirectory);
		return false;
	}
	
	if(sourceSequenceBDirectory != "" && ofDirectory::doesDirectoryExist(sourceSequenceBDirectory)){
		sourceB->loadSequence(sourceSequenceBDirectory);
	}
	else{
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Sequence B failed to load from directory: " + sourceSequenceBDirectory);
		return false;
	}
	
	if(disortionSequenceDirectory != "" && ofDirectory::doesDirectoryExist(disortionSequenceDirectory)){
		distortion->loadSequence(disortionSequenceDirectory);
		clearDistortionCaches();
		createDistortionCaches();
	}
	else{
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Distortion Sequence failed to load from directory: " + disortionSequenceDirectory);
		return false;
	}
	
	if(outputSequenceDirectory != "" && ofDirectory::doesDirectoryExist(outputSequenceDirectory)){
		exporter->pathPrefix = outputSequenceDirectory;
	}
	else {
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Output directory '" + outputSequenceDirectory + "' not found");
		return false;
	}
	
	if( !(sourceA->getTotalFrames() == sourceB->getTotalFrames() && sourceA->getTotalFrames() == distortion->getTotalFrames())){
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Sequence lengths do not match ");
		return false;
	}
		  
	minwidthkeys->durationInFrames = sourceB->getTotalFrames();
	maxwidthkeys->durationInFrames = sourceB->getTotalFrames();
	sourcekeys->durationInFrames = sourceB->getTotalFrames();
	blendkeys->durationInFrames = sourceB->getTotalFrames();
	
	playheadPosition = settings.getValue("settings:playhead", 0.0);
	
	return true;
}
//--------------------------------------------------------------
bool testApp::loadVideoFile(string hiResPath, string lowResPath){

	hasHiresVideo = (hiResPath != "");
	if(hasHiresVideo){
		if(hiResPlayer != NULL){
			delete hiResPlayer;
		}
		hiResPlayer = new ofVideoPlayer();

		if(!hiResPlayer->loadMovie(hiResPath)){
			ofSystemAlertDialog("Load Failed -- Couldn't load hi res video file.");
			return false;
		}
	}
	
	//must at least have a low res player
	//string lowResPath = ofFilePath::removeExt(path) + "_small.mov";
	if(lowResPlayer != NULL){
		delete lowResPlayer;
	}
	lowResPlayer = new ofVideoPlayer();
	if(!lowResPlayer->loadMovie(lowResPath)){
		ofSystemAlertDialog("Load Failed -- Couldn't load low res video file.");
		return false;		
	}
	
	
	if(hasHiresVideo){
		renderer.setTextureScale(1.0*lowResPlayer->getWidth()/hiResPlayer->getWidth(), 
								 1.0*lowResPlayer->getHeight()/hiResPlayer->getHeight());
	}
	else { //refer to the calibration stats

		float fullsizedWidth  = renderer.getRGBCalibration().getDistortedIntrinsics().getImageSize().width;
		float fullsizedHeight = renderer.getRGBCalibration().getDistortedIntrinsics().getImageSize().height; 
		cout << "image size is " << fullsizedWidth << " " << fullsizedHeight << endl;
		renderer.setTextureScale(1.0*lowResPlayer->getWidth()/fullsizedWidth, 
								 1.0*lowResPlayer->getHeight()/fullsizedHeight);
	}
	
	renderer.setRGBTexture(*lowResPlayer);
	string videoThumbsPath = ofFilePath::removeExt(lowResPath);
	if(!ofDirectory(videoThumbsPath).exists()){
		ofDirectory(videoThumbsPath).create(true);
	}
	videoTimelineElement.setup();	
//	timeline.setDurationInFrames(lowResPlayer->getTotalNumFrames());
	videoTimelineElement.setVideoPlayer(*lowResPlayer, videoThumbsPath);
	lowResPlayer->play();
	lowResPlayer->setSpeed(0);
	
	return true;
}
Example #5
0
 void showHelp() {
     ofSystemAlertDialog("Doodle3D version " + getVersion() + " - www.doodle3d.com\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"
                         "Did you know you can use Doodle3D on your iPad?\n\n"
                         "1. Connect with your tablet to the '" + getWirelessNetwork() + "' network.\n\n"
                         "2. On your tablet open this webpage:\n\n"
                         "http://" + getIP() + ":" + ofToString(serverPort));
 }
Example #6
0
//--------------------------------------------------------------
void ofApp::setup(){
    if( !ofFile::doesFileExist("11to16.bin") ){
        ofSystemAlertDialog("Make sure you have 11to16.bin, xTable.bin and zTable.bin in your data folder!");
        ofExit(); 
    }

    ofBackground(30, 30, 30);

    extrude.set("extrudeDepth", 500.0, 0.0, 1000.0);
    depthLeft.set("depthLeft",0.0,0.0,1.0);
    depthRight.set("depthRight",1.0, 0.0, 1.0);
    
    panel.setup("distance in mm", "settings.xml", 540, 100);
    panel.add(kinect.minDistance);
    panel.add(kinect.maxDistance);
    panel.add(extrude);
//    panel.add(depthLeft);
//    panel.add(depthRight);
    panel.loadFromFile("settings.xml");
    
    pointCloudShader.load("shader/pointCloud");
    
    kinect.open();
    
    camera.setPosition(ofGetWidth()/2.0, ofGetHeight()/2.0, 700.0);
    camera.roll(180.0);
}
Example #7
0
//--------------------------------------------------------------
void testApp::saveToDisk(string saveFileName)
{
    if(saveFileName=="")
        return;
    
    ofFile tempFile = saveFileName;
    if(!tempFile.exists())
    {
        tempFile.create();
    }
    
    if(!tempFile.canWrite())
    {
        ofSystemAlertDialog(ofToString(tempFile)+ " can not be written");
        return;
    }
    
    ofBuffer csvData = createCsvString();
    bool fileWritten = ofBufferToFile(saveFileName, csvData);
    if(fileWritten)
        ofLog(OF_LOG_NOTICE, saveFileName+" saved");
    
    curList.open(saveFileName);
    savePrevious(saveFileName);

}
Example #8
0
	//----------
	void Scene::draw() {
		if (!this->initialised) {
			ofSystemAlertDialog("You are calling ofxGrabScene::draw without first calling init, we're exiting!");
			ofExit();
		}
		
		this->camera->begin();
		
		ofPushStyle();
		ofEnableAlphaBlending();
		
		this->drawNodesAndElements();
		this->camera->updateCursorWorld();
		this->drawIndexBuffer();
		this->drawOutlines();
		
		ofPopStyle();
		
		////
		//cache values for unprojection of mouse
		this->viewport = ofGetCurrentViewport();
		glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix.getPtr());
		glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix.getPtr());
		glGetDoublev(GL_MODELVIEW_MATRIX, viewDoubles);
		glGetDoublev(GL_PROJECTION_MATRIX, projectionDoubles);
		//
		////
		
		this->camera->end();
		
		this->drawOverlay();
	}
//--------------------------------------------------------------
bool testApp::loadNewProject(){
	allLoaded = false;
	ofSystemAlertDialog("Select Someone's Name");
	ofFileDialogResult r;
	r = ofSystemLoadDialog("Get Directory", true);
	if(!r.bSuccess){
		return false;
	}
		
	string currentMediaFolder = r.getPath();	
	
	ofDirectory compBin(currentMediaFolder + pathDelim + "compositions"+pathDelim);
	if(!compBin.exists()){
		compBin.create(true);
	}	
	compBin.listDir();
	
	int compNumber = compBin.numFiles();
	currentCompositionDirectory = currentMediaFolder + pathDelim+"compositions"+pathDelim+"comp" + ofToString(compNumber) + pathDelim;
	currentCompIndex = compNumber;
	
	if(!loadAssetsFromCompositionDirectory(currentMediaFolder)){
		return false;
	}
	
	saveComposition();
	refreshCompButtons();
	loadTimelineFromCurrentComp();
	
	allLoaded = true;
	return true;
}
Example #10
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){

    if(key == ' ')
    {
        if (elemV1.leftChannelPlayer.isPlaying()) elemV1.element_videoPause();
        else elemV1.element_videoPlay(1);
    }
    
    else if (key== OF_KEY_BACKSPACE) elemV1.element_videoStop();
    
//    else if(key == '.') elemV1.element_frameAvanti();
//    
//    else if(key == ',') elemV1.element_frameIndietro();        
    
    else if(key == 'i') ofSystemAlertDialog(comandi);

    else if(key == OF_KEY_F1) minimalGUI->setVisible(true);
    
    else if(key == '-') swapLeftRight=!swapLeftRight;
    
    else if(key == 'e') elemV1.setElementInputType(ELM_INPUT_STEREO_LEFTRIGHT);
    
    else if(key == '0') elemV1.bDrawCalibrationImg=!elemV1.bDrawCalibrationImg;
        
    else elemV1.warper.warpKeyPressedHandler(key);
    
    
}
//--------------------------------------------------------------
void testApp::loadCompositions(){
	ofSystemAlertDialog("Select the MediaBin containing everyone's names");

	ofFileDialogResult r = ofSystemLoadDialog("Select Media Bin", true);
	if(r.bSuccess){
		mediaBinDirectory = r.getPath();
		refreshCompButtons();
	}
}
Example #12
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofBackground(0);
	ofSetFrameRate(60);
	kinect.setRegistration(true);
	kinect.init();
	kinect.open();
	if(!kinect.isConnected()){
		ofSystemAlertDialog("not connected.");
	}
}
void ofxRGBDCaptureGui::loadDirectory(){
    if(recorder.numFramesWaitingCompession() != 0){
    	ofSystemAlertDialog("Cannot change directory while files are converting");
		return;
    }
    
	ofFileDialogResult r = ofSystemLoadDialog("Select Record Directory", true);
	if(r.bSuccess){
		loadDirectory(r.getPath());
	}
}
Example #14
0
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
	ofVec2f mouse(x,y);
	if(xmpp.getConnectionState()==ofxXMPPConnected && sendButton.inside(mouse) && selectedFriend!=-1){
		ofFileDialogResult file = ofSystemLoadDialog("select a file to send",false);
		if(file.bSuccess){
			xmppFileTransfer.sendFile(xmpp.getFriends()[selectedFriend].userName + "/" + xmpp.getFriends()[selectedFriend].resource,file.getPath());
		}
	}else if(selectedFriend==-1){
		ofSystemAlertDialog("No user selected to send a file");
	}
}
Example #15
0
//--------------------------------------------------------------
void testApp::loadFromDevice()
{
    //close any previous connections
    tcpClient.close();
    
    //make new connection
    weConnected = tcpClient.setup(ib->IP, 4322);
    tcpClient.setMessageDelimiter("\n");
    tcpClient.setVerbose(true);
    
    //clear the previous messages
    receivedMessage.clear();
    
    if(!tcpClient.isConnected())
    {
        weConnected=false;
        ofSystemAlertDialog("Uh-oh! Could not connect to the Rabbit!!! Make sure it's connected and has enough carrots.");
        return;
    }
    

    while(tcpClient.isConnected())
    {
        string s = tcpClient.receive();
        
        if( s.length() > 0 ){
            receivedMessage.push_back(s);
        }
    }

    readCsvString(receivedMessage);        
        
    tcpClient.close();
    
    saveToDisk("OnRabbit.csv");
    ofSystemAlertDialog("Data retrieved from the Rabbit!");

    
}
Example #16
0
//----------
void ofxWatermark::init(string filename, string hash) {
	ofFile file(filename);
	auto buffer = file.readToBuffer();
	
	unsigned char fileHash[MD5_DIGEST_LENGTH];
	MD5((unsigned char *)buffer.getBinaryBuffer(), buffer.size(), fileHash);

	if (hashToString(fileHash) != hash) {
		ofSystemAlertDialog("The watermark hash does not match. Tamper alert! Quitting!");
		ofExit();
	}

	this->loadImage(buffer);
}
Example #17
0
ofFileDialogResult testApp::updateProjectViaDialog(){

#ifndef COMMAND_LINE_ONLY
    ofFileDialogResult res = ofSystemLoadDialog("choose a folder to update an OF project :)",true);
    if (res.fileName == "" || res.filePath == "") return res;
    //base.pushDirectory(res.fileName);   // somehow an extra things here helps?

    vector <int> targetsToMake;
	if( osxToggle )		targetsToMake.push_back(OF_TARGET_OSX);
	if( iosToggle )		targetsToMake.push_back(OF_TARGET_IPHONE);
	if( wincbToggle )	targetsToMake.push_back(OF_TARGET_WINGCC);
	if( winvsToggle )	targetsToMake.push_back(OF_TARGET_WINVS);
	if( linuxcbToggle )	targetsToMake.push_back(OF_TARGET_LINUX);
	if( linux64cbToggle )	targetsToMake.push_back(OF_TARGET_LINUX64);

	if( targetsToMake.size() == 0 ){
		cout << "Error: updateProjectViaDialog - must specifiy a project to generate " <<endl;
		ofSystemAlertDialog("Error: updateProjectViaDialog - must specifiy a project platform to generate");
	}

	for(int i = 0; i < (int)targetsToMake.size(); i++){
		setupForTarget(targetsToMake[i]);
        project->setup(target);
        project->create(res.filePath);
        vector<string> addonsToggles = panelAddons.getControlNames();
        for (int i = 0; i < (int)addonsToggles.size(); i++){
            ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]);
            // TODO: make this remove existing addons that are unchecked????
            // probably requires a more complex logic chain: loadProject
            // (ticks the addons) and then you can untick etc???
            if(toggle){
                ofAddon addon;
                addon.pathToOF = getOFRelPath(res.filePath);
                addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target);
                printf("adding %s addons \n", addonsToggles[i].c_str());
                project->addAddon(addon);

            }
        }
        project->save(true);
	}

	return res;
#endif

}
Example #18
0
void testApp::openSampleImage() {
    ofFileDialogResult res = ofSystemLoadDialog("Open Sample Image");
    
    if (!res.bSuccess) return;
    
    string filepath = res.getPath();
    cout << "Will load sample image " << filepath << endl;
    ofImage loaded;
    if (loaded.loadImage(filepath)) {
        
        rawImage.setFromPixels(loaded.getPixels(), loaded.width, loaded.height);
        this->processRawImage();
        
    }
    else {
        ofSystemAlertDialog("ERROR LOADING IMAGE " + filepath);
    }
}
Example #19
0
ofFileDialogResult testApp::makeNewProjectViaDialog(){

#ifndef COMMAND_LINE_ONLY
    ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)");
    if (res.fileName == "" || res.filePath == "") return res;
    //base.pushDirectory(res.fileName);   // somehow an extra things here helps?

    vector <int> targetsToMake;
	if( osxToggle )		targetsToMake.push_back(OF_TARGET_OSX);
	if( iosToggle )		targetsToMake.push_back(OF_TARGET_IPHONE);
	if( wincbToggle )	targetsToMake.push_back(OF_TARGET_WINGCC);
	if( winvsToggle )	targetsToMake.push_back(OF_TARGET_WINVS);
	if( linuxcbToggle )	targetsToMake.push_back(OF_TARGET_LINUX);
	if( linux64cbToggle )	targetsToMake.push_back(OF_TARGET_LINUX64);

	if( targetsToMake.size() == 0 ){
		cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl;
		ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate");
	}

	for(int i = 0; i < (int)targetsToMake.size(); i++){
		setupForTarget(targetsToMake[i]);
        project->setup(target);
        if(project->create(res.filePath)){
            vector<string> addonsToggles = panelAddons.getControlNames();
            for (int i = 0; i < (int) addonsToggles.size(); i++){
                ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]);
                if(toggle){
                    ofAddon addon;
                    addon.pathToOF = getOFRelPath(res.filePath);
                    addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target);
                    printf("adding %s addons \n", addonsToggles[i].c_str());
                    project->addAddon(addon);

                }
            }
            project->save(true);
        }
	}
    return res;
#endif

}
Example #20
0
bool THISTimeline::loadComposition(string compFolder)
{
	if(compFolder == "" || !ofDirectory::doesDirectoryExist(compFolder, false)){
		ofLog(OF_LOG_ERROR, "THISTimeline -- comp '" + compFolder + "' failed to load");
		return false;
	}

	setWorkingFolder(compFolder);
	
    if(settings.loadFile(settingsFileName)){
		return loadComposition(settings);
    }
	else{
		ofSystemAlertDialog("THISTimeline -- LOAD COMP -- Failed to load settings file '" + settingsFileName + "'.");
		exporter->pathPrefix = compFolder;
		return false;
	}
	return true;
}
Example #21
0
//--------------------------------------------------------------
void testApp::setup() {

    moviesLoaded = false;
    ofSystemAlertDialog("Select directory of calibration clips");
    ofFileDialogResult r = ofSystemLoadDialog("Calibration Directory", true);
    if(r.bSuccess) {
        movieDirectory = ofDirectory(r.getPath());
        movieDirectory.allowExt("mov");
        movieDirectory.allowExt("mp4");
        movieDirectory.listDir();
        for(int i = 0; i < movieDirectory.numFiles(); i++) {
            ofVideoPlayer p;
            p.loadMovie( movieDirectory.getPath(i) );
            videoplayers.push_back( p );
        }
        currentMovie = 0;
        moviesLoaded = true;
    }
}
Example #22
0
void ofApp::loadMesh()
{
	ofFileDialogResult openFileResult = ofSystemLoadDialog("Select 3D Model to load");
	if(openFileResult.bSuccess)
	{
		ofLogVerbose() << "File Selected: " << openFileResult.fileName;
	}
	else
	{
		ofSystemAlertDialog("Loading file cancelled or failed.");
		return;
	}


	if(loadedMesh.loadModel(openFileResult.filePath))
	{
		ofLogVerbose() << "Model loaded successfully: " << loadedMesh.getMeshNames()[0];
	}
	cam.setTarget(loadedMesh.getPosition());
}
Example #23
0
//--------------------------------------------------------------
void ofApp::setup() {
    if( !ofFile::doesFileExist("11to16.bin") ) {
        ofSystemAlertDialog("Make sure you have 11to16.bin, xTable.bin and zTable.bin in your data folder!");
        ofExit();
    }
    ofBackground(30, 30, 30);

    // gui
    panel.setup("distance in mm", "settings.xml", 540, 100);
    panel.add(kinect.minDistance);
    panel.add(kinect.maxDistance);
    panel.add(step.set("step", 5, 3, 100));
    panel.loadFromFile("settings.xml");

    // kinect
    kinect.open();

    // debug
    ofSetVerticalSync(false);
    ofSetFrameRate(0);
}
//--------------------------------------------------------------
void testApp::setup(){
//	ofSetFrameRate(30);
	ofSystemAlertDialog("Load a directory of .xkcd files");
	ofFileDialogResult r = ofSystemLoadDialog("Load uncompressed xkcd directory", true);
	if(r.bSuccess){
		
		ofDirectory dir(r.getPath());
		dir.allowExt("xkcd");
		dir.listDir();
		
		unsigned short* lastbuf = new unsigned short[640*480];
		unsigned short* tempbuf = new unsigned short[640*480];
		string pngDirPath = r.getPath() + "_pngs";
		ofDirectory pngDir = ofDirectory(pngDirPath);
		if(!pngDir.exists()){
			pngDir.create(true);
		}

		ofSystemAlertDialog("Optionally load a pairing file to fix");
		r = ofSystemLoadDialog("Load pairing file to repair", false);
		if(r.bSuccess){
			pairingFileLoaded = true;
			pairingFileName = r.getPath();
			oldPairing.loadPairingFile(pairingFileName);
		}
		else{
			pairingFileLoaded = false;
		}
		
		
		time_t original = 0;
		time_t last = 0; 
		int total;
		int currentOutputFile = 0;
		for(int i = 0; i < dir.numFiles(); i++){
			
			string path = dir.getPath(i);
			memcpy(lastbuf, tempbuf, sizeof(unsigned short)*640*480);
			decoder.readDepthFrame(path, tempbuf);
			
			//check if we have a matching pair for this frame
			int thisDepthFrame = ofToInt(dir.getName(i).substr(dir.getName(i).find(".xkcd")-5,5) );
			if(pairingFileLoaded){
				for(int p = 0; p < oldPairing.getPairs().size(); p++){
					VideoDepthPair pair = oldPairing.getPairs()[p];
					if(pair.depthFrame == thisDepthFrame){
						pair.depthFrame = currentOutputFile;
						newPairing.addAlignedPair(pair);
						cout << "CONVERTED PAIR: " << thisDepthFrame << " to " << pair.depthFrame << endl;
						break;
					}
				}
			}
			
			//check for duplicate
			if(i != 0){
				bool identical = true;

				for (int p = 0; p < 640*480; p++) {
					if(lastbuf[p] != tempbuf[p]){
						identical = false;
						break;
					}
				}
				
				if(identical) continue;
			}
			
			char framestr[1024];
			sprintf(framestr, "%05d", currentOutputFile);
			string newPath = pngDirPath + "/frame__" + string(framestr) + ".png";

			decoder.saveToCompressedPng(newPath, tempbuf);
			currentOutputFile++;
			
			struct stat fileInfo;
			int r  = stat(path.c_str(), &fileInfo);
			time_t t = fileInfo.st_mtimespec.tv_sec;
			if(i == 0){
				original = t;
				last = 0;
			}
			
			if( (t-original) != last){
				cout << "time " << last << " had " << total << " frames " << endl;
				total = 1;
				last = t-original;
			}
			else{
				total++;
			}
			
			//cout << "file " << path << " created at " << ( t-original ) << " " << fileInfo.st_mtimespec.tv_nsec << endl;
			cout << "saved " << path << " to " << newPath << endl;
		}
		if(pairingFileLoaded){
			newPairing.savePairingFile(pairingFileName+".corrected.xml");
		}
	}
}
Example #25
0
//--------------------------------------------------------------
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
    
  
    
    

}
Example #26
0
void THISTimeline::newComposition(){
	ofSystemAlertDialog("Choose where to save your comp files");
	string newWorkingDirectory = "";
	string newADir = "";
	string newBDir = "";
	string newDistortDir = "";
	string newOutDir = "";
	ofFileDialogResult result;
	result = ofSystemLoadDialog("Choose Comp Directory", true);
	if(result.bSuccess){
		newWorkingDirectory = result.filePath;
	}
	else{
		ofSystemAlertDialog("You didn't select a Comp directory.");
		return;
	}
	
	ofSystemAlertDialog("Choose SOURCE A sequence folder");
	result = ofSystemLoadDialog("Choose SOURCE A sequence folder", true);
	if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){
		newADir = result.filePath;
	}
	else{
		ofSystemAlertDialog("Failed to load Source A Sequence directory");
		return;
	}
	
	ofSystemAlertDialog("Choose SOURCE B sequence folder");
	result = ofSystemLoadDialog("Choose SOURCE B sequence folder", true);
	if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){
		newBDir = result.filePath;
	}
	else{
		ofSystemAlertDialog("Failed to load Source B Sequence");
		return;
	}
	
	ofSystemAlertDialog("Choose DISTORTION sequence folder");
	result = ofSystemLoadDialog("Choose DISTORTION sequence folder", true);
	if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){
		newDistortDir = result.filePath;
	}
	else{
		ofSystemAlertDialog("Failed to load Distortion Sequence");
		return;
	}
	
	ofSystemAlertDialog("Set OUTPUT Directory");			
	result = ofSystemLoadDialog("Set Output Directory", true);
	if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){
		newOutDir = result.filePath;
	}
	else{
		ofSystemAlertDialog("Failed to select output directory");
		return;
	}
	
	setWorkingFolder(newWorkingDirectory);
	settings.setValue("settings:source_directory_a", newADir);		
	settings.setValue("settings:source_directory_b", newBDir);
	settings.setValue("settings:distortion_directory", newDistortDir);
	exporter->pathPrefix = newOutDir;
	settings.setValue("settings:output_directory", newOutDir);
	
	loadComposition(settings);	
	settings.saveFile(settingsFileName);

}
Example #27
0
//--------------------------------------------------------------
void ofApp::setup() {
    this->gui.init();

    auto widgets = this->gui.addWidgets();
    widgets->addTitle("MultiTrack Receive");
    widgets->addFps();
    widgets->addMemoryUsage();
    widgets->addLiveValue<int>("Receiving on port", [this]() {
        return (float) this->receiver.getReceiver().getPort();
    });
    widgets->addIndicator("Frame incoming", [this]() {
        return this->newFrame;
    });
    widgets->addLiveValueHistory("Receiver incoming frame rate", [this]() {
        return (float) this->receiver.getReceiver().getIncomingFramerate();
    });
    widgets->addLiveValueHistory("Dropped frames", [this]() {
        return (float) this->receiver.getReceiver().getDroppedFrames().size();
    });
    widgets->addLiveValue<string>("Sending Body OSC to ", [this]() {
        return this->oscHost + ":" + ofToString(this->oscPort);;
    });

    //initialise receiver
    {
        auto port = 4444;

        while (!this->receiver.init(port)) {
            port++;
        }

        this->clientIndex = port - 4444;
        widgets->addLiveValue<float>("Client index", [this]() {
            return this->clientIndex;
        });

        this->oscPort = port + 1000;

        this->gui.add(ofxCvGui::Panels::makeTexture(this->color.texture, "Color"));
        this->gui.add(ofxCvGui::Panels::makeTexture(this->depth.texture, "Depth"));
        this->gui.add(ofxCvGui::Panels::makeTexture(this->infrared.texture, "Infrared"));
        this->gui.add(ofxCvGui::Panels::makeTexture(this->bodyIndex.texture, "BodyIndex"));
        this->gui.add(ofxCvGui::Panels::makeTexture(this->colorCoordInDepthFrame.texture, "ColorCoordInDepthView"));

        auto worldPanel = this->gui.addWorld();
        worldPanel->onDrawWorld += [this](ofCamera &) {
            auto & frame = this->receiver.getFrame();
            const auto & bodies = frame.getBodies();
            const auto & boneAtlas = ofxKinectForWindows2::Data::Body::getBonesAtlas();
            for (const auto & body : bodies) {
                body.drawWorld();
            }
        };
    }


    //initialise texture sharing
    {
        try {
            auto suffix = ofToString(this->clientIndex);

            this->color.sender.init("color" + suffix);
            this->depth.sender.init("depth" + suffix);
            this->infrared.sender.init("infrared" + suffix);
            this->bodyIndex.sender.init("bodyIndex" + suffix);
            this->colorCoordInDepthFrame.sender.init("colorCoordInDepthFrame" + suffix);
        }
        catch (std::exception e) {
            ofSystemAlertDialog(string("Couldn't initialise Spout texture sharing : ") + e.what());
        }
        catch (...) {
            ofSystemAlertDialog("Couldn't initialise Spout texture sharing");
        }
    }


    //initialise osc (not a standard format)
    {
        this->oscSender.setup(this->oscHost, this->oscPort);
    }

    ofSetFrameRate(60);
}
Example #28
0
//-----------------------------------------------------------------
void elementVideo::setElementInputType(int _inType)
{
    inputType=_inType;
    
    
    if (getElementInputType() == ELM_INPUT_MONO)
    {
        leftChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        rightChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        
        rightChannelPlayer.close();
        
    }
    else if (getElementInputType() == ELM_INPUT_STEREO_TWO_CHANNEL)
    {
        leftChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        rightChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        if (rightChannelPath!="") rightChannelPlayer.loadMovie(rightChannelPath);   
        else ofSystemAlertDialog("ERROR: this mode requires TWO separate videos!");        
        
        
    }
    if (getElementInputType() == ELM_INPUT_STEREO_LEFTRIGHT)
    {
        leftChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        rightChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        
        rightChannelPlayer.close();
        
        //prepare left:
        tempLeft.allocate(leftChannelPlayer.getWidth()*.5, leftChannelPlayer.getHeight());
        lT.clear();
        lT.allocate(leftChannelPlayer.getWidth()*.5, leftChannelPlayer.getHeight(), GL_RGBA);
        
        //prepare right:
        tempRight.allocate(leftChannelPlayer.getWidth()*.5, leftChannelPlayer.getHeight());
        rT.clear();
        rT.allocate(leftChannelPlayer.getWidth()*.5, leftChannelPlayer.getHeight(), GL_RGBA);
        
    }
    else if (getElementInputType() == ELM_INPUT_STEREO_TOPBOTTOM)
    {
        leftChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        rightChannelPlayer.setPixelFormat(OF_PIXELS_RGBA);
        
        rightChannelPlayer.close();
        //prepare left:
        tempLeft.allocate(leftChannelPlayer.getWidth(), leftChannelPlayer.getHeight()*.5);
        lT.clear();
        lT.allocate(leftChannelPlayer.getWidth(), leftChannelPlayer.getHeight()*.5, GL_RGBA);
        
        //prepare right:
        tempRight.allocate(leftChannelPlayer.getWidth(), leftChannelPlayer.getHeight()*.5);
        rT.clear();
        rT.allocate(leftChannelPlayer.getWidth(), leftChannelPlayer.getHeight()*.5, GL_RGBA);        
    }
    
    //    cout << "width: " << parentElement->warper.width<< endl;
    //    cout << "text.getWidth: " << parentElement->warper.text.getWidth() << endl;
    
    //    parentElement->warper.createGrid(parentElement->warper.xRes, parentElement->warper.yRes);
    //    parentElement->warper.updateCoordinates();
    //    parentElement->warper.createGrid(parentElement->warper.xRes, parentElement->warper.yRes);
    
    
}
void testApp::generateProject(){
    
    vector <int> targetsToMake;
    for(int i = 0; i < platformsList.elements.size(); i++){
        if ( *(platformsList.elements[i]) == true ){
            if (platformsList.elements[i]->text == "windows (codeblocks)" ){
                targetsToMake.push_back(OF_TARGET_WINGCC);
            } else if (platformsList.elements[i]->text == "windows (visualStudio)"){
                targetsToMake.push_back(OF_TARGET_WINVS);
            } else if (platformsList.elements[i]->text == "linux (codeblocks)"){
                targetsToMake.push_back(OF_TARGET_LINUX);
            } else if (platformsList.elements[i]->text == "linux64 (codeblocks)"){
                targetsToMake.push_back(OF_TARGET_LINUX64);
            } else if (platformsList.elements[i]->text == "osx (xcode)"){
                targetsToMake.push_back(OF_TARGET_OSX);
            } else if (platformsList.elements[i]->text == "ios (xcode)"){
                targetsToMake.push_back(OF_TARGET_IPHONE);
            }
        }
    }
    
    cout << targetsToMake.size() << endl;
    
	if( targetsToMake.size() == 0 ){
		cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl;
		ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate");
        return;
	}
    
    if (buttons[0]->text.size() == 0){
        ofSystemAlertDialog("Error: project must have a name");
        return;
    }
    
    printf("start with project generation \n");
    
    string path = ofFilePath::join(buttons[1]->text, buttons[0]->text);
    
	for(int i = 0; i < (int)targetsToMake.size(); i++){
		string target = setTarget(targetsToMake[i]);
        
        if(project->create(path)){
            
            vector<string> addons = coreAddonsList.getSelected(); 
            for (int i = 0; i < addons.size(); i++){
                ofAddon addon;
                addon.pathToOF = getOFRelPath(path);
                addon.fromFS(ofFilePath::join(addonsPath, addons[i]),target);
                project->addAddon(addon);
            }
            
            addons = coreAddonsList.getSelected();
            for (int i = 0; i < addons.size(); i++){
                ofAddon addon;
                addon.pathToOF = getOFRelPath(path);
                addon.fromFS(ofFilePath::join(addonsPath, addons[i]),target);
                project->addAddon(addon);
            }
            
            project->save(true);
        }
        
        setStatus("generated: " + buttons[1]->text + "/" + buttons[0]->text + " for " + platformsList.getSelected()[i]);
	}
    
    printf("done with project generation \n");
    // go through the control panels, do stuff
}
Example #30
0
void ofApp::onFileSavedCorrectly(ofxXMPPFileReceive & file){
	ofSystemAlertDialog(file.path() + "\nreceived correctly " );
}