Esempio n. 1
0
        void setup(){
            ofSetVerticalSync(false);

            w=ofGetScreenWidth();
            h=ofGetScreenHeight();

            ofDisableArbTex();
            img.load("1.jpg");
            player.load("1.mp4");
            player.play();
            player.setLoopState(OF_LOOP_NORMAL);
            gray = img;
            gray.setImageType(OF_IMAGE_GRAYSCALE);
            wc.load("wcolor.vert","wcolor.frag");

            ofFbo::Settings s;
            s.depthStencilAsTexture=true;
            s.useDepth=true;
            s.width=w;
            s.height=h;
            fboDepth.allocate(s);
            fbo.allocate(w,h);
            fbo.begin();
            ofClear(0,0,100,255);
            fbo.end();

            gui.setup();
            gui.add(stepGradient.set("step gradient",    .0015, -1., 1.));
            gui.add(advectStep.set("step advect",        .0015, -.1, .1));
            gui.add(flipHeightMap.set("flip height map",  0.7,   0.,  2.));
            gui.add(time.set("time",  0.,   0.,  1.));
            gui.add(advectMatrix.set("advect matrix",  ofVec4f(0.1),   ofVec4f(-1.),  ofVec4f(1.)));
            gui.add(switchVideo.set("switch video", false));
        }
Esempio n. 2
0
//--------------------------------------------------------------
void ofApp::setup() {
    ofSetFrameRate(60);
    BPStar::starImg.loadImage("particle32.png");
    ofSetWindowPosition(2000, 0);
    ofSetFullscreen(true);
    sky.setupFromXml("mySettings.xml");

    BPConstellation c;
    c.loadFromXml();
    constellations.push_back(c);
    for (auto it = c.getStars()->begin(); it != c.getStars()->end(); it++) {
        for (auto it2 = sky.getStars()->begin(); it2 != sky.getStars()->end(); it2++) {
            if (it->getId() == it2->getId()) {
                it2->isConstellation = true;
            }
        }
    }

    mode = Edge;
    fbo.allocate(ofGetWidth(), ofGetHeight());

    s.setup();
    s.stars = sky.getStars();

    int w = ofGetWidth();
    int h = ofGetHeight();
    int x = 0;
    int y = 0;
    warper.setSourceRect(ofRectangle(0, 0, w, h));              // this is the source rectangle which is the size of the image and located at ( 0, 0 )
    warper.setTopLeftCornerPosition(ofPoint(x, y));             // this is position of the quad warp corners, centering the image on the screen.
    warper.setTopRightCornerPosition(ofPoint(x + w, y));        // this is position of the quad warp corners, centering the image on the screen.
    warper.setBottomLeftCornerPosition(ofPoint(x, y + h));      // this is position of the quad warp corners, centering the image on the screen.
    warper.setBottomRightCornerPosition(ofPoint(x + w, y + h)); // this is position of the quad warp corners, centering the image on the screen.
    warper.setup();
}
Esempio n. 3
0
	void setup(){
		w=ofGetScreenWidth();
		h=ofGetScreenHeight();
		touch.init("/dev/input/event0",w,h);
		ofLog()<<touch.getName();
		fbo.allocate(w,h);
	}
Esempio n. 4
0
    void setup() {
        ofSetDataPathRoot("../../../../../SharedData/");
        ofSetVerticalSync(true);
//        ofSetLogLevel(OF_LOG_VERBOSE);
        
#ifdef USE_VIDEO
        video.loadMovie("videos/melica.mp4");
        video.play();
#else
        video.setup();
        #ifdef USE_EDSDK
            video.setDeviceType(EDSDK_MKII);
        #endif
#endif
        
        ofFbo::Settings settings;
        settings.width = video.getWidth();
        settings.height = video.getHeight();
        settings.useDepth = false;
        buffer.allocate(settings);
        ofSetBackgroundAuto(false);
        contours.getTracker().setPersistence(100);
        contours.getTracker().setMaximumDistance(100);
        setupGui();
        
        osc.setup("klaus.local", 7400);
    }
//--------------------------------------------------------------
void testApp::setup(){
	light.setDirectional();
	ofEnableArbTex();
	fbo.allocate(ofGetWidth()*2, ofGetHeight()*2);
	fxaa.load("v002.FXAA.vert","v002.FXAA.frag");
	ofSetFrameRate(30);
}
Esempio n. 6
0
 void setupedFbo()
 {
     if (!mFbo.isAllocated()) {
         mFbo.allocate(getWidth(), getHeight(), GL_RGBA);
         mGlitch.setup(&mFbo);
         mGlitch.setFx(OFXPOSTGLITCH_TWIST, true);
     }
 }
Esempio n. 7
0
void Buffer::init(ofFbo &b, const ofColor &bg) {
    b.allocate();
    b.begin();
    ofFill();
    ofSetColor(bg);
    ofRect(0, 0, b.getWidth(), b.getHeight());
    b.end();
}
Esempio n. 8
0
//--------------------------------------------------------------
void testApp::setup()
{
//	ofSetFrameRate(60);
//	ofSetVerticalSync(true);
	
	ofBackground(0);
	
	fbo.allocate(1920, 1080, GL_RGB);
}
Esempio n. 9
0
//--------------------------------------------------------------
void testApp::setup(){
    font.loadFont("Arial.ttf", 300, true, true, true);
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    fbo.allocate(ofGetWidth(), ofGetHeight());
    fbo.begin();ofClear(0, 0, 0);fbo.end();
    cnt = 0;
    maxDraw = 5;
    randomVal = 0;
}
Esempio n. 10
0
    void setup()
	{
        ofSetLogLevel(OF_LOG_VERBOSE);
		
        testImage.loadImage("of.png");
        fbo.allocate(ofGetWidth(), ofGetHeight());
		fbo.begin();
			ofClear(0, 0, 0, 0);
		fbo.end();
    }
Esempio n. 11
0
 void setup() {
     ofBackground(255);
     trail.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA, 4);
     trail.begin();
     ofClear(255, 0);
     trail.end();
     derivatives.resize(3); // vel, acc, jer
     magnitudes.resize(3, 0);
     limits.resize(3, 0);
     limits[0] = pow(100, 1./1.);
     limits[1] = pow(1, 1./2.);
     limits[2] = pow(10, 1./3.);
 }
	void setup() {
		ofSetFrameRate(60);
		ofSetVerticalSync(false);
		ledRing.setup();
		fbo.allocate(512, 512);
		fbo.begin();
		ofClear(0);
		fbo.end();
		ofSetCircleResolution(64);
		ofSetLineWidth(2);
		ofLog() << "MIDI Ports: " << ofToString(midi.getPortList());
		midi.openPort();
		Pulse::midiWrapper = &midiWrapper;
		pulses.push_back(Pulse(0, 0));
	}
Esempio n. 13
0
		void setup() {
            ofSetFrameRate(60);
            ofSetVerticalSync(true);

            dw=ofGetScreenWidth();
			dh=ofGetScreenHeight();
			ofDisableArbTex();
            fbo.allocate(dw,dh);
            shader.load("shaders/fluid.vert","shaders/fluid.frag");

			camera.setFarClip(100000);
			camera.setNearClip(.1);
            if ( !allocate_data () ){
                    cout<<"error allocate!"<<endl;
                    exit();
			}
            clear_data ();

			gui.setup();
            gui.setPosition(ofPoint(10,10));

			gui.add(size_cube.setup("size box", 100.0f,0.0f,255.0f));
            gui.add(dvel.setup("draw velocity", true));
            gui.add(dden.setup("draw density",  false));

			gui.add(TaddSource.setup("add source",false));
			gui.add(Bclear.setup("clear source",false));

			gui.add(addX.setup("add x",false));
			gui.add(addY.setup("add y",false));
			gui.add(addZ.setup("add z",false));
			gui.add(dt.setup("time delta", 0.9f,0.0f,25.0f));
			gui.add(diff.setup("diffuse",  0.0f,0.0f,25.0f));
			gui.add(visc.setup("viscosity", 0.0f,0.0f,25.0f));
			gui.add(force.setup("add force",30.0f,0.0f,60.0f));
			gui.add(source.setup("density", 200.0f,0.0f,600.0f));
			gui.add(source_alpha.setup("alpha",0.05,0.0,1.0));
			gui.add(drawAbstacle.setup("draw abstacle",false));
			gui.add(drawAxis.setup("draw Axis",true));

			gui.add(sourcePosX.setup("source posX", 0,-10,SIZE));
			gui.add(sourcePosY.setup("source posY", 0,-10,SIZE));
			gui.add(sourcePosZ.setup("source posZ", 0,-10,SIZE));
		}
Esempio n. 14
0
 void setupSpeakers() {
     ofVec3f speakers[n_speakers];
     // maybe need to swap dimensions here?
     // possibly change scale too
     float eps = 0.001; // needed to avoid "== 0" check in shader
     speakers[0] = ofVec3f(0,0,0)+eps; // front left
     speakers[1] = ofVec3f(0,1,0)+eps; // front right
     speakers[2] = ofVec3f(1,1,0)+eps; // rear right
     speakers[3] = ofVec3f(1,0,0)+eps; // rear left
     
     float speakerAreaSize = 0.02;
     speakerXyzMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
     speakerConfidenceMap.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
     
     float* xyzPixels = speakerXyzMap.getPixels().getData();
     float* confidencePixels = speakerConfidenceMap.getPixels().getData();
     for(int i = 0; i < n_speakers; i++){
         for(int j = 0; j < n_samples; j++){
             // sample a spiral
             float angle = j * TWO_PI / 20; // 20 samples per full rotation
             float radius = ((float) j / n_samples) * speakerAreaSize; // 0 to speakerAreaSize
             // might need to swap axes here too
             xyzPixels[0] = speakers[i].x + sin(angle) * radius;
             xyzPixels[1] = speakers[i].y + cos(angle) * radius;
             xyzPixels[2] = speakers[i].z;
             xyzPixels[3] = 1;
             xyzPixels += 4;
             
             confidencePixels[0] = 1;
             confidencePixels[1] = 1;
             confidencePixels[2] = 1;
             confidencePixels[3] = 1;
             confidencePixels += 4;
         }
     }
     speakerXyzMap.update();
     speakerConfidenceMap.update();
     
     speakerFbo.allocate(n_samples, n_speakers);
     speakerPixels.allocate(n_samples, n_speakers, OF_IMAGE_COLOR_ALPHA);
 }
Esempio n. 15
0
//--------------------------------------------------------------
void ofApp::setup(){


	ofSetFrameRate(60);

	//Определяем графический буфер
	int w = ofGetWidth();
	int h = ofGetHeight();
	fbo.allocate(w,h,GL_RGB32F_ARB);

	//Заполняем буфер белым цветом
	fbo.begin();
	ofBackground(255,255,255);
	fbo.end();

	//Настраиваем параметры
	param.setup();
	history = 0.9;
	time0 = ofGetElapsedTimef();

	bornRate = 2500;
	bornCount = 0;
}
Esempio n. 16
0
void ofxLayerMask::initFbo(ofFbo &fbo) {
    fbo.allocate(width, height, GL_RGBA, 1);
    fbo.begin();
    ofBackground(ofColor(ofColor::black, 0));
    fbo.end();
}
Esempio n. 17
0
void ofxLayerMask::initMaskFbo(ofFbo &fbo) {
    fbo.allocate(width, height, GL_RGB, 1);
    fbo.begin();
    ofBackground(ofColor::white);
    fbo.end();
}
Esempio n. 18
0
 void setup(){
     ofSetLogLevel(OF_LOG_VERBOSE);
     testImage.loadImage("of.png");
     fbo.allocate(ofGetWidth(), ofGetHeight());
 }
Esempio n. 19
0
//--------------------------------------------------------------
void testApp::update(){
    
    // Get infrarred image from kinect and transform to OpenCV image
    recordContext.update();
    recordImage.update();
    
    grayImage.setFromPixels(recordImage.ir_pixels, W, H);
    
    
    // Save background
    if(bBackground){
        saveBackground();
        bBackground = false;
    }
    
    
    // ROI mask selection
    drawRoiMask(grayImage);

 
    roi.x = MIN(roiMask[0].x, roiMask[3].x);
    roi.y = MIN(roiMask[0].y, roiMask[1].y);
    roiW = MAX(roiMask[1].x, roiMask[2].x) - roi.x;
    roiH = MAX(roiMask[3].y, roiMask[2].y) - roi.y;
    
    grayImage.setROI(roi.x, roi.y, roiW, roiH);
    backImg.setROI(roi.x, roi.y, roiW, roiH);
    grayAcc.setROI(roi.x, roi.y, roiW, roiH);
    
    
    // Opencv preprocessing
    
    t0 = ofGetElapsedTimeMillis();
    
    if(bProcess){
       // grayImage.absDiff(grayImage, backImg);
        grayImage.brightnessContrast(brightness, contrast);
        cvAdaptiveThreshold(grayImage.getCvImage(), grayImage.getCvImage(), 255);
        grayImage.blur();
        grayImage.erode();
        grayImage.dilate();
        
        grayImage.addWeighted(grayAcc, 0.1);
        grayAcc = grayImage;
        grayImage.canny(50, 150);
        
        Mat dst = grayImage.getCvImage();
        findContours(dst, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
        for (size_t i = 0; i < contours.size(); i++){
            CvPoint* pts = new CvPoint[contours[i].size()];
            for(int j = 0; j < contours[i].size(); j ++){
                pts[j].x = contours[i][j].x;
                pts[j].y = contours[i][j].y;
            }
            
            int nPts = contours[i].size();
            cvPolyLine( grayImage.getCvImage(), &pts, &nPts, 1, true, CV_RGB(255, 255, 255));
            delete[] pts;
        }
        grayImage.dilate();
        grayImage.erode();
    }
    t1 = ofGetElapsedTimeMillis() - t0;
     
    //---
    
    
	// Send image to MadMapper
    t0 = ofGetElapsedTimeMillis();
    tex.allocate(grayImage.getWidth(), grayImage.getHeight(), GL_LUMINANCE);
    tex.loadData(grayImage.getPixels(), grayImage.getWidth(), grayImage.getHeight(), GL_LUMINANCE);
    individualTextureSyphonServer.publishTexture(&tex);
    //---
    
	// Get image from MadMapper
    if(!fbo.isAllocated() || !(mClient.getWidth() == fbo.getWidth() && mClient.getHeight() == fbo.getHeight()))
        fbo.allocate(mClient.getWidth(), mClient.getHeight());
    
    fbo.begin();
    mClient.draw(0, 0);
    fbo.end();
    
    fbo.readToPixels(pix);
    
    t2 = ofGetElapsedTimeMillis() - t0;
    //---
    
    
	// Update my system
    
    L.update(mouseX, mouseY);
}