From 3ce5ca0c1409ef1d2eaecab012261beee922c8a4 Mon Sep 17 00:00:00 2001 From: cailean Date: Mon, 7 Oct 2024 14:55:57 +0100 Subject: [PATCH] update frame when is_active --- src/Request.cpp | 1 - src/Server.cpp | 7 +++++-- src/ofApp.cpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Request.cpp b/src/Request.cpp index 43b3705..96900c4 100644 --- a/src/Request.cpp +++ b/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 */ VPResp Request::query(Vector7D& in){ - std::cout << "Sending Request to HTTP Server" << std::endl; VPResp vp_resp; try { req.body = "{\"vector\": [" + diff --git a/src/Server.cpp b/src/Server.cpp index 61fc8b9..be0e25c 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -50,7 +50,7 @@ void Server::addOrUpdateClient(int client_id, float value, const std::string& ip void Server::updateEmbedding(){ for(const auto& c : clients){ 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){ case 0: embedding.angry = val; @@ -72,6 +72,9 @@ void Server::updateEmbedding(){ break; case 6: 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; } } @@ -91,7 +94,7 @@ void Server::printClients(){ /* check if the controllers are in use */ 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 previous_embedding = embedding; // Update the previous embedding to the current one is_active = true; diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 665395b..9a20bf9 100644 --- a/src/ofApp.cpp +++ b/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 */ + player.SetFrame(server->vp_resp.image); player.Update(img, server->is_active); /* Run Models, and set pixels */