Browse Source

comments added

master
cailean 2 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(){
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);

1
src/Player.h

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

1
src/Request.h

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

5
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

1
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);

18
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();
}

Loading…
Cancel
Save