Пример #1
0
void ofApp::drawMediaView() {
    if (currentAssetIsMovie) {
        video.draw(0, 0, 3240, 1920);
    }
    else {
        image.draw(0, 0, 3240, 1920);
        imageTimer++;
    }
    
    // Caption
    ofSetColor(0, 255);
    font.drawString(artistNames[currentIndex], 105, ofGetScreenHeight() - 95);
    ofSetColor(255, 255);
    font.drawString(artistNames[currentIndex], 100, ofGetScreenHeight() - 100);
    
    if(currentAssetIsMovie) {
        if(video.getIsMovieDone()) {
            cout << "DONE" << endl;
            playState = 1;
            imageTimer = 0;
            video.stop();
            // Increase Play
            currentIndex++;
            if(currentIndex >= maxIndex) {
                currentIndex = 0;
            }
            updateCurrentIndex();
        }
    }
    else {
        if (imageTimer > imageMAX ) {
            cout << "DONE" << endl;
            playState = 1;
            imageTimer = 0; 
            
            // Increase Play
            currentIndex++;
            if(currentIndex >= maxIndex) {
                currentIndex = 0;
            }
            updateCurrentIndex();
        }
    }
}
Пример #2
0
void BooksListWatcher::setListView(QQuickItem* aView)
{
    if (iListView != aView) {
        const QSize oldSize(iSize);
        if (iListView) iListView->disconnect(this);
        iListView = aView;
        if (iListView) {
            connect(iListView,
                SIGNAL(widthChanged()),
                SLOT(onWidthChanged()));
            connect(iListView,
                SIGNAL(heightChanged()),
                SLOT(onHeightChanged()));
            connect(iListView,
                SIGNAL(contentXChanged()),
                SLOT(onContentXChanged()));
            connect(iListView,
                SIGNAL(contentYChanged()),
                SLOT(onContentYChanged()));
            connect(iListView,
                SIGNAL(contentWidthChanged()),
                SLOT(onContentSizeChanged()));
            connect(iListView,
                SIGNAL(contentHeightChanged()),
                SLOT(onContentSizeChanged()));
            iContentX = contentX();
            iContentY = contentY();
            updateCurrentIndex();
        } else {
            iContentX = iContentY = 0;
            iSize = QSize(0,0);
        }
        Q_EMIT listViewChanged();
        if (oldSize != iSize) {
            Q_EMIT sizeChanged();
        }
        if (oldSize.width() != iSize.width()) {
            Q_EMIT widthChanged();
        }
        if (oldSize.height() != iSize.height()) {
            Q_EMIT heightChanged();
        }
    }
}
Пример #3
0
void ofApp::keyPressed (int key) {
	switch (key) {
		case ' ':
			bThreshWithOpenCV = !bThreshWithOpenCV;
			break;
			
		case '>':
		case '.':
			farThreshold ++;
			if (farThreshold > 255) farThreshold = 255;
			break;
			
		case '<':
		case ',':
			farThreshold --;
			if (farThreshold < 0) farThreshold = 0;
			break;
			
		case '+':
		case '=':
			nearThreshold ++;
			if (nearThreshold > 255) nearThreshold = 255;
			break;
			
		case '-':
			nearThreshold --;
			if (nearThreshold < 0) nearThreshold = 0;
			break;
			
		case 'w':
			kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
			break;
			
		case 'o':
			kinect.setCameraTiltAngle(angle); // go back to prev tilt
			kinect.open();
			break;
			
		case 'c':
			kinect.setCameraTiltAngle(0); // zero the tilt
			kinect.close();
			break;
			
		case '1':
			targetAlpha = 50;
			kinect.setLed(ofxKinect::LED_GREEN);
			break;
			
		case '2':
			targetAlpha = 125;
			kinect.setLed(ofxKinect::LED_YELLOW);
			break;
			
		case '3':
			targetAlpha = 200;
			kinect.setLed(ofxKinect::LED_RED);
			break;
			
		case '4':
			kinect.setLed(ofxKinect::LED_BLINK_GREEN);
			break;
			
		case '5':
			kinect.setLed(ofxKinect::LED_BLINK_YELLOW_RED);
			break;
			
		case '0':
			kinect.setLed(ofxKinect::LED_OFF);
			break;
			
		case OF_KEY_UP:
			angle++;
			if(angle>30) angle = 30;
			kinect.setCameraTiltAngle(angle);
			break;
			
		case OF_KEY_DOWN:
			angle--;
			if(angle<-30) angle =- 30;
			kinect.setCameraTiltAngle(angle);
			break;

		case 'g':
			minBlob--;
			break;
		
		case 'h':
			minBlob++;
			break;
	
		case 'e':
			closePoints.begin();
				ofFill(); 
				ofSetColor(ofColor::white);
				ofRect(0, 0, closePoints.getWidth(), closePoints.getHeight());
			closePoints.end();
			break;

		case 'd':
			presenting = !presenting;
			playState = presenting;
			break;

		case 'n':
			// Increase Play
			currentIndex++;

			// Check Limit
			if(currentIndex >= maxIndex) {
				currentIndex = 0;
			}

			// Update Assets
			updateCurrentIndex();

			break;

		case 's':
			tooSunny = !tooSunny;
			break;

		case 'm':
			showDemo = !showDemo;
			if(showDemo) {
				playState = 4;
				demo.play();
				demo.setLoopState(OF_LOOP_NONE);
			}
			break;

		case 'b':
			bLearnBakground = true;
			break;

	}
}
Пример #4
0
void ofApp::setup() {

	// SYSTEM
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofHideCursor();
	ofSetFrameRate(60);
	
	// SCREEN
    ofEnableAlphaBlending();
    ofBackground(100);
    width = ofGetWindowWidth();
    height = ofGetWindowHeight();
    
    // STATE
    presenting = true;
    tooSunny = false;
    fboAge = 0;
    imageTimer = 0;
    imageMAX = 500;
    playState = 1;
    currentBrightness = 0;
    targetAlpha = 155;
	
    #ifdef INTERACTIVE
        // KINECT
        #ifdef KINECT
            kinect.setRegistration(true);
            kinect.init();	
            kinect.open();
            if(kinect.isConnected()) {
                ofLogNotice() << "sensor-emitter dist: " << kinect.getSensorEmitterDistance() << "cm";
                ofLogNotice() << "sensor-camera dist:  " << kinect.getSensorCameraDistance() << "cm";
                ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() << "mm";
                ofLogNotice() << "zero plane dist: " << kinect.getZeroPlaneDistance() << "mm";
            }
            angle = 23;
            kinect.setCameraTiltAngle(angle);
        #else
            camera.setVerbose(true);
            camera.initGrabber(320, 240);
        #endif
    
        // CAPTURE SIZE
        int capture_width, capture_height;
        #ifdef KINECT
            capture_width = kinect.width;
            capture_height = kinect.height;
        #else
            capture_width = camera.width;
            capture_height = camera.height;
        #endif
        
        // OPENCV
        colorImg.allocate(capture_width, capture_height);
        grayImage.allocate(capture_width, capture_height);
        grayThreshNear.allocate(capture_width, capture_height);
        grayThreshFar.allocate(capture_width, capture_height);
        grayBg.allocate(capture_width, capture_height);
        grayDiff.allocate(capture_width, capture_height);
        closePoints.allocate(capture_width, capture_height, GL_RGBA32F_ARB);

        nearThreshold = 350;
        farThreshold = 112;
        bLearnBakground = true;
        threshold = 80;
        bThreshWithOpenCV = false;
        minBlob = 25; 
        maxBlob = (capture_width * capture_height)/2;
    
        // FBO & GLSL SHADER
        setupGL(width, height);
    #else
        playState = 2;
        imageMAX = 2500;
    #endif
    

	
    // XML ASSETS
    BASEPATH = "../../../MEDIA/";
    assets.loadFile("xml/assets.xml");
    if( assets.loadFile("xml/assets.xml") ) {
        ofLog(OF_LOG_NOTICE, "Loaded xml file !!! \n");
        loadFonts();
        loadArtists();
        loadAssets();
    }
    else {
        ofLog(OF_LOG_ERROR, "UNABLE to load xml file :( \n");
    }

    //  INDEX
    currentIndex = 0;
    updateCurrentIndex();

    // ASSETS
    brush.loadImage("mouse/brush.png");
	stamp.loadImage("logo/stamp_white2.png");
	demo.loadMovie(BASEPATH + "demo/studio_in_the_city_6_promo.mp4");
    
    // MEMORY
    checkMemory();

	cout << "Setup Is Done \n" << endl;
}
Пример #5
0
//--------------------------------------------------------------
void testApp::draw() {

	// DEBUG VIEW
	if(presenting == false ) {
	
		// Draw IR Images
		kinect.drawDepth(10, 10, 400, 300); // Depth
		kinect.draw(420, 10, 400, 300); // RGB
		contourFinder.draw(10, 320, 400, 300); // Blobs
		closePoints.draw(420, 320, 400, 300); // FBO

		// Draw The CV Images
		colorImg.draw(1100, 10, 400, 300); // RGB
		grayImage.draw(1510, 20, 400, 300); // Grayscale
		grayBg.draw(1100, 280, 400, 300); // Background
		grayDiff.draw(1510, 280, 400, 300); // Difference
	
		// Debug Info
		ofSetColor(255, 255, 255);
		stringstream reportStream;
		reportStream 
		<< "using opencv threshold = " << bThreshWithOpenCV <<" (press spacebar)" << endl
		<< "set near threshold " << nearThreshold << " (press: + -)" << endl
		<< "set far threshold " << farThreshold << " (press: < >)" << endl
		<< "num blobs found " << contourFinder.nBlobs << endl
		<< "current brightness is " << currentBrightness << endl
		<< "fps: " << ofGetFrameRate() << endl
		<< "play state is " << playState << endl
		<< "Too Sunny ? = " << int(tooSunny) << endl
		<< "press c to close the connection and o to open it again, connection is: " << kinect.isConnected() << endl;
		if(kinect.hasCamTiltControl()) {
    		reportStream << "press UP and DOWN to change the tilt angle: " << angle << " degrees" << endl
			<< "press 1-5 & 0 to change the led mode" << endl;
		}
		ofDrawBitmapString(reportStream.str(), 20, 652);

	} // presenting

	// INTERACTIVE VIEW
	else if(presenting == true && playState == 1) {
		// Draw FBO
		fbo.draw(0, 0, maskFbo.getWidth(), maskFbo.getHeight());
	}

	// PLAYING VIEW
	else if(presenting == true && playState == 2) {
		// Movie
		if (currentAssetIsMovie) {
			video.draw(0, 0, 3240, 1920); 
		}
		
		// Image
		else {
			image.draw(0, 0, 3240, 1920);
			imageTimer++; 
		}

		// Caption
		ofSetColor(0, 255);
		font.drawString(artistNames[currentIndex], 105, ofGetScreenHeight() - 95);
		ofSetColor(255, 255);
		font.drawString(artistNames[currentIndex], 100, ofGetScreenHeight() - 100);

		// DONE ???
		
		// Movie
		if(currentAssetIsMovie) {
			if(video.getIsMovieDone()) {
				cout << "DONE" << endl;
				playState = 1; 
				imageTimer = 0; 
				video.stop(); 
			
				// Increase Play
				currentIndex++;

				// Check Limit
				if(currentIndex >= maxIndex) {
					currentIndex = 0;
				}

				// Update Assets
				updateCurrentIndex();
			}
		}
		
		// Image
		else {
			if (imageTimer > 500 ) {
				cout << "DONE" << endl;
				playState = 1; 
				imageTimer = 0; 
			
				// Increase Play
				currentIndex++;

				// Check Limit
				if(currentIndex >= maxIndex) {
					currentIndex = 0;
				}

				// Update Assets
				updateCurrentIndex();
			}
		}

	} // playback

	// TRAILER VIEW
	else if(presenting == true && playState == 4) {
		if(demo.getIsMovieDone()) {
			playState = 1;
			demo.stop();
		}
		else {
			if(currentAssetIsMovie) {
				video.stop()	;
			}
			demo.draw(0, 0, 3240, 1920); 
		}
	} // trailer

} // draw()
Пример #6
0
void StackedDocumentTreeView::_q_currentDocumentIndexChanged( int index )
{
    const QModelIndex idx = index >= 0 ? model()->index( index, 0 ) : QModelIndex();
    updateCurrentIndex( idx );
}
Пример #7
0
void StackedDocumentTreeView::_q_selectionChanged()
{
    const QModelIndex index = selectionModel()->selectedIndexes().value( 0 );
    updateCurrentIndex( index );
}
Пример #8
0
void BooksListWatcher::onContentSizeChanged()
{
    HASSERT(sender() == iListView);
    updateCurrentIndex();
}