diff --git a/src/Player.cpp b/src/Player.cpp index 0c5e965..0e354c1 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -2,9 +2,11 @@ Player::Player(){ hasVideo = false; - playerVideoIndex = 0; + + // Set IP, Port, and POST req.setup("192.168.0.53", 2000, "search"); + // Initial values resp.folder = "fingers.mp4"; resp.video = "movies/fingers.mp4"; resp.image = "images/happy.png"; @@ -12,12 +14,15 @@ Player::Player(){ } void Player::setup(){ + // Loop state videoPlayer.setLoopState(OF_LOOP_NONE); + setupGUI(); int windowW = ofGetWindowWidth(); int windowH = ofGetWindowHeight(); + // Sets window size fbo.allocate(windowW * 2 / 3, windowH, GL_RGBA); } @@ -49,14 +54,16 @@ void Player::draw(){ } void Player::setVideo(VPQuery query){ + // Set video path videoPath = query.video; videoPlayer.load(videoPath); - videoPlayer.setFrame(query.frame); - setVideoPosition(); + // Center video + setVideoPosition(); currentVideoLabel = query.folder; + // Play Video videoPlayer.play(); } @@ -83,26 +90,27 @@ void Player::setVideoPosition(){ } void Player::setRandomFrame(){ + // Sets a random frame in the active video + int randomFrame = ofRandom(0, videoPlayer.getTotalNumFrames()); videoPlayer.setFrame(randomFrame); } string Player::getFrameName(){ + + // Returns current frame name string imagePath = resp.image; return imagePath; } -int Player::getFrameIndex(){ - return resp.index; -} - void Player::setupGUI(){ - gui.setup("Embeddings"); - + // Setting up GUI + gui.setup("Embeddings"); gui.setSize(300, 500); + // Create Sliders gui.add(angrySlider.setup("Angry", 0.0, 0.0, 1.0)); gui.add(disgustSlider.setup("Disgust", 0.0, 0.0, 1.0)); gui.add(fearSlider.setup("Fear", 0.0, 0.0, 1.0)); @@ -116,6 +124,8 @@ void Player::setupGUI(){ gui.add(audioToggle.setup("Audio", false)); + + // Set slider values to the values of the the Vec7D currentVector.angry = angrySlider; currentVector.disgust = disgustSlider; currentVector.fear = fearSlider; @@ -124,10 +134,11 @@ void Player::setupGUI(){ currentVector.sad = sadSlider; currentVector.surprise = surpriseSlider; + // Set current values to last vector lastVector = currentVector; + // Set position of GUI. float guiWidth = gui.getWidth(); - gui.setPosition(ofGetWindowWidth() - guiWidth, 0); } @@ -143,6 +154,7 @@ void Player::updateGUI(){ currentVector.sad = sadSlider; currentVector.surprise = surpriseSlider; + // If the last vector is different ot the current vector, set a new video if(currentVector != lastVector){ // Send a request resp = req.query(currentVector); diff --git a/src/Player.h b/src/Player.h index d0b6420..dd158a4 100644 --- a/src/Player.h +++ b/src/Player.h @@ -20,7 +20,6 @@ class Player { void updateVector(); void checkNewFrame(); string getFrameName(); - int getFrameIndex(); ofVideoPlayer videoPlayer; diff --git a/src/Request.h b/src/Request.h index e607f6a..4ab691d 100644 --- a/src/Request.h +++ b/src/Request.h @@ -32,7 +32,6 @@ struct VPQuery{ std::string video; std::string image; int frame; - int index; }; class Request { diff --git a/src/TSNEMap.cpp b/src/TSNEMap.cpp index a2f4131..5e4cc48 100644 --- a/src/TSNEMap.cpp +++ b/src/TSNEMap.cpp @@ -11,6 +11,7 @@ TSNEMap::TSNEMap(){ } void TSNEMap::setup(){ + // Setup objects setupNodes(); // Setup FBO fbo.allocate(ofGetWindowWidth() / 3, ofGetWindowHeight() / 3 * 2, GL_RGBA); @@ -246,10 +247,6 @@ void TSNEMap::MoveCameraToPosition(glm::vec2 position){ std::cout << "new position " << cam.getPosition() << std::endl; } -void TSNEMap::setTexture(std::string imagePath){ - image.load("images/rte-archive-football/" + imagePath); -} - void TSNEMap::keyPressed(int key) { if (key == OF_KEY_UP) { zoomLevel *= 0.9; // Zoom in diff --git a/src/TSNEMap.h b/src/TSNEMap.h index b036ef9..8c427b5 100644 --- a/src/TSNEMap.h +++ b/src/TSNEMap.h @@ -29,7 +29,6 @@ class TSNEMap{ void setup(); void draw(); void update(std::string imagePath); - void setTexture(std::string imagePath); void updateCameraProjection(); void keyPressed(int key); void setupTSNE(std::string jsonPath); diff --git a/src/ofApp.cpp b/src/ofApp.cpp index a0e4f37..5b4de0f 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -7,24 +7,42 @@ using namespace glm; void ofApp::setup(){ ofBackground(ofColor(0, 0, 0)); ofSetVerticalSync(true); + + // Setup Video Player player.setup(); + + // Setup Image Viewer imageViewer.setup(); + + // Setup TNSE & 2D Map map.setupTSNE("embeddings.json"); map.setup(); } //-------------------------------------------------------------- void ofApp::update(){ + + // Updates Video Player player.update(); + + // Gets the path to the current Image std::string imagePath = player.getFrameName(); + + // Updates the image if it is different to the current path imageViewer.update(imagePath); + + // Update the map, passing in the selected image -> checks hashmap, and moves to that new location map.update(imagePath); } //-------------------------------------------------------------- void ofApp::draw(){ + + // Drawing functions player.draw(); + imageViewer.draw(); + map.draw(); }