示例#1
0
TimeHandler::TimeHandler(bool _realTime){
    
    realTime = _realTime;
    
    if (realTime)
    {
        minutesPerDay = 24 * 60;
        currentHour = ofGetHours();
        timePerDay = minutesPerDay*60*ofGetFrameRate();
        oneHour = timePerDay/24;
        currentDay = 1;
        
        currentTime = ofGetHours() * oneHour;
        currentTime += ofGetMinutes() * (oneHour/60);
        
        
    } else {
        
        minutesPerDay = 1;
        currentDay = 1;
        startTime = 0;
        currentTime = startTime;
        currentHour = 0;
        timePerDay = minutesPerDay*60*ofGetFrameRate();
        oneHour = timePerDay/24;
        
    }
    

    
}
示例#2
0
void ParticleTrace :: saveFBO ( ofxFBOTexture& fbo )
{
    int y = ofGetYear();
    int m = ofGetMonth();
    int d = ofGetDay();
    int r = ofGetHours();
    int n = ofGetMinutes();
    int s = ofGetSeconds();
    
    char str[255];
    sprintf( str, "screengrab_lrg/image_%02d%02d%02d_%02d%02d%02d.png", y % 1000, m, d, r, n, s );
    
    int w = fbo.getWidth();
    int h = fbo.getHeight();
    
	ofxCvColorImage imgTemp;
	imgTemp.allocate( w, h );
	imgTemp.setFromPixels( (unsigned char*)fbo.getPixels(), w, h );
	imgTemp.mirror( true, false );

	ofImage imgSave;
    imgSave.allocate( w, h, OF_IMAGE_COLOR );
    imgSave.setFromPixels( imgTemp.getPixels(), w, h, OF_IMAGE_COLOR );
    imgSave.saveImage( str );
    
	imgTemp.clear();
    imgSave.clear();
}
bool ofxCameraSequenceRecorder::createNewTimeStampDirectory(){

	ofSetDataPathRoot("./data/"); // relative to data

    folder_name =
    "capture-"+ofToString(ofGetYear())
    +ofToString(ofGetMonth())
    +ofToString(ofGetDay())+"-"
    +ofToString(ofGetHours())
    +ofToString(ofGetMinutes())
    +ofToString(ofGetSeconds());

   string dir = ofToDataPath(folder_name);
   cout << "\n\nCreating new directory for capture: " << dir << endl;

   File file_handle(dir);
   bool success = false;
   try{
      success = file_handle.createDirectory();
   }catch( Poco::Exception &except ){
      ofLog(OF_LOG_ERROR, "Could not make directory");
      return false;
   }

   if(success==false)ofLog(OF_LOG_WARNING, "Could not make directory because it already exists");
   return success;

}
void RiodeoJaneiro::draw(){
    ofSetColor(255, 0, 127);
    
    int s = ofGetSeconds();
    int m = ofGetMinutes();
    int h = ofGetHours();
    int n;
    if(h>=12){
        n = h-12;
        
    }else{
        n = h+24-12;
    }
    
    string weather = response["weather"][0]["main"].asString();
    float temp = response["main"]["temp"].asFloat();
    float rate = response2["rates"]["JPY"].asFloat();
    
    
    string city = "     Rio de Janeiro\n\n";
    city += "        Brazil\n\n";
    city += "     " + ofToString(n, 0) + ":" + ofToString(m, 0) + ":" + ofToString(s, 0) + "\n\n";
    city += "              -12h\n\n";
    city += "         25h20min\n\n";
    city += "        " + weather + "\n\n";
    city += "           " + ofToString(temp, 1) + "\n\n";
    city += "         " + ofToString(rate,2) + "yen";
    waster.drawString(city, ofGetWidth()-250, 250);
    
}
void ScreenRecorder::setupNewDirectory()
{
    counter = 0;
    
    string year = ofToString(ofGetYear());
    string month = ofToString(ofGetMonth());
    if (month.size() == 1) month.insert(0, "0");
    string day = ofToString(ofGetDay());
    if (day.size() == 1) day.insert(0, "0");
    string hour = ofToString(ofGetHours());
    if (hour.size() == 1) hour.insert(0, "0");
    string minute = ofToString(ofGetMinutes());
    if (minute.size() == 1) minute.insert(0, "0");
    string second = ofToString(ofGetSeconds());
    if (second.size() == 1) second.insert(0, "0");
    
    currentPath = rootFolderName + "/recording_" + year + "-" + month + "-" + day + "_" + hour + "." + minute + "." + second;
    
    printf("rootFolderName = %s, currentPath = %s \n", rootFolderName.c_str(), currentPath.c_str());
    ofDirectory dir(currentPath);
    if(!dir.exists())
        dir.create(true);
    
    millisAtLastFrame = ofGetElapsedTimeMillis();
}
void testApp::fireCamera(){
	
	ofDirectory dir;
	char pathc[1024];
	sprintf(pathc, "%02d_%02d_%02d_%02d", ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds());
	string path(pathc);
	dir.createDirectory(path);
	
	cameraFiredTime = ofGetElapsedTimef();
	
	cout << "Firing camera at time "<< cameraFiredTime << endl;
	
	shouldFireCamera = false;
	
	camera1.takePhoto();
	pullBackRender = true;
	pullFrontRender = true;
	
	
	ofFile f(path);
	currentSaveDirectory = f.getAbsolutePath();
	
	cout << " absolute path is " << f.getAbsolutePath() << endl;
	
	//front.getColorImage().saveImage(f.getAbsolutePath() + "/backTexture.png");
}
示例#7
0
void nebulaEye::csvRecordCb(bool & flag){
  if ( flag ){
    csvRecorder.clear();
    ofResetElapsedTimeCounter();

    stringstream ss;
    ss << ofGetYear();
    ss << setfill('0') << setw(2) << ofGetMonth();
    ss << setfill('0') << setw(2) << ofGetDay() << "-";
    ss << setfill('0') << setw(2) << ofGetHours();
    ss << setfill('0') << setw(2) << ofGetMinutes();
    ss << setfill('0') << setw(2) << ofGetSeconds() << ".csv";
    ofLog() << "try to create file : " << ss.str();
    csvRecorder.filePath = ofToDataPath(ss.str());
    ofLog() << "record CSV to : " << csvRecorder.filePath;

    int idx(0);
    csvRecorder.setString(0,idx++,"date");
    csvRecorder.setString(0,idx++,"time");
    csvRecorder.setString(0,idx++,"blob x");
    csvRecorder.setString(0,idx++,"blob y");
    csvRecorder.setString(0,idx++,"flow zone 0");
    csvRecorder.setString(0,idx++,"flow zone 1");
    csvRecorder.setString(0,idx++,"flow zone 2");
    csvRecorder.setString(0,idx++,"flow zone 3");

  } else {
    csvRecorder.saveFile();
    // Save the recorded values in the csvRecorder ofxCsv object
    // csvRecorder.saveFile( ofToDataPath( csvFileName ));
    ofLog() << "Saved " << csvRecorder.numRows << " rows to " << csvRecorder.filePath;
  }
}
示例#8
0
//--------------------------------------------------
void simpleLogger::log(int logLevel, const char* format, ...){
	//thanks stefan!
	//http://www.ozzu.com/cpp-tutorials/tutorial-writing-custom-printf-wrapper-function-t89166.html

	logRecord record;
	record.year     = ofGetYear();
	record.month    = ofGetMonth();
	record.day      = ofGetDay();
	record.hour     = ofGetHours();
	record.minute   = ofGetMinutes();
	record.seconds  = ofGetSeconds();
	record.level    = logLevel;

	char str[2048] = {0};

	va_list args;
	va_start( args, format );
	vsprintf(str, format, args );
	va_end( args );

	record.msg      = str;
	record.logStr   =  convertToString(record);

	logs.push_back(record);
	logToXml(record);
}
示例#9
0
//--------------------------------------------------------------
void testApp::draw(){
    // copy enable part of gl state
//    glPushAttrib(GL_ENABLE_BIT);
    
    // setup gl state
//    glEnable(GL_DEPTH_TEST);
//    glEnable(GL_CULL_FACE);
//    light.enable();
    
    // begin scene to post process
//    post.begin(cam);
//    post.begin();
//    cam.begin();
    ofPushMatrix();

//    ofScale(1, -1, 1);
//	ofEnableAlphaBlending();
    //	ofSetColor(255, 255, 255);
	
    
	vbo.bind();
	vbo.updateVertexData(pos, total);
    //	vbo.updateColorData(color, total);
    //	vbo.updateTexCoordData(tex_coord, total);
    
	for (int i=0; i<GRID_WIDTH; i++) {
		for (int j=0; j<GRID_HEIGHT; j++) {
			int index = (j*GRID_WIDTH+i) * LENGTH;
            vbo.draw(GL_TRIANGLE_FAN, index,LENGTH);
		}
	}
    
	vbo.unbind();
    ofPopMatrix();
    // end scene and draw
//    post.end();
//    cam.end();
//    post.end();
    
    // set gl state back to  original
//    glPopAttrib();
//    image.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
//    if(saver.isRecording()) saver.writeRGB(image.getPixels());
//    server.publishScreen();
    if(ofGetLogLevel()==OF_LOG_VERBOSE)
    {
        for (int j=0; j<GRID_HEIGHT; j++) {
            for (int i=0; i<GRID_WIDTH; i++) {
                
                int index2 = (j*GRID_WIDTH+i);
                ofCircle(center_pos[index2],10);
            }
        }
        ofDrawBitmapString(ofToString(ofGetFrameRate()), 20,20);
    }
    
    ofDrawBitmapString(ofToString(ofGetHours())+":"+ofToString(ofGetMinutes()),ofGetWidth()*0.5,ofGetHeight()*0.5);

    
}
示例#10
0
/* EmergenceLog::dateTimeString
 * Returns the current date/time in following format:
 * 2011-05-26,14-36-587,28.469
 */
string EmergenceLog::fileDateTimeString(float beatTime)
{
    string output = "";
    
    int year = ofGetYear();
    int month = ofGetMonth();
    int day = ofGetDay();
    int hours = ofGetHours();
    int minutes = ofGetMinutes();
    int seconds = ofGetSeconds();
    
    output = output + ofToString(year) + ".";
    if (month < 10) output = output + "0";
    output = output + ofToString(month) + ".";
    if (day < 10) output = output + "0";
    output = output + ofToString(day) + ", ";
    if (hours < 10) output = output + "0";
    output = output + ofToString(hours) + ".";
    if (minutes < 10) output = output + "0";
    output = output + ofToString(minutes) + ".";
    if (seconds < 10) output = output + "0";
    output = output + ofToString(seconds) + ", ";
    output = output + ofToString(beatTime, 3);
    
    return output;
}
示例#11
0
void Sydney::draw(){
    ofSetColor(127, 255, 0);
    
    int s = ofGetSeconds();
    int m = ofGetMinutes();
    int h = ofGetHours();
    int n;
    if(h<=22){
        n = h+1;
        
    }else{
        n = h-23;
    }
    
    string weather = response["weather"][0]["main"].asString();
    float temp = response["main"]["temp"].asFloat();
    float rate = response2["rates"]["JPY"].asFloat();
    
    string city = "     Sydney\n\n";
    city += "        Australia\n\n";
    city += "     " + ofToString(n, 0) + ":" + ofToString(m, 0) + ":" + ofToString(s, 0) + "\n\n";
    city += "              +1h\n\n";
    city += "         9h30min\n\n";
    city += "        " + weather + "\n\n";
    city += "           " + ofToString(temp, 1) + "\n\n";
    city += "         " + ofToString(rate,2) + "yen";
    waster.drawString(city, ofGetWidth()-250, 250);
}
示例#12
0
//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
    if(gui2->hasKeyboardFocus())
    {
        return;  
    }
	switch (key) 
	{			
		case '`':
		{
			string hr;         
			ofImage img; 
			img.grabScreen(0,0,ofGetWidth(), ofGetHeight()); 
			if(ofGetHours() < 12)
			{
				hr = " AM"; 
			}
			else
			{
				hr = " PM"; 
			}
			img.saveImage("snapshots/OFXUI "+ofToString(ofGetYear())+"-"+ofToString(ofGetMonth())+"-"+ofToString(ofGetDay())+" at "+ofToString(ofGetHours(),2)+"."+ofToString(ofGetMinutes(),2)+"."+ofToString(ofGetSeconds(),2) +hr +".png");
		}						
			break; 
			
		case 'f':
			ofToggleFullscreen(); 
			break;

		case 'h':
            gui1->toggleVisible(); 
            gui2->toggleVisible(); 
            gui3->toggleVisible();             
			break;

		case 'p':
			bdrawPadding = !bdrawPadding; 
			gui1->setDrawWidgetPaddingOutline(bdrawPadding); 			
			gui2->setDrawWidgetPaddingOutline(bdrawPadding); 			
			gui3->setDrawWidgetPaddingOutline(bdrawPadding); 			            
			break;			

		case '[':
			gui1->setDrawWidgetPadding(false); 			
			gui2->setDrawWidgetPadding(false);
			gui3->setDrawWidgetPadding(false);
			break;			

		case ']':
			gui1->setDrawWidgetPadding(true); 			
			gui2->setDrawWidgetPadding(true);
			gui3->setDrawWidgetPadding(true);
			break;			
			
            
		default:
			break;
	}
}
示例#13
0
//--------------------------------------------------------------
string ofApp::getTakeName() {
	return ofToString(ofGetYear(), 4, '0') + "-"
		+ ofToString(ofGetMonth(), 2, '0') + "-"
		+ ofToString(ofGetDay(), 2, '0') + "-"
		+ ofToString(ofGetHours(), 2, '0') + "-"
		+ ofToString(ofGetMinutes(), 2, '0') + "-"
		+ ofToString(ofGetSeconds(), 2, '0');
}
示例#14
0
void ofApp::draw_wave(){

    if(audioIn_data.size()!=0){

        ob::DrawerSettings & s = ob::dset;
        s.app = this;
        s.indicator = indicator;
        s.data = &audioIn_data;
        s.track_len = track_len;
        s.buffer_size = bufferSize;
        s.xrate = track_len/s.buffer_size;
        s.global_amp = canvas.height/2 * 0.8;

        int start = 0;
        const int end = s.buffer_size;
        bool loop = true;

        while( loop ){

            float n1 = ofNoise( ofGetDay(), ofGetElapsedTimef(), start );
            int type_max = 7;
            int type = round(n1 * type_max);

            float n2 = ofNoise( ofGetHours() , ofGetFrameNum()*2.0, start );
            n2 = pow(n2, 8) * ofRandom(1.0f,10.0f);

            int num_min = s.buffer_size * 0.01;
            int num_max = s.buffer_size * 0.05;
            int num = num_min + n2*num_max;

            if(type == 3) num*=0.25;

            if((start+num)>=end){
                num =  end-start-1;
                loop = false;
                if(num<=2) break;
            }

            glPointSize( 1 );

            switch (type) {
                case 0: ob::draw_line_wave(start, num); break;
                case 1: ob::draw_dot_wave(start, num); break;
                case 2: ob::draw_prep_line(start, num); break;
                case 3: ob::draw_circle(start, num); break;
                case 4: ob::draw_rect(start, num); break;
                case 5: ob::draw_log_wave(start, num); break;
                case 6: ob::draw_arc(start, num, 0.5); break;
                case 7: ob::draw_prep_line_inv(start, num, 0.33f); break;

                default: break;
            }

            start += num;
        }
    }
}
示例#15
0
void inputManager::startRecord(){
	
	folderName = "recordedImages/" + ofToString(ofGetMonth(),0) + ofToString(ofGetDay(), 0)
				+ ofToString(ofGetHours(), 0) + ofToString(ofGetMinutes(), 0)
				+ ofToString(ofGetSeconds(), 0);

	fileHelper.makeDirectory(folderName);
	bRecord = true;
}
示例#16
0
void ofApp::touchDoubleTap(int x, int y, int id){
    //string fileName = "screenshot/" + ofGetTimestampString() + ".png";
    string fileName= "/sdcard/DCIM/myFolder/ob"
    				+ ofToString(ofGetYear()) + ofToString(ofGetMonth())
    				+ ofToString(ofGetDay()) + ofToString(ofGetHours())
    				+ ofToString(ofGetMinutes()) + ofToString(ofGetSeconds())
    				+ ".png";
    ofSaveScreen(fileName);
}
void testApp::createFileName(void)
{
	ostringstream oss;
	oss << ofGetYear() << "-";
	oss << setw(2) << setfill('0') << ofGetMonth() << "-";
	oss << setw(2) << setfill('0') << ofGetDay() << "-";
	oss << setw(2) << setfill('0') << ofGetHours() << "-";
	oss << setw(2) << setfill('0') << ofGetMinutes() << "-";
	oss << setw(2) << setfill('0') << ofGetSeconds() << ".mov";
	mFileName = oss.str();	
}
示例#18
0
//-----------------------------------------------keyPressed p or x to save---------------
void ofApp::keyPressed(int key)
{
    // key 'p' or key 'x' is used to save the images and create a movie.

    //TODO: move this to be done by the mouse.  Maybe the mouse wheel or the move from the optical sensor.

    if (key == 'p' || key == 'x')
    {
        //makes a folder and video name using time date tags when saving and exporting.


        int day = ofGetDay();
        int hour = ofGetHours();
        int minute = ofGetMinutes();
        char timeStamp[24];
        sprintf(timeStamp,"%02d%02d%02d",day,hour,minute);
        char exportFile[100];
        ofImage img2Export;


        ofPixels pix2Export;
        for(int i = 0; i < videoArray.size(); i ++)
        {
            videoArray[i].readToPixels(pix2Export);
            img2Export.setFromPixels(pix2Export);





            sprintf(exportFile,"image-%03d.png",i);//saves the images.//dms
            img2Export.saveImage(exportFile);

        }

        char videoExportCmd[256];
        sprintf(videoExportCmd, "/usr/local/bin/ffmpeg -r %d -y -i ./data/image-%%03d.png -c:v mpeg4 -r %d -pix_fmt yuv420p ~/Desktop/data/v%s.mp4",frameRate,frameRate,timeStamp);



        system(videoExportCmd);//saves the images as a video. dms
        char deleteOldImages[24];
        sprintf(deleteOldImages, "rm data/*.png");//dms delete old images
        system(deleteOldImages);


                char exportAWS[100];
                char nameAWS[100];
                sprintf(nameAWS,"v%s.mp4",timeStamp);
                sprintf(exportAWS,"aws s3 cp ~/Desktop/data/%s s3://stopmotion/%s",nameAWS,nameAWS);
               system(exportAWS);

    }
}
示例#19
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
	
	if(timeline.isModal()){
		return;
	}
	
    if(key == ' '){
		timeline.togglePlay();
	}
	
	if(key == 'T'){
		camTrack.addKeyframe();
	}
	
	if(key == 'L'){
		camTrack.lockCameraToTrack = !camTrack.lockCameraToTrack;
		if(!camTrack.lockCameraToTrack){
			cam.setAnglesFromOrientation();
		}
	}
	
	if(key == 'R'){
		rendering = !rendering;
		
		if(rendering){
			currentFrameNumber = 0;
			char fileName[1024];
			sprintf(fileName, "frame_%02d_%02d_%02d/", ofGetDay(), ofGetHours(), ofGetMinutes() );
			renderFolder = string(fileName);
			ofDirectory(renderFolder).create(true);
		}

		timeline.stop();
		player.getVideoPlayer()->stop();
		timeline.setPercentComplete(timeline.getInOutRange().min);
		timeline.play();
	}
	
	if(key == 'f'){
		ofToggleFullscreen();
	}
	
	if(key == 'S'){
		loadShader();
	}
	
	if(key == '1'){
		particleRenderer.sampleTextureColors(player.getVideoPlayer()->getPixelsRef());
	}
	
	if(key == 'P'){
		generateAmbientParticles();
	}
}
示例#20
0
void ofApp::saveData()
{
    string userTime = "User" + std::to_string(userIndex) + ":time";
    string userColor = "User" + std::to_string(userIndex) + ":color";
    string userDay = "User" + std::to_string(userIndex) + ":day";
    string userHour = "User" + std::to_string(userIndex) + ":hour";
    
    
    dataLog.setValue(userTime, finalCounter);
    dataLog.setValue(userColor, Light::getInstance().getCurrentColor()); //<<<<<<<-----------------------------!!!!!INTRODUIR COLOR!!!!!
    dataLog.setValue(userDay, std::to_string(ofGetDay()));
    dataLog.setValue(userHour, std::to_string(ofGetHours()) + "." + std::to_string(ofGetMinutes()));
    
    dataLog.saveFile("Log_BlueProject_" + std::to_string(ofGetDay()) + "_"
                     + std::to_string(ofGetHours()) + "h"
                     + std::to_string(ofGetMinutes()) + ".xml");
    
    dataLog.saveFile("Log_BlueProject_" + std::to_string(ofGetDay()) + "_"
                     + std::to_string(ofGetHours()) + "h"
                     + std::to_string(ofGetMinutes()) + "_copy.xml");

}
示例#21
0
void testApp::toLog(const std::string& to_log){

	static bool initLog = false;

	if(!initLog){
		sprintf(logFilename, "log_%02d_%02d_%02d_%02d_%02d.txt", ofGetMonth(), ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds());
		log.append("Clouds Visual Systems Test Log \n ================================================ \n ");
		initLog = true;
	}

	log.append(to_log);
	logEnd();
}
示例#22
0
// ---------------------------------
void Clockbug::update()
{
    // Our goal here is to calculate 2 things: target angle and target distance
    
    
    // Which angle should the bug be at?
    // Hint: this depends on which "type" it is
    float targetAngle;
    if(type==BUG_TYPE_HOUR_HAND) {
        float hours = ofGetHours() + (ofGetMinutes()/60.0) + (ofGetSeconds()/3600.0);
        targetAngle = ofMap(hours, 0, 12, CLOCK_TOP, CLOCK_TOP+M_TWO_PI);
    }
    if(type==BUG_TYPE_MINUTE_HAND) {
        float minutes = ofGetMinutes() + (ofGetSeconds()/60.0);
        targetAngle = ofMap(minutes, 0, 60, CLOCK_TOP, CLOCK_TOP+M_TWO_PI);
    }
    if(type==BUG_TYPE_SECOND_HAND) {
        float seconds = ofGetSeconds();
        targetAngle = ofMap(seconds, 0, 60, CLOCK_TOP, CLOCK_TOP+M_TWO_PI);
    }
    
    
    // Calculate some "noise" -- smoothly changing random values
    // This will give us a value between 0 and 1.
    float angleNoise = ofNoise(noise[0], ofGetElapsedTimef()/slow);
    // change the noise value from [0 -> 1] to [-5 -> 5]
    angleNoise = ofMap(angleNoise, 0, 1, ofDegToRad(-5), ofDegToRad(5));
    
    // Add that noise to the target angle.  This will make the bug move
    // a little bit (+/- 5 degrees) around it's target angle
    targetAngle += angleNoise;
    
    // Now that we have determined the angle the bug will be at,
    // we will calculate how far away from the center it should be.
    // once again, we get smoothly changing noise [0 -> 1]
    // and then calculate the dist on the scale of [0 -> maximumDistance]
    float dist = ofNoise(noise[1], ofGetElapsedTimef()/slow);
    float targetDist = ofMap(dist, 0, 1, 0, maximumDistance);
    
    
    // Calculate where the bug should be moving towards
    // Here we are converting from radial to cartesian.
    ofPoint target;
    target.x = cos(targetAngle) * targetDist;
    target.y = sin(targetAngle) * targetDist;
    
    
    // Move towards target point
    ofPoint diff = target - pos;
    pos += diff / 10.0;
}
示例#23
0
void ProjectorTimer::checkProjectorPower(){
    
    int currentHour;
    int currentDay;
    if(useFakeTime){
        currentHour = fakeHours;
        currentDay = fakeDay;
    } else {
        currentHour = ofGetHours();
        currentDay = ofGetWeekday();
    }
    bool dayEnabled = false;
    
    switch (currentDay) { //is today enabled?
        case 0:
            dayEnabled = autoPwrSun;
            break;
        case 1:
            dayEnabled = autoPwrMon;
            break;
        case 2:
            dayEnabled = autoPwrTues;
            break;
        case 3:
            dayEnabled = autoPwrWeds;
            break;
        case 4:
            dayEnabled = autoPwrThurs;
            break;
        case 5:
            dayEnabled = autoPwrFri;
            break;
        case 6:
            dayEnabled = autoPwrSat;
            break;
            
        default:
            break;
    }
    
    //if it's between the on hour and the off hour, and the projector's off, and today is enabled, turn it on. if it's later than the off hour and the projector is on, and today is enabled, turn it off.
    if (currentHour >= projOnHour && currentHour < projOffHour && !pjControl.getProjectorStatus() && dayEnabled) {
        startupProjectors();
        projectorPower = true;
        ofLogWarning()<<"started projector automatically at "<< currentHour<<":"<<ofGetMinutes()<<endl;
    } else if (currentHour >= projOffHour && pjControl.getProjectorStatus() && dayEnabled){
        shutdownProjectors();
        projectorPower = false;
        ofLogWarning()<<"shut down projector automatically at "<< currentHour<<":"<<ofGetMinutes()<<endl;
    }
}
//--------------------------------------------------------------
string motionDetector::generateFileName() {

    string _root = "kinectRecord";
    string _timestamp = ofToString(ofGetDay()) +
                        ofToString(ofGetMonth()) +
                        ofToString(ofGetYear()) +
                        ofToString(ofGetHours()) +
                        ofToString(ofGetMinutes()) +
                        ofToString(ofGetSeconds());

    string _filename = (_root + _timestamp + ".oni");

    return _filename;
}
示例#25
0
//--------------------------------------------------------------
bool ofApp::isTimeToOpenScreen()
{
	float currentHour = ofGetHours() + (ofGetMinutes()/60.0);
	float timeOpen;
	int switchMode = gui.getValueI("TIME_SWITCHON_TYPE");
	if(switchMode==1){
		timeOpen = gui.getValueF("TIME_SWITCHON_HOUR") + (gui.getValueF("TIME_SWITCHON_MINUTE")/60.0);
	}else if(switchMode==0){
		timeOpen = mySunrise.getSunset()-0.5; // open half an hour before sunset
	}else if(switchMode==2){
		timeOpen = true;
	}
	float timeClose = gui.getValueF("TIME_SWITCHOFF_HOUR")+(gui.getValueF("TIME_SWITCHOFF_MINUTE")/60.0);
	return currentHour>timeOpen && currentHour<timeClose;
}
示例#26
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground(0);
	//	grabber.draw(0, 0);
	cam.begin();
	//	ofDrawAxis(100);
//	ofDrawGrid(100,10,false,true,true,true);
	ofPushMatrix();
	ofEnableAlphaBlending();
	ofSetColor(255, 255, 255);
	

	vbo.bind();
	vbo.updateVertexData(pos, total);
	vbo.updateColorData(color, total);
	vbo.updateTexCoordData(tex_coord, total);
	if(bUseGrabber)grabber.getTextureReference().bind();
	for (int i=0; i<GRID_WIDTH; i++) {
		for (int j=0; j<GRID_HEIGHT; j++) {
			int index = (j*GRID_WIDTH+i) * LENGTH;
//			for(int k = 0; k < LENGTH ; k++)
			{
//				vbo.draw(GL_LINES, index,LENGTH);
				vbo.draw(GL_TRIANGLE_FAN, index,LENGTH);
			}
		}
	}
	if(bUseGrabber)grabber.getTextureReference().unbind();
	vbo.unbind();
	
	ofPopMatrix();
	cam.end();
	if (bSnap) {
		string hr;
		ofImage img;
		img.grabScreen(0,0,ofGetWidth(), ofGetHeight());
		if(ofGetHours() < 12)
		{
			hr = " AM";
		}
		else
		{
			hr = " PM";
		}
		img.saveImage(ofToString(ofGetYear())+"-"+ofToString(ofGetMonth())+"-"+ofToString(ofGetDay())+" at "+ofToString(ofGetHours(),2)+"."+ofToString(ofGetMinutes(),2)+"."+ofToString(ofGetSeconds(),2) +hr +".png");
		bSnap = false;
	}
	ofDrawBitmapString(ofToString(ofGetFrameRate()), 20,20);
}
示例#27
0
//--------------------------------------------------------------
void ofApp::draw(){
    string s;
    s = ofToString(ofGetHours()) + ofToString(ofGetMinutes()) + ".ai";
    if (loop) {
        vg.beginEPS(s);
        
        /*===========================code===========================*/
        for (int i = 0; i < 5000; i++) {
            vg.setColor(ofRandom(255), ofRandom(255), ofRandom(255));
            vg.rect(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()), ofRandom(5), ofRandom(5));
        }
        /*===========================code===========================*/
        vg.endEPS();
        loop = false;
    }
}
示例#28
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){

	if(key == ' '){
		timeline.togglePlay();
	}
	
	if(key == 'g'){
		generate();
	}
	
	if(key == 't'){
		traverse();
	}
	
	if(key == 'T'){
		camTrack.addKeyframe();
	}
	
	if(key == 'L'){
		camTrack.lockCameraToTrack = !camTrack.lockCameraToTrack;
		if(!camTrack.lockCameraToTrack){
			cam.setAnglesFromOrientation();
		}
	}
	
	if(key == 'f'){
		ofToggleFullscreen();
	}
	
	if(key == 'R'){
		rendering = !rendering;
		if(rendering){
			char folder[1024];
			sprintf(folder, "frames_%02d_%02d_%02d/",ofGetDay(), ofGetHours(), ofGetMinutes());
			renderFolder = folder;
			frameNum = 0;
			ofDirectory(renderFolder).create(true);
			timeline.setCurrentFrame(timeline.getInFrame());
			timeline.play();
		}
	}
	
	if(key == 'S'){
		loadShader();
	}
}
示例#29
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
	if(key == ' '){
		recording = !recording;
        if(recording){
            ofImage posterFrame;
            posterFrame.setFromPixels(kinect.getPixels(), kinect.getWidth(), kinect.getHeight(), OF_IMAGE_GRAYSCALE);
            recorder.incrementFolder(posterFrame);
        }
	}
    
    if(key == 'c'){
        string filename = "__CalibFile_" + ofToString(ofGetDay()) + "_" + ofToString(ofGetHours()) + "_" + ofToString(ofGetMinutes()) + "_" + ofToString(ofGetSeconds()) +".png";
        ofImage kinectImage;
        kinectImage.setFromPixels(kinect.getPixels(), 640, 480, OF_IMAGE_GRAYSCALE);
        ofSaveImage( kinectImage, filename);
    }
}
void ofxDepthImageRecorder::incrementTake(){
	char takeString[1024] ;
	sprintf(takeString, "TAKE_%02d_%02d_%02d_%02d_%02d", ofGetMonth(), ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds());
    currentFolderPrefix = string(takeString);
    ofDirectory dir(targetDirectory + "/" + currentFolderPrefix);
    
    dir.create(true);
	ofDirectory depthDir = ofDirectory(dir.getOriginalDirectory() + "/depth/");
    depthDir.create(true);
	
    //create a color folder for good measure
	ofDirectory colorDir = ofDirectory(dir.getOriginalDirectory() + "/color/");
    colorDir.create(true);
    
    currentFrame = 0;	
    recordingStartTime = msaTimer.getAppTimeMillis();
}