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