Exemplo n.º 1
0
//--------------------------------------------------------------
void testApp::setup(){
    CGDisplayShowCursor(kCGDirectMainDisplay);
//  CGDisplayHideCursor(kCGDirectMainDisplay);
    swapGloble = 0;
    dir.listDir("videos");
	dir.sort();
    ofSetVerticalSync(true);
    hozpertion = 1;
    load = 0;
    ofEnableSmoothing();
    maxNumber = (int)dir.size();
    mapping =    new ofxQuad*[20];
    width  = 10;
    height = 10;
    for(int i = 0; i < maxNumber; i++){
        mapping[i] = new ofxQuad();
        vid.push_back(ofVideoPlayer());
        vid[i].loadMovie(dir.getPath(i));
       // vid[i].setPixelFormat(ofPixelFormat _rg)
        mapping[i]->setup(width+10,10, 200, 200, ofGetWidth(), ofGetHeight(),i);
        mapping[0]->activate();
        width = vid[i].getWidth() * (1 + i);
        height = 10;
        vid[i].play();
        mapping[i]->debugSet(0);
    }
    h = ofGetHeight();
    w = ofGetWidth();
    loadMe();
}
//--------------------------------------------------------------
void ofApp::setup(){
    //General setup of look of window.
    ofBackground(0);
    
    //   serial.setup("/dev/cu.usbmodem1411", 9600);
    
    
    for(int i=0; i<videoNum; i++){
        
        cityVid.push_back(ofVideoPlayer());
        greenVid.push_back(ofVideoPlayer());
        
        cityColor.push_back(ofColor());
        greenColor.push_back(ofColor());
        
        opacity.push_back(float());
        
    }
    
    //----------------video part----------------------------
    
    
    for(int i=0; i<videoNum; i++){
        string filenameCity = "test" + to_string(i) + ".mp4";
        //        cout<<"city file name: "<<filenameCity<<std::endl;
        cityVid[i].load(filenameCity);
        
        string filenameGreen = "_test" + to_string(i) + ".mp4";
        //        cout<<"green file name: "<<filenameGreen<<std::endl;
        greenVid[i].load(filenameGreen);
        
    }
    
    
    
    
    //----------------Set Syphon----------------------------
    mainOutputSyphonServer.setName("Screen Output");
    individualTextureSyphonServer.setName("Texture Output");
    mClient.setup();
    mClient.set("","Simple Server");
}
Exemplo n.º 3
0
void testApp::loadMe(){
    
    for(int i = 0; i < maxNumber; i++){
        vid[i].close();
        delete  mapping[i];
        
    }
    vid.empty();
    vid.clear();

    maxNumber = 0;
    width = 10;
    height = 10;
    
         
    
    // }
    
    ofxXmlSettings XML;
	if( !XML.loadFile("glob.xml") ){
		ofLog(OF_LOG_ERROR, "no xml");
	}
	
	XML.pushTag("GLOB");
//    int t = XML.addTag("GLOBY");
//    XML.pushTag("GLOBY");
    maxNumber = XML.getValue("GLOB:maxNumber", double(1.0));
    
    
    cout << maxNumber << endl;
    for(int x = 0;x < maxNumber;x++){
    
        mapping[x] = new ofxQuad();
        vid.push_back(ofVideoPlayer());
        vid[x].loadMovie( ofToString(XML.getValue("GLOB:vidPath"+ofToString(x), "videos/hands.mov")));
        mapping[x]->setup(width+10,10, 200, 200, w, h,x);
        mapping[x]->deactivate();
        mapping[0]->activate();
        width = vid[x].getWidth() * (1 + x);
        height = 10;
        vid[x].play();
        mapping[x]->debugSet(0);

    }
    
    XML.popTag();

    for (int i = 0; i < maxNumber; i++){
        mapping[i]->load(ofToString(i)+".xml");
    }

}
Exemplo n.º 4
0
void ofxSlides::loadVideos(string path) {
	ofDirectory dir;
	dir.listDir(path);
	dir.sort();
	
	if( dir.size() ){
		videos.assign(dir.size(), ofVideoPlayer());
		doUpdateVideo.assign(dir.size(), 0);
	}
	
	for( int i = 0 ; i < (int)dir.size(); i++ ) {
		videos.at(i).loadMovie(dir.getPath(i));
	}
}
Exemplo n.º 5
0
//------------------------------------------------------------------------
bool tspsApp::initVideoFile(){    
    videoFile = peopleTracker.getVideoFile();
    vidPlayer = ofVideoPlayer();
    bool loaded = vidPlayer.loadMovie( videoFile );
    
    if ( loaded ){
        vidPlayer.play();
        if ( camWidth != vidPlayer.width || camHeight != vidPlayer.height ){            
            camWidth    = vidPlayer.width;
            camHeight   = vidPlayer.height;
            peopleTracker.resize( camWidth, camHeight );
        }
        
        // reallocate
        colorImg.resize(camWidth, camHeight);
        grayImg.resize(camWidth, camHeight);
        
        cameraState = CAMERA_VIDEOFILE;        
    }
    
    return loaded;
}
Exemplo n.º 6
0
Arquivo: ofApp.cpp Projeto: BBDO/LUMI
//--------------------------------------------------------------
void ofApp::setup() {
    
    ofBackground(0, 0, 0);                      // default background to black / LEDs off
    ofDisableAntiAliasing();                    // we need our graphics sharp for the LEDs
    
    // SYSTEM SETTINGS
    //--------------------------------------
    stripWidth = 64;                            // pixel width of strip
    stripHeight = 2;                            // pixel height of strip
    stripsPerPort = 8;                          // total number of strips per port
    numPorts = 4;                               // total number of teensy ports?
    brightness = 0;                             // LED brightness
    fboRotate = 0;                              // rotate display
    fboFlip = false;                            // invert display
    waveSpeed = 0.05f;                          // animation speed
    drawModes = 0;                              // default is demo mode
    demoModes = 0;                              // default is draw white
    counterShape = 0;                           // init at zero
    hue = 0;                                    // init color at red
    
    // setup our teensys
    teensy.setup(stripWidth, stripHeight, stripsPerPort, numPorts);
    
    // configure out teensy boards
    // (portName, xOffset, yOffset, width%, height%, direction)
    teensy.serialConfigure("tty.usbmodem14761", 0, 50, 100, 25, 0);
    teensy.serialConfigure("tty.usbmodem14791", 0, 25, 100, 25, 0);
    teensy.serialConfigure("tty.usbmodem29", 0, 0, 100, 25, 0);
    teensy.serialConfigure("tty.usbmodem14751", 0, 75, 100, 25, 0);
    
    // allocate our pixels, fbo, and texture
    teensy.pixels1.allocate(stripWidth, stripHeight*stripsPerPort*numPorts, OF_PIXELS_RGB);
    fbo.allocate(stripWidth, stripHeight*stripsPerPort*numPorts, GL_RGB);
    tex.allocate(stripWidth, stripHeight*stripsPerPort*numPorts, GL_RGB);
    
    // osc -- listen on the given port
    //receiver.setup(PORT);
    
    // TEST PATTERN
    //--------------------------------------
    font.loadFont("fonts/samst.ttf", 10);
    
    // GIFS - dynamic loading
    //--------------------------------------
    dirGif.listDir("gifs/");
    gif.setup(dirGif.size());
    currentGif = 0;
    
    // VIDEOS - dynamic loading
    //--------------------------------------
    dirVid.listDir("videos/");
    dirVid.sort();
    //allocate the vector to have as many ofVidePlayer as files
	if( dirVid.size() ){
		vid.assign(dirVid.size(), ofVideoPlayer());
	}
    videoOn = false;
    currentVideo = 0;
    
    // IMAGES - dynamic loading
    //--------------------------------------
    dirImg.listDir("images/");
    dirImg.sort();
    //allocate the vector to have as many ofImages as files
	if( dirImg.size() ){
		img.assign(dirImg.size(), ofImage());
	}
    currentImage = 0;
}
Exemplo n.º 7
0
	//---------
	void Register::loadAssets(string addon) {
		ofLogNotice("ofxAssets") << "//--------------------";
		ofLogNotice("ofxAssets") << "//ofxAssets::init";
		ofLogNotice("ofxAssets") << "//--------------------";
		ofLogNotice("ofxAssets") << "//";
		
		string filename, name, extension, withoutExtension, folder;
		ofDirectory files;
		
		string dataPath = "assets";
		if (addon.size() > 0) {
			dataPath += "/" + addon;
		}
		
		if (!ofDirectory::doesDirectoryExist(dataPath))
		{
			ofLogNotice("ofxAssets") << "Assets data path cannot be found. Be sure to have a ./assets subfolder inside your app's data/ folder if you want to use ofxAssets";
			return;
		}
		
		////
		//images
		////
		//
		folder = ofToDataPath(dataPath + "/images/", true);
		if (ofDirectory::doesDirectoryExist(folder)) {
			files.listDir(folder);
			for (int i=0; i<files.size(); i++) {
				filename = files.getPath(i);
				extension = ofFilePath::getFileExt(filename);
				withoutExtension = filename.substr(0, filename.length() - extension.length() - 1);
				name = ofFilePath::getBaseName(filename);
				transformName(name, addon);
				
				if (!(extension == "png" || extension == "jpeg" || extension == "jpg"))
					continue;
				
				if (this->images.count(name) > 0)
					continue;
				
				this->images.insert(pair<string, ofImage>(name, ofImage()));
				
				this->images[name].loadImage(filename);
				
				ofLogNotice("ofxAssets") << "Loaded image asset '" << name << "'" << endl;
			}
		}
		//
		////
		
		
		////
		//shaders
		////
		//
		folder = ofToDataPath(dataPath + "/shaders/", true);
		if (ofDirectory::doesDirectoryExist(folder)) {
			files.listDir(folder);
			bool hasFrag, hasVert;
			for (int i=0; i<files.size(); i++) {
				filename = files.getPath(i);
				extension = ofFilePath::getFileExt(filename);
				withoutExtension = filename.substr(0, filename.length() - extension.length() - 1);
				name = ofFilePath::getBaseName(filename);
				transformName(name, addon);
				
				if (!(extension == "vert" || extension == "frag" || extension == "geom"))
					continue;
				
				if (this->shaders.count(name) > 0)
					continue;
				
				this->shaders.insert(pair<string, ofShader>(name, ofShader()));
				
				if (ofFile::doesFileExist(withoutExtension + ".frag"))
					this->shaders[name].setupShaderFromFile(GL_FRAGMENT_SHADER, withoutExtension + ".frag");
				if (ofFile::doesFileExist(withoutExtension + ".vert"))
					this->shaders[name].setupShaderFromFile(GL_VERTEX_SHADER, withoutExtension + ".vert");
				if (ofFile::doesFileExist(withoutExtension + ".geom"))
					this->shaders[name].setupShaderFromFile(GL_GEOMETRY_SHADER, withoutExtension + ".geom");
				this->shaders[name].linkProgram();
				
				ofLogNotice("ofxAssets") << "Loaded shader asset '" << name << "'" << endl;
			}
		}
		//
		////
		
		
		////
		//fonts
		////
		//
		folder = ofToDataPath(dataPath + "/fonts/", true);
		if (ofDirectory::doesDirectoryExist(folder)) {
			files.listDir(folder);
			for (int i=0; i<files.size(); i++) {
				filename = files.getPath(i);
				extension = ofFilePath::getFileExt(filename);
				withoutExtension = filename.substr(0, filename.length() - extension.length() - 1);
				name = ofFilePath::getBaseName(filename);
				transformName(name, addon);
				
				if (!(extension == "ttf"))
					continue;
				
				if (this->fontFilenames.count(name) > 0)
					continue;
				
				this->fontFilenames.insert(pair<string, string>(name, filename));
				
				ofLogNotice("ofxAssets") << "Found font asset '" << name << "'" << endl;
			}
		}
		//
		////
		
		////
		//videos
		////
		//
		folder = ofToDataPath(dataPath + "/videos/", true);
		if (ofDirectory::doesDirectoryExist(folder)) {
			files.listDir(folder);
			for (int i=0; i<files.size(); i++) {
				filename = files.getPath(i);
				extension = ofFilePath::getFileExt(filename);
				withoutExtension = filename.substr(0, filename.length() - extension.length() - 1);
				name = ofFilePath::getBaseName(filename);
				transformName(name, addon);
				
				if (!(extension == "mov"))
					continue;
				
				if (this->videos.count(name) > 0)
					continue;
				
				this->videos.insert(pair<string, ofVideoPlayer>(name, ofVideoPlayer()));
				
				this->videos[name].loadMovie(filename);
				this->videos[name].play();
				
				ofLogNotice("ofxAssets") << "Loaded video asset '" << name << "'" << endl;
			}
		}
		//
		////
		
		
		ofLogNotice("ofxAssets") << "//";
		ofLogNotice("ofxAssets") << "//--------------------";
		
		ofNotifyEvent(evtLoad, *this, this);
	}
Exemplo n.º 8
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){

int swap = ofMap(key, 48, 57, 0, 9);

    if((swap <= 9)&&(swap >= 0)){
        if(swap < maxNumber){
              for(int i = 0; i < maxNumber; i++){
                  mapping[i]->deactivate();
              }
            mapping[swap]->activate();
            swapGloble = swap;
        }
    }
    
    switch (key) {
        case 's':
            save();

            break;
        case 'l':
            loadMe();

            break;
        case 'f':
            
            CGDisplayHideCursor(kCGDirectMainDisplay);

            ofToggleFullscreen();
            break;
        case ' ':
            if(debug == 0){

                debug = 1;
            }
            else{
                debug = 0;
            }
            
            for(int i = 0; i < maxNumber; i++){
                mapping[i]->debugSet(debug);
            }
            break;
            
        case 13:
            maxNumber ++;
            mapping[maxNumber-1] = new ofxQuad();
            vid.push_back(ofVideoPlayer());
            vid[maxNumber-1].loadMovie(dir.getPath(0));

            width =  vid[maxNumber-1].getWidth() * (maxNumber-hozpertion);
            if((width + vid[maxNumber-1].getWidth()) > ofGetWidth() ){
                hozpertion = maxNumber + 1;
                height += vid[maxNumber-1].getHeight();
                width = 10;
            }
          
            mapping[maxNumber-1]->setup(width+10,10+height, 200, 200, ofGetWidth(), ofGetHeight(),maxNumber-1);
            mapping[maxNumber-1]->deactivate();
            vid[maxNumber-1].play();
            mapping[maxNumber-1]->debugSet(0);
            
            break;
            
        case 357:
            
            if( load >=(int)dir.size()-1){
                load = 0;
            }
            else{
                load += 1;
            }
            vid[swapGloble].loadMovie(dir.getPath(load));
            
            break;
    
    
        case 359:
            
            if( load <=0){

                load = (int)dir.size()-1;
            }
            else{
                load -= 1;
                
            }

            vid[swapGloble].loadMovie(dir.getPath(load));
            break;
            
        default:
            break;
    }
  //      cout << " me first " << endl;
}