Browse Source

update frame when is_active

tsns-map
cailean 3 months ago
parent
commit
3ce5ca0c14
  1. 1
      src/Request.cpp
  2. 7
      src/Server.cpp
  3. 1
      src/ofApp.cpp

1
src/Request.cpp

@ -11,7 +11,6 @@ void Request::setup(std::string ip, int port, std::string page){
/* send a request to vp_server & return frame/video/folder */ /* send a request to vp_server & return frame/video/folder */
VPResp Request::query(Vector7D& in){ VPResp Request::query(Vector7D& in){
std::cout << "Sending Request to HTTP Server" << std::endl;
VPResp vp_resp; VPResp vp_resp;
try { try {
req.body = "{\"vector\": [" + req.body = "{\"vector\": [" +

7
src/Server.cpp

@ -50,7 +50,7 @@ void Server::addOrUpdateClient(int client_id, float value, const std::string& ip
void Server::updateEmbedding(){ void Server::updateEmbedding(){
for(const auto& c : clients){ for(const auto& c : clients){
const ClientInfo& info = c.second; const ClientInfo& info = c.second;
float val = std::round(info.value * 1000.0f) / 1000.0f; float val = (std::round(info.value * 1000.0f) / 1000.0f) / 100.0f;
switch(c.first){ switch(c.first){
case 0: case 0:
embedding.angry = val; embedding.angry = val;
@ -72,6 +72,9 @@ void Server::updateEmbedding(){
break; break;
case 6: case 6:
embedding.neutral = val; embedding.neutral = val;
embedding.fear = ofRandom(0.1, 0.6);
embedding.angry = ofRandom(0.01, 0.99);
embedding.happy = ofRandom(0.01, 0.99);
break; break;
} }
} }
@ -91,7 +94,7 @@ void Server::printClients(){
/* check if the controllers are in use */ /* check if the controllers are in use */
void Server::checkActivity(){ void Server::checkActivity(){
if (previous_embedding != embedding) { // Check if embedding has changed if (previous_embedding.neutral != embedding.neutral) { // Check if embedding has changed
last_change_time = std::chrono::steady_clock::now(); // Reset the timer if there is a change last_change_time = std::chrono::steady_clock::now(); // Reset the timer if there is a change
previous_embedding = embedding; // Update the previous embedding to the current one previous_embedding = embedding; // Update the previous embedding to the current one
is_active = true; is_active = true;

1
src/ofApp.cpp

@ -93,6 +93,7 @@ void ofApp::update(){
} }
/* Setup model input using ofImage, allocated fbo, checks if a frame or video_frme should be drawn to the screen */ /* Setup model input using ofImage, allocated fbo, checks if a frame or video_frme should be drawn to the screen */
player.SetFrame(server->vp_resp.image);
player.Update(img, server->is_active); player.Update(img, server->is_active);
/* Run Models, and set pixels */ /* Run Models, and set pixels */

Loading…
Cancel
Save