Browse Source

comments added

master
cailean 4 months ago
parent
commit
a91caa97d9
  1. 32
      src/Player.cpp
  2. 1
      src/Player.h
  3. 1
      src/Request.h
  4. 5
      src/TSNEMap.cpp
  5. 1
      src/TSNEMap.h
  6. 18
      src/ofApp.cpp

32
src/Player.cpp

@ -2,9 +2,11 @@
Player::Player(){ Player::Player(){
hasVideo = false; hasVideo = false;
playerVideoIndex = 0;
// Set IP, Port, and POST
req.setup("192.168.0.53", 2000, "search"); req.setup("192.168.0.53", 2000, "search");
// Initial values
resp.folder = "fingers.mp4"; resp.folder = "fingers.mp4";
resp.video = "movies/fingers.mp4"; resp.video = "movies/fingers.mp4";
resp.image = "images/happy.png"; resp.image = "images/happy.png";
@ -12,12 +14,15 @@ Player::Player(){
} }
void Player::setup(){ void Player::setup(){
// Loop state
videoPlayer.setLoopState(OF_LOOP_NONE); videoPlayer.setLoopState(OF_LOOP_NONE);
setupGUI(); setupGUI();
int windowW = ofGetWindowWidth(); int windowW = ofGetWindowWidth();
int windowH = ofGetWindowHeight(); int windowH = ofGetWindowHeight();
// Sets window size
fbo.allocate(windowW * 2 / 3, windowH, GL_RGBA); fbo.allocate(windowW * 2 / 3, windowH, GL_RGBA);
} }
@ -49,14 +54,16 @@ void Player::draw(){
} }
void Player::setVideo(VPQuery query){ void Player::setVideo(VPQuery query){
// Set video path
videoPath = query.video; videoPath = query.video;
videoPlayer.load(videoPath); videoPlayer.load(videoPath);
videoPlayer.setFrame(query.frame); videoPlayer.setFrame(query.frame);
setVideoPosition();
// Center video
setVideoPosition();
currentVideoLabel = query.folder; currentVideoLabel = query.folder;
// Play Video
videoPlayer.play(); videoPlayer.play();
} }
@ -83,26 +90,27 @@ void Player::setVideoPosition(){
} }
void Player::setRandomFrame(){ void Player::setRandomFrame(){
// Sets a random frame in the active video
int randomFrame = ofRandom(0, videoPlayer.getTotalNumFrames()); int randomFrame = ofRandom(0, videoPlayer.getTotalNumFrames());
videoPlayer.setFrame(randomFrame); videoPlayer.setFrame(randomFrame);
} }
string Player::getFrameName(){ string Player::getFrameName(){
// Returns current frame name
string imagePath = resp.image; string imagePath = resp.image;
return imagePath; return imagePath;
} }
int Player::getFrameIndex(){
return resp.index;
}
void Player::setupGUI(){ void Player::setupGUI(){
gui.setup("Embeddings");
// Setting up GUI
gui.setup("Embeddings");
gui.setSize(300, 500); gui.setSize(300, 500);
// Create Sliders
gui.add(angrySlider.setup("Angry", 0.0, 0.0, 1.0)); gui.add(angrySlider.setup("Angry", 0.0, 0.0, 1.0));
gui.add(disgustSlider.setup("Disgust", 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)); gui.add(fearSlider.setup("Fear", 0.0, 0.0, 1.0));
@ -116,6 +124,8 @@ void Player::setupGUI(){
gui.add(audioToggle.setup("Audio", false)); gui.add(audioToggle.setup("Audio", false));
// Set slider values to the values of the the Vec7D
currentVector.angry = angrySlider; currentVector.angry = angrySlider;
currentVector.disgust = disgustSlider; currentVector.disgust = disgustSlider;
currentVector.fear = fearSlider; currentVector.fear = fearSlider;
@ -124,10 +134,11 @@ void Player::setupGUI(){
currentVector.sad = sadSlider; currentVector.sad = sadSlider;
currentVector.surprise = surpriseSlider; currentVector.surprise = surpriseSlider;
// Set current values to last vector
lastVector = currentVector; lastVector = currentVector;
// Set position of GUI.
float guiWidth = gui.getWidth(); float guiWidth = gui.getWidth();
gui.setPosition(ofGetWindowWidth() - guiWidth, 0); gui.setPosition(ofGetWindowWidth() - guiWidth, 0);
} }
@ -143,6 +154,7 @@ void Player::updateGUI(){
currentVector.sad = sadSlider; currentVector.sad = sadSlider;
currentVector.surprise = surpriseSlider; currentVector.surprise = surpriseSlider;
// If the last vector is different ot the current vector, set a new video
if(currentVector != lastVector){ if(currentVector != lastVector){
// Send a request // Send a request
resp = req.query(currentVector); resp = req.query(currentVector);

1
src/Player.h

@ -20,7 +20,6 @@ class Player {
void updateVector(); void updateVector();
void checkNewFrame(); void checkNewFrame();
string getFrameName(); string getFrameName();
int getFrameIndex();
ofVideoPlayer videoPlayer; ofVideoPlayer videoPlayer;

1
src/Request.h

@ -32,7 +32,6 @@ struct VPQuery{
std::string video; std::string video;
std::string image; std::string image;
int frame; int frame;
int index;
}; };
class Request { class Request {

5
src/TSNEMap.cpp

@ -11,6 +11,7 @@ TSNEMap::TSNEMap(){
} }
void TSNEMap::setup(){ void TSNEMap::setup(){
// Setup objects
setupNodes(); setupNodes();
// Setup FBO // Setup FBO
fbo.allocate(ofGetWindowWidth() / 3, ofGetWindowHeight() / 3 * 2, GL_RGBA); 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; 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) { void TSNEMap::keyPressed(int key) {
if (key == OF_KEY_UP) { if (key == OF_KEY_UP) {
zoomLevel *= 0.9; // Zoom in zoomLevel *= 0.9; // Zoom in

1
src/TSNEMap.h

@ -29,7 +29,6 @@ class TSNEMap{
void setup(); void setup();
void draw(); void draw();
void update(std::string imagePath); void update(std::string imagePath);
void setTexture(std::string imagePath);
void updateCameraProjection(); void updateCameraProjection();
void keyPressed(int key); void keyPressed(int key);
void setupTSNE(std::string jsonPath); void setupTSNE(std::string jsonPath);

18
src/ofApp.cpp

@ -7,24 +7,42 @@ using namespace glm;
void ofApp::setup(){ void ofApp::setup(){
ofBackground(ofColor(0, 0, 0)); ofBackground(ofColor(0, 0, 0));
ofSetVerticalSync(true); ofSetVerticalSync(true);
// Setup Video Player
player.setup(); player.setup();
// Setup Image Viewer
imageViewer.setup(); imageViewer.setup();
// Setup TNSE & 2D Map
map.setupTSNE("embeddings.json"); map.setupTSNE("embeddings.json");
map.setup(); map.setup();
} }
//-------------------------------------------------------------- //--------------------------------------------------------------
void ofApp::update(){ void ofApp::update(){
// Updates Video Player
player.update(); player.update();
// Gets the path to the current Image
std::string imagePath = player.getFrameName(); std::string imagePath = player.getFrameName();
// Updates the image if it is different to the current path
imageViewer.update(imagePath); imageViewer.update(imagePath);
// Update the map, passing in the selected image -> checks hashmap, and moves to that new location
map.update(imagePath); map.update(imagePath);
} }
//-------------------------------------------------------------- //--------------------------------------------------------------
void ofApp::draw(){ void ofApp::draw(){
// Drawing functions
player.draw(); player.draw();
imageViewer.draw(); imageViewer.draw();
map.draw(); map.draw();
} }

Loading…
Cancel
Save