You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.5 KiB
70 lines
1.5 KiB
5 months ago
|
#include "Map.h"
|
||
|
|
||
|
Map::Map(){
|
||
|
|
||
|
}
|
||
|
|
||
|
void Map::Setup(){
|
||
|
ofDisableArbTex();
|
||
|
isDebug = true;
|
||
|
|
||
|
json_embeddings = ofLoadJson(jsonPath);
|
||
|
if(!json_embeddings.is_array()){
|
||
|
ofLogError() << "JSON is not an array";
|
||
|
return;
|
||
|
} else {
|
||
|
std::cout << "JSON LOADED" << std::endl;
|
||
|
SetupTSNE();
|
||
|
}
|
||
|
|
||
|
mapFbo.allocate(ofGetWindowWidth(), ofGetWindowHeight(), GL_RGBA);
|
||
|
}
|
||
|
|
||
|
void Map::Update(){
|
||
|
|
||
|
}
|
||
|
|
||
|
void Map::Draw(){
|
||
|
|
||
|
}
|
||
|
|
||
|
void Map::SetupNodes(){
|
||
|
|
||
|
}
|
||
|
|
||
|
void Map::SetupTSNE(){
|
||
|
for (const auto& entry: json_embeddings) {
|
||
|
if (entry.contains("vector") && entry["vector"].is_array()) {
|
||
|
Node n;
|
||
|
n.foldername = entry["folder"];
|
||
|
n.image_path = entry["image"];
|
||
|
n.isLost = entry["lost"].get<int>();
|
||
|
|
||
|
std::vector<float> emb;
|
||
|
|
||
|
for (const auto& value: entry["vector"]){
|
||
|
if(value.is_number()){
|
||
|
emb.push_back(value.get<float>());
|
||
|
} else {
|
||
|
ofLogError() << "Vector value is not a number";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
n.emotion_vector = emb;
|
||
|
|
||
|
nodes.push_back(n);
|
||
|
embeddings.push_back(emb);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
std::cout << nodes.size() << std::endl;
|
||
|
std::cout << embeddings.size() << std::endl;
|
||
|
points = tsne.run(embeddings, dims, perplexity, theta, normalise, runManually);
|
||
|
|
||
|
for (size_t i = 0; i < points.size(); i++){
|
||
|
const auto& vec = points[i];
|
||
|
auto& n = nodes[i];
|
||
|
n.position = glm::vec3(vec[0], vec[1], vec[2]);
|
||
|
}
|
||
|
|
||
|
}
|