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