Exemple #1
0
//--------------------------------------------------------------
void ofApp::update(){
    while(receiver.hasWaitingMessages()){
        // get the next message
		ofxOscMessage m;
		receiver.getNextMessage(&m);

        if(m.getAddress() == "/take/picture"){
            std::string type = m.getArgAsString(0);
            std::string id = m.getArgAsString(1);


            if(type == "matrix"){
                cout << "matrix requested" << endl;
                takeMatrixPhoto("matrix-" + ofGetTimestampString("%m%d%Y-%H%M%s") + "_" + id + ".gif", id);
            }else if(type == "traditional"){
                //take a picture every time we get this message
                //while we have less than 4 images, keep waiting
                //once we have all the images, composite it and send it
                //using sendMessage
                cout << "traditional requested" << endl;
                std::string fileName = takeTraditionalPhoto("traditional-" + ofGetTimestampString("%m%d%Y-%H%M%s") + ".jpg", id);
                sendPhoto(fileName, id);
            }

		}else{
            std::cout << m.getAddress();
        }
    }
}
//--------------------------------------------------------------
void ofxVideoDataWriterThread::threadedFunction(){
    if(fd == -1){
        ofLogVerbose("ofxVideoDataWriterThread") << "opening pipe: " <<  filePath;
        fd = ::open(filePath.c_str(), O_WRONLY);
        ofLogWarning("ofxVideoDataWriterThread") << "got file descriptor " << fd;
    }

    while(isThreadRunning())
    {
        ofPixels * frame = NULL;
        if(queue->Consume(frame) && frame){
            bIsWriting = true;
            int b_offset = 0;
            int b_remaining = frame->getWidth()*frame->getHeight()*frame->getBytesPerPixel();

            while(b_remaining > 0 && isThreadRunning())
            {
                errno = 0;

                int b_written = ::write(fd, ((char *)frame->getData())+b_offset, b_remaining);

                if(b_written > 0){
                    b_remaining -= b_written;
                    b_offset += b_written;
                    if (b_remaining != 0) {
                        ofLogWarning("ofxVideoDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - b_remaining is not 0 -> " << b_written << " - " << b_remaining << " - " << b_offset << ".";
                        // break;
                    }
                }
                else if (b_written < 0) {
                    ofLogError("ofxVideoDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - write to PIPE failed with error -> " << errno << " - " << strerror(errno) << ".";
                    bNotifyError = true;
                    break;
                }
                else {
                    if(bClose){
                        ofLogVerbose("ofxVideoDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - Nothing was written and bClose is TRUE.";
                        break; // quit writing so we can close the file
                    }
                    ofLogWarning("ofxVideoDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - Nothing was written. Is this normal?";
                }

                if (!isThreadRunning()) {
                    ofLogWarning("ofxVideoDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - The thread is not running anymore let's get out of here!";
                }
            }
            bIsWriting = false;
            frame->clear();
            delete frame;
        }
        else{
            condition.wait(conditionMutex);
        }
    }

    ofLogVerbose("ofxVideoDataWriterThread") << "closing pipe: " <<  filePath;
    ::close(fd);
}
void ofxOMXPlayer::saveImage(string imagePath)//default imagePath=""
{
	if(imagePath == "")
	{
		imagePath = ofGetTimestampString()+".png";
	}
	updatePixels();
	ofSaveImage(GlobalEGLContainer::getInstance().pixels, ofGetTimestampString()+".png");
	
}
Exemple #4
0
void ofApp::createRandomGroups()
{
    ofAddListener(api.CREATE_GROUP, this, &ofApp::onGroupCreated);
    
    
    for (size_t i=0; i<numGroupsToCreate; i++)
    {
        string title = "title " + ofGetTimestampString();
        string text = "text " + ofGetTimestampString();
        api.createGroup(title, text);
    }
    
}
//--------------------------------------------------------------
void ofxAudioDataWriterThread::threadedFunction(){
    if(fd == -1){
        ofLogVerbose("ofxAudioDataWriterThread") << "opening pipe: " <<  filePath;
        fd = ::open(filePath.c_str(), O_WRONLY);
        ofLogWarning("ofxVideoDataWriterThread") << "got file descriptor " << fd;
    }

    while(isThreadRunning())
    {
        audioFrameShort * frame = NULL;
        if(queue->Consume(frame) && frame){
            bIsWriting = true;
            int b_offset = 0;
            int b_remaining = frame->size*sizeof(short);
            while(b_remaining > 0 && isThreadRunning()){
                int b_written = ::write(fd, ((char *)frame->data)+b_offset, b_remaining);

                if(b_written > 0){
                    b_remaining -= b_written;
                    b_offset += b_written;
                }
                else if (b_written < 0) {
                    ofLogError("ofxAudioDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - write to PIPE failed with error -> " << errno << " - " << strerror(errno) << ".";
                    bNotifyError = true;
                    break;
                }
                else {
                    if(bClose){
                        // quit writing so we can close the file
                        break;
                    }
                }

                if (!isThreadRunning()) {
                    ofLogWarning("ofxAudioDataWriterThread") << ofGetTimestampString("%H:%M:%S:%i") << " - The thread is not running anymore let's get out of here!";
                }
            }
            bIsWriting = false;
            delete [] frame->data;
            delete frame;
        }
        else{
            condition.wait(conditionMutex);
        }
    }

    ofLogVerbose("ofxAudioDataWriterThread") << "closing pipe: " <<  filePath;
    ::close(fd);
}
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground(0);
    
    
    
    if (bTrails){
        
        fbo.begin();
        for (int i = 0; i < particles.size(); i++){
            ofSetColor(0);
            particles[i]->draw();
        }
        fbo.end();
        
        ofSetColor(255);
        fbo.draw(0, 0);
        
        if (bPrintScreen){
            ofSaveScreen("screenshot-"+ofGetTimestampString()+".png");
            bPrintScreen = false;
        }
    } 
    
    if (bPrintScreen){
        ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false);
    }
    
    for (int i = 0; i < particles.size(); i++){
        ofSetColor(0);
        particles[i]->draw();
    }
    
    if (bPrintScreen){
        ofEndSaveScreenAsPDF();
        bPrintScreen = false;
    }
    
    
    if (bDrawField){
        ofSetColor(255,100);
        normals.draw(0,0,ofGetWidth(),ofGetHeight());
        ofDisableSmoothing();
        ofSetColor(100);
        VF.draw();
        ofEnableSmoothing();
    }
    
}
void ofApp::setup(){
    ofSetWindowShape(500, 500);
    gif.setupPaused(ofGetTimestampString("%Y-%m-%d"), 30, 59);

    ofEnableSmoothing();
    shapeSystem.setup();

    image.setup("glass.png", 0.5);

    shapeSize = 100;
    thickness = 60;
    halfShapeSize = shapeSize * 0.5;

    for(int i = 0; i < gif.width; i += shapeSize) {
        for(int j = 0; j < gif.height; j += shapeSize) {
            shape.setupHollowArc(30, thickness, shapeSize, 180);
            shape.setColor(ofColor::white);
            shape.setBlur(25);
            shape.setPosition(ofVec3f(i + halfShapeSize, j + halfShapeSize, 0));
            shape.rotateZ(ofRandom(360));
            shapes.push_back(shape);
        }
    }
    
    for(int i = 0; i < shapes.size(); i++) {
        shapeSystem.add(shapes.at(i));
    }
}
//--------------------------------------------------------------
void visionScene1::keyPressed(int key){
    if (key == '1') myGlitch.setFx(OFXPOSTGLITCH_CONVERGENCE	, true);
    if (key == '2') myGlitch.setFx(OFXPOSTGLITCH_GLOW			, true);
    if (key == '3') myGlitch.setFx(OFXPOSTGLITCH_SHAKER			, true);
    if (key == '4') myGlitch.setFx(OFXPOSTGLITCH_CUTSLIDER		, true);
    if (key == '5') myGlitch.setFx(OFXPOSTGLITCH_TWIST			, true);
    if (key == '6') myGlitch.setFx(OFXPOSTGLITCH_OUTLINE		, true);
    if (key == '7') myGlitch.setFx(OFXPOSTGLITCH_NOISE			, true);
    if (key == '8') myGlitch.setFx(OFXPOSTGLITCH_SLITSCAN		, true);
    if (key == '9') myGlitch.setFx(OFXPOSTGLITCH_SWELL			, true);
    if (key == '0') myGlitch.setFx(OFXPOSTGLITCH_INVERT			, true);
    
    if (key == 'q') myGlitch.setFx(OFXPOSTGLITCH_CR_HIGHCONTRAST, true);
    if (key == 'w') myGlitch.setFx(OFXPOSTGLITCH_CR_BLUERAISE	, true);
    if (key == 'e') myGlitch.setFx(OFXPOSTGLITCH_CR_REDRAISE	, true);
    if (key == 'r') myGlitch.setFx(OFXPOSTGLITCH_CR_GREENRAISE	, true);
    if (key == 't') myGlitch.setFx(OFXPOSTGLITCH_CR_BLUEINVERT	, true);
    if (key == 'y') myGlitch.setFx(OFXPOSTGLITCH_CR_REDINVERT	, true);
    if (key == 'u') myGlitch.setFx(OFXPOSTGLITCH_CR_GREENINVERT	, true);
    
    
    if (key == 's') {
        
        ofSaveScreen("savedScreenshot_"+ofGetTimestampString()+".png");
    }
}
//--------------------------------------------------------------
void testApp::draw(){
	
//	float counter = 1 + ofGetElapsedTimeMillis() * 0.0001;
//	ofScale(counter, counter, counter);

	if (savePDF == true){
        //ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false);
		ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false, true);
    }
	
	cam.begin();
	
	//ofRotateX(-20);
	//ofRotateY(90);
	//ofRotateZ(ofRadToDeg(0.5));
	

	
	ofBackground(255);
	
	ofSetColor(0,130,130, 200);
	//VF.draw();
	
	for (int i = 0; i < particles.size(); i++){
		if (!particles[i].magic)
			particles[i].draw();
	}
	
	cam.end();
	
	if (savePDF){
		ofEndSaveScreenAsPDF();
        savePDF = false;
	}
}
Exemple #10
0
void form::exportModel() {
    mExporter.beginModel("blob sim");
    
    addMesh(mMesh);
    addMesh(mOuterMesh);
    
    // doing the edge by hand
    for (int i=1; i<mMasterEdgeParticles.size();i++) {
        ofPoint p0 = mBottomParticles[mMasterEdgeParticles[i-1]->array_ind]->getPosition();
        ofPoint p1 = mBottomParticles[mMasterEdgeParticles[i]->array_ind]->getPosition();
        ofPoint p2 = mParticles[mMasterEdgeParticles[i]->array_ind]->getPosition();
        ofPoint p3 = mParticles[mMasterEdgeParticles[i-1]->array_ind]->getPosition();
        
        mExporter.addTriangle(p0, p1, p2, ofPoint(0,0,0));
        mExporter.addTriangle(p0, p2, p3, ofPoint(0,0,0));
    }
    for (int i=1; i<mSlaveEdgeParticles.size();i++) {
        ofBeginShape();
        ofPoint p0 = mBottomParticles[mSlaveEdgeParticles[i-1]->array_ind]->getPosition();
        ofPoint p1 = mBottomParticles[mSlaveEdgeParticles[i]->array_ind]->getPosition();
        ofPoint p2 = mParticles[mSlaveEdgeParticles[i]->array_ind]->getPosition();
        ofPoint p3 = mParticles[mSlaveEdgeParticles[i-1]->array_ind]->getPosition();
        
        mExporter.addTriangle(p0, p1, p2, ofPoint(0,0,0));
        mExporter.addTriangle(p0, p2, p3, ofPoint(0,0,0));
    }

    
    mExporter.useASCIIFormat(false); //export as binary
    mExporter.saveModel(ofToDataPath("blob-to-print-"+ofGetTimestampString()+".stl"));
}
/* This handles the setup and GIF rendering, etc */
void ofApp::setup(){
    //Gif render values
    slowMode = false;
    width = 400, height = 400;
    duration = 0.2, colors = 256;
    saveOnFrame = -1;
    
    filename = ofGetTimestampString("%Y-%m-%d") + ".gif";
    framerate = slowMode ? 5 : 10;
    
    //Init
    ofSetFrameRate(framerate);
    ofSetWindowShape(width, height);
    gifEncoder.setup(width, height, duration, colors);
    renderingNow = false;
    renderMessage = "";
    
    fbo.allocate(width, height, GL_RGB);
    fbo.begin();
    ofClear(255, 255, 255, 0);
    fbo.end();
    
    //Begin patch
    setupAnim();
}
Exemple #12
0
//--------------------------------------------------------------
void ofApp::draw(){

    ofBackground(255);    
    
    if(isSavingPDF){
        ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false);
    }else{
        ofSetColor(0);
        ofDrawBitmapString("Press RETURN to save pdf file.", 10, ofGetHeight() - 10);
    }

    for (int i = 0; i < allTopics.size(); i++) {
        switch (chartType) {
            case 0:
                allTopics[i].draw(i, drawLabels, "bar");
                break;
                
            case 1:
                allTopics[i].draw(i, drawLabels, "area");
                break;
                
            default:
                allTopics[i].draw(i, drawLabels, "polar");
                break;
        }
    }
    
    if(isSavingPDF){
        ofEndSaveScreenAsPDF();
        isSavingPDF = false;
    }
}
Exemple #13
0
void testApp::recordPressed(bool & l){
	if(l && !record){
		recorder.setup(ofGetTimestampString()+".mp4",ofGetWidth(),ofGetHeight(),30);
	}else if(!l && record){
		recorder.encodeVideo();
	}
}
Exemple #14
0
//--------------------------------------------------------------
void testApp::draw(){
    
    
    ofPushMatrix();
    ofTranslate(235, 149);
    
    if (saveScreen){
        ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf");
    }
    

    for (int i = 0; i < triangles.size(); i++) {
        ofSetColor(colors.at(i % colors.size()));
        ofTriangle(points.at(triangles.at(i).x), points.at(triangles.at(i).y), points.at(triangles.at(i).z));
    }
    
    // I picked this color out specifically. It doesn't change like the others
    ofColor accent;
    accent.setHsb(37.54, 255*.60, 255*.75);
    ofSetColor(accent);
    ofTriangle(points.at(6), points.at(8), points.at(2));
    
    if (saveScreen){
        ofEndSaveScreenAsPDF();
        saveScreen = false;
    }
    
    ofPopMatrix();
    
}
Exemple #15
0
void ofApp::setupTimeline(){
    
    
    gizmo.setDisplayScale(1.0);
    tcpNode.setPosition(ofVec3f(0.5, 0.5, 0.5)*1000);
    tcpNode.setOrientation(parameters.targetTCP.rotation);
    gizmo.setNode( tcpNode);
    
    ofDirectory dir;
    string dirName = "timeline/saves/"+ofGetTimestampString();
    dir.createDirectory(ofToDataPath(dirName));
    
    timeline.setup();
    
    timeline.setFrameRate(60);
    timeline.setDurationInFrames(timeline.getFrameRate()*30);
    timeline.setLoopType(OF_LOOP_NORMAL);
    
    nodeTrack = new ofxTLNodeTrack();
    nodeTrack->setNode(tcpNode);
    nodeTrack->setTimeline(&timeline);
    nodeTrack->setXMLFileName(dirName+"/_keyframes.xml");
    timeline.addTrack("TargetTCP", nodeTrack);
    timeline.setWorkingFolder(dirName);
    timeline.setFrameBased(false);
    
    nodeTrack->lockNodeToTrack = true;
}
Exemple #16
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key){ 
	
	if (key == ' '){
		VF.clear();
	} else if (key == 'a'){
		drawingStyle ++;
		drawingStyle %= 4;
	} else if (key == 'f'){
		bFade = !bFade;
	} else if (key == 'r'){
        VF.randomizeField(4.0);
    }
    
    if( key=='1'){
        pdfRendering = !pdfRendering;
        if( pdfRendering ){
            ofSetFrameRate(12);  // so it doesn't generate tons of pages
            ofBeginSaveScreenAsPDF("recording-"+ofGetTimestampString()+".pdf", true);
        }else{
            ofSetFrameRate(60);
            ofEndSaveScreenAsPDF();
        }
    }
    
    
    if( !pdfRendering && key == '2' ){
        oneShot = true;
    }

    
}
/* Snippet begin */
void ofApp::setup(){
    ofSetWindowShape(1000, 800);
    gif.setup(ofGetTimestampString("out/%Y-%m-%d"), 100, 500, 500, ISOLATE_DRAWING);
    masker.setup(500, 500, 3, ISOLATE_LAYERS);
    masker.toggleOverlay();
    mask.setup("face-mask.png", 500, 500, 1.5, TEXTURE_OFFSET_MIDDLE_CENTER);
    glass.setup("glass3.png", 500, 500, 2.0);
    shapeSystem.setup();
    numPerDimension.x = 2;
    numPerDimension.y = numPerDimension.x * 2;
    spacing.x = gif.width / numPerDimension.x;
    halfSpacing.x = spacing.x * 0.5;
    spacing.y = gif.height / numPerDimension.y;
    halfSpacing.y = spacing.y * 0.5;
    for(int x = 0; x < numPerDimension.x; x++) {
        for(int y = 0; y < numPerDimension.y; y++) {
            shape.setupFilledSquare(halfSpacing.x);
            shape.setPosition(
                x * spacing.x + halfSpacing.x*0.5 + (y % 2 == 0 ? halfSpacing.x : 0),
                y * spacing.y + halfSpacing.y);
            shapes.push_back(shape);
        }
    }
    for(int i = 0; i < shapes.size(); i++) {
        shapeSystem.add(shapes.at(i));
    }
}
Exemple #18
0
//--------------------------------------------------------------
void ofApp::startRecording(){
    
    if(!bUseKinect) return;
    
    if(totalAvatarsThisUser >= MAX_AVATARS || bSavingRecords){
        bRecordingAvatar = false;
        return;
    }
    
    cout << "Start recording." << endl;
    
    currentAvatar++;
    totalAvatarsThisUser++;
    
    // set avatar directory
    string dir = "avatar_"+ofGetTimestampString();
    avatars[currentAvatar].setDirectory(dir);
    
    // start recorder
    recorder.startThread();
    string filePrefix = dir + "/frame_";
    recorder.setPrefix(ofToDataPath(filePrefix));

    // set is recording
    bRecordingAvatar = true;
    
}
Exemple #19
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    
    
//    switch (key){
//			
//		case ' ':
//			// reposition everything: 
//			for (int i = 0; i < particles.size(); i++){
//				particles[i].setInitialCondition(ofRandom(0,ofGetWidth()),ofRandom(0,ofGetHeight()),0,0);
//			}
//			break;
//	}

	
	if( key=='r'){
		pdfRendering = !pdfRendering;	
		if( pdfRendering ){
			ofSetFrameRate(12);  // so it doesn't generate tons of pages
			ofBeginSaveScreenAsPDF("recording-"+ofGetTimestampString()+".pdf", true);
		}else{
			ofSetFrameRate(60);
			ofEndSaveScreenAsPDF();		
		}
	}
    
    
//    if( !pdfRendering && key == 's' ){
//		oneShot = true;
//	}

	
}
//--------------------------------------------------------------
void ofApp::draw(){

	if (savePDF){

		ofBeginSaveScreenAsPDF("recording-"+ofGetTimestampString()+".pdf", true);
	}

	float hue = ofMap(mouseX,0,ofGetWidth(),0,255);
	c.setHue(hue);
	ofSetColor(c);
	ofSetRectMode(OF_RECTMODE_CORNER);
	//ofNoFill();

	//ofBackground(mouseY/2,100,100);
	ofRect( 0, 0, ofGetWidth(), ofGetHeight() );

	float antiHue = 255.0 - hue;
	b.setHue(antiHue);
	ofFill();
	ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(b);
	ofRect(ofGetWidth() / 2, ofGetHeight() / 2, ofGetHeight() - mouseY, ofGetHeight() - mouseY );
	
	if (savePDF){
		savePDF = false;
		ofEndSaveScreenAsPDF();
	}

}
Exemple #21
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    if(key == 's'){
        save = !save;
        recorder.setup("embossLandScape_"+ofGetTimestampString()+"_.mov", w, h, 30);
        recorder.start();
    }
    if(key == '1'){
        frameCounter = hello;
        isAngry = false;
        fbTex.loadData(img.getPixels());
        fbTex2.loadData(img2.getPixels());
        wait = 0;
    }
    
    if(key == '2'){
        fbTex.loadData(img.getPixels());
    }
    
    if(key == '3'){
        frameCounter = endFrame-30;
    }
    
    if(key == 'h'){
        showGui = !showGui;
        gui->setVisible(showGui);
        if(showGui){
            cam.disableMouseInput();
        } else{
            cam.enableMouseInput();
        }
    }
    
    
}
//--------------------------------------------------------------
void testApp::draw(){
	if(cmd == "run")
	{		
		//do
		//	m_par.Simulate(&canvas);
		//while(!m_par.canstop());
		time_t now, then;
		double seconds;
		//time(&now);

		for(int i =0; i<500; i++)
		{
			m_par.Simulate(&canvas);	
		}
		
		//time(&then);
		//seconds = difftime(now, then);
		//cout<<"elapse time during 5000 iterations: "<<seconds<<endl;

		if(m_par.canstop())
			pdfmaker = true;

		if(!m_par.GetSaved1stGroup() && m_par.Get1stGroupStopSign())
		{
			pdfmaker = true;
			m_par.SetSaved1stGroup();
		}
		// show catmull curves and save as pdf
		if(pdfmaker)
		{
			ofBeginSaveScreenAsPDF("testpdf-"+ofGetTimestampString()+".pdf");
			cout<<"Saving..."<<endl;
		}
		m_par.drawcatmull();
		if(pdfmaker)
		{
			ofEndSaveScreenAsPDF();
			cout<<"Saved PDF."<<endl;
			pdfmaker =false;
			if(m_par.canstop())
				exitApp();
		}

		//canvas.reloadTexture();
		//ofSetColor(255);
		//canvas.draw(0,0);
		//if(nowSaveImage)
		//{
		//	nowSaveImage = false;
		//	SaveImage();
		//}
	}
	else if(cmd == "edge")
	{
		edgeImage.reloadTexture();
		ofSetColor(150);
		edgeImage.draw(0,0);
		showEGmap = true;
	}
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    if(key == 'f'){
        ofToggleFullscreen();
    }
    if (key == 's'){
        string frameCount = ofToString(20000+ofGetFrameNum());
        string fileName = "Images/" + frameCount + ".jpg";
        ofSaveScreen(fileName);
    }

    //THIS CREATES A NEW TREE!!
    if(key == 't'){
        ofVec3f treeInit = ofVec3f(0,ofGetHeight()*ofRandom(0.1,0.9),0);
        int angleInit = int(ofRandom(70,130));

        Tree t;
        t.setup(treeInit,angleInit,trees.size());
        trees.push_back(t);
    }

    //THIS SAVES EVERY FRAME
    if(key == 'r'){
            record = true;
            recStart = ofGetFrameNum();
            currentDate = ofGetTimestampString();
        }

    if(key == 'e'){
            record = false;
    }


}
Exemple #24
0
//--------------------------------------------------------------
void ofApp::captureFunction() {

    fbo.begin();
    ofClear(0,0);

    ofPushMatrix();
    ofScale(2, 2, 2);

    cam.setTransformMatrix(camCapture);

    cam.begin();
    mainDrawing();
    cam.end();

    if (bHide) {
        guiDrawing();
    }

    fbo.end();

    ofPixels _p;
    fbo.readToPixels(_p);

    ofImage _temp;
    _temp.setFromPixels(_p.getData(), posSize.x, posSize.y, OF_IMAGE_COLOR_ALPHA);
    string _file = "../../__" + ofGetTimestampString() + ".png";
    _temp.save(_file);

}
Exemple #25
0
//--------------------------------------------------------------
void testApp::keyReleased(int key){

    if(key=='r'){
        bRecording = !bRecording;
        if(bRecording && !vidRecorder.isInitialized()) {
            vidRecorder.setup(fileName+ofGetTimestampString()+fileExt, vidGrabber.getWidth(), vidGrabber.getHeight(), 30, sampleRate, channels);
//          vidRecorder.setup(fileName+ofGetTimestampString()+fileExt, vidGrabber.getWidth(), vidGrabber.getHeight(), 30); // no audio
//            vidRecorder.setup(fileName+ofGetTimestampString()+fileExt, 0,0,0, sampleRate, channels); // no video
//          vidRecorder.setupCustomOutput(vidGrabber.getWidth(), vidGrabber.getHeight(), 30, sampleRate, channels, "-vcodec mpeg4 -b 1600k -acodec mp2 -ab 128k -f mpegts udp://localhost:1234"); // for custom ffmpeg output string (streaming, etc)
            
            // Start recording
            vidRecorder.start();
        }
        else if(!bRecording && vidRecorder.isInitialized()) {
            vidRecorder.setPaused(true);
        }
        else if(bRecording && vidRecorder.isInitialized()) {
            vidRecorder.setPaused(false);
        }
    }
    if(key=='c'){
        bRecording = false;
        vidRecorder.close();
    }
}
Exemple #26
0
//--------------------------------------------------------------
void testApp::keyPressed(int key) {
    if (key=='s') {
        ofImage capture;
        capture.grabScreen(0,0,ofGetWidth(), ofGetHeight());
        capture.saveImage(ofGetTimestampString()+".jpg");
    }
}
Exemple #27
0
void ofApp::addPointsToFile(ofVec3f point)
{
    string name = ofGetTimestampString();
    ofFile file(name + ".txt", ofFile::WriteOnly);
    file << "v(" << point.x << "," << point.y << "," << point.z << ")" <<endl;
    
}
Exemple #28
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
    if (key == 'h')
    {
        gui->toggleVisible();
    }
    if(key == 'p')
    {
        ofxHttpForm form;
        form.action = action_url;
        form.method = OFX_HTTP_POST;
        form.addFormField("Last Record Time",ofGetTimestampString());
        httpUtils.addForm(form);
        requestStr = "message sent: " + ofGetTimestampString();
    }
}
//--------------------------------------------------------------
void saverScene::update(float mouseX, float mouseY){

	saveAndUpload.setMaxCounter(buttonCount);
	clearTags.setMaxCounter(buttonCount*2);	
	
	mx = mouseX;
	my = mouseY;

	if( saveAndUpload.update(mx, my) ){
		
		checkDirExists();
		
		string timeStr = ofGetTimestampString();
        
		
		string fileName = "temptTag-"+timeStr+".gml";
		
		string fullPath = "tags/gml/"+fileName;
		
		imagePath	    = "tags/images/";
		imageFilename   = "temptTag-"+timeStr+".png";
		
		//add the file name to gml
    /*  gml.saveStateAndFileName(groups.getVector(), fullPath, fileName);
				
		reader.loadGML(fullPath);
		
		if( bUpload )uploader.uploadToWeb(gmlUploadString, reader.xml);
		if( bUpload )grabScreen = true;
     */
	}
	
	if( tmpGroups.size() ){
		if( addTag.update(mx, my) ){
			vector <strokeGroup> & vec = groups.getVector();
			for(int i = 0; i < tmpGroups.size(); i++){
				vec.push_back(tmpGroups[i]);
			}
			tmpGroups.clear();
		}
		if( clearLoaded.update(mx, my) ){
			tmpGroups.clear();
		}
	}
	
	if( loadNext.update(mx, my) ){
		loadNextState();
	}
	
	if( loadPrevious.update(mx, my) ){
		loadPreState();
	}
		
	if( clearTags.update(mx, my) ){
		groups.clear();
		groups.addGroup();	
	}
	
}
/* Snippet begin */
void ofApp::setup(){
    ofSetWindowShape(1000, 800);
    gif.setup(ofGetTimestampString("out/%Y-%m-%d"), 64, 500, 500);
    masker.setup(500, 500, 1);
    masker.toggleOverlay();
    foil.setup("foil1.png", 500, 500, 2.0, TEXTURE_OFFSET_MIDDLE_CENTER);
    glass.setup("glass1-inverted.png", 500, 500, 1.0, TEXTURE_OFFSET_MIDDLE_CENTER);
}