Browse Source

inital commit

master
cailean 4 months ago
commit
fbc2b295a2
  1. 91
      .gitignore
  2. 178
      .vscode/c_cpp_properties.json
  3. 72
      .vscode/launch.json
  4. 133
      .vscode/tasks.json
  5. 101
      Demo.code-workspace
  6. 71
      Demo.qbs
  7. 13
      Makefile
  8. 2
      addons.make
  9. 142
      config.make
  10. 66
      src/ImageViewer.cpp
  11. 27
      src/ImageViewer.h
  12. 152
      src/Player.cpp
  13. 62
      src/Player.h
  14. 33
      src/Request.cpp
  15. 52
      src/Request.h
  16. 137
      src/TSNEMap.cpp
  17. 40
      src/TSNEMap.h
  18. 17
      src/main.cpp
  19. 83
      src/ofApp.cpp
  20. 31
      src/ofApp.h

91
.gitignore

@ -0,0 +1,91 @@
#.gitignore is a file which makes git ignore files which should
# not go into version control in the first place
# Questions? See
# http://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files
# http://git-scm.com/docs/gitignore
###########################
# ignore generated binaries
# but not the data folder
###########################
/bin/*
!/bin/data/
#########
# general
#########
[Bb]uild/
[Oo]bj/
*.o
[Dd]ebug*/
[Rr]elease*/
*.mode*
*.app/
*.pyc
.svn/
*.log
########################
# IDE files which should
# be ignored
########################
# XCode
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
# XCode 4
*.xccheckout
xcuserdata/
# Visual Studio
*.sdf
*.opensdf
*.suo
*.pdb
*.ilk
*.aps
ipch/
# Eclipse
.metadata
local.properties
.externalToolBuilders
# Android Studio
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
##################
# operating system
##################
# Linux
*~
# KDE
.directory
.AppleDouble
# OSX
.DS_Store
*.swp
*~.nib
# Thumbnails
._*
# Windows
# Image file caches
Thumbs.db
# Folder config file
Desktop.ini
# Android
.csettings
/bin/data/

178
.vscode/c_cpp_properties.json

@ -0,0 +1,178 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1",
"${workspaceRoot}/../../../addons/ofxGui",
"${workspaceRoot}/../../../libs/openFrameworks",
"${workspaceRoot}/../../../libs/openFrameworks/3d",
"${workspaceRoot}/../../../libs/openFrameworks/app",
"${workspaceRoot}/../../../libs/openFrameworks/communication",
"${workspaceRoot}/../../../libs/openFrameworks/events",
"${workspaceRoot}/../../../libs/openFrameworks/gl",
"${workspaceRoot}/../../../libs/openFrameworks/graphics",
"${workspaceRoot}/../../../libs/openFrameworks/math",
"${workspaceRoot}/../../../libs/openFrameworks/sound",
"${workspaceRoot}/../../../libs/openFrameworks/types",
"${workspaceRoot}/../../../libs/openFrameworks/utils",
"${workspaceRoot}/../../../libs/openFrameworks/video",
"${workspaceRoot}/../../../libs/boost/include",
"${workspaceRoot}/../../../libs/cairo/include",
"${workspaceRoot}/../../../libs/curl/include",
"${workspaceRoot}/../../../libs/fmod/include",
"${workspaceRoot}/../../../libs/FreeImage/include",
"${workspaceRoot}/../../../libs/freetype/include",
"${workspaceRoot}/../../../libs/glew/include",
"${workspaceRoot}/../../../libs/glfw/include",
"${workspaceRoot}/../../../libs/glm/include",
"${workspaceRoot}/../../../libs/json/include",
"${workspaceRoot}/../../../libs/pugixml/include",
"${workspaceRoot}/../../../libs/rtAudio/include",
"${workspaceRoot}/../../../libs/tess2/include",
"${workspaceRoot}/../../../libs/uriparser/include",
"${workspaceRoot}/../../../libs/utf8/include"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "${workspaceRoot}/.vscode/browse.db",
"path": [
"/usr/include",
"/usr/local/include",
"/System/Library/Frameworks",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/",
"${workspaceRoot}/../../../libs",
"${workspaceRoot}/../../../addons",
"${workspaceRoot}/../../../libs/openFrameworks"
]
},
"intelliSenseMode": "clang-x64",
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/usr/local/bin/gcc-8",
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"/usr/include/c++/5",
"/usr/include/c++/5/backward",
"/usr/lib/gcc/x86_64-linux-gnu/5/include",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include",
"/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include",
"/usr/local/include",
"/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
"/usr/include/x86_64-linux-gnu",
"${workspaceRoot}/../../../libs/openFrameworks",
"${workspaceRoot}/../../../libs/openFrameworks/3d",
"${workspaceRoot}/../../../libs/openFrameworks/app",
"${workspaceRoot}/../../../libs/openFrameworks/communication",
"${workspaceRoot}/../../../libs/openFrameworks/events",
"${workspaceRoot}/../../../libs/openFrameworks/gl",
"${workspaceRoot}/../../../libs/openFrameworks/graphics",
"${workspaceRoot}/../../../libs/openFrameworks/math",
"${workspaceRoot}/../../../libs/openFrameworks/sound",
"${workspaceRoot}/../../../libs/openFrameworks/types",
"${workspaceRoot}/../../../libs/openFrameworks/utils",
"${workspaceRoot}/../../../libs/openFrameworks/video",
"${workspaceRoot}/../../../libs/boost/include",
"${workspaceRoot}/../../../libs/cairo/include",
"${workspaceRoot}/../../../libs/curl/include",
"${workspaceRoot}/../../../libs/fmod/include",
"${workspaceRoot}/../../../libs/FreeImage/include",
"${workspaceRoot}/../../../libs/freetype/include",
"${workspaceRoot}/../../../libs/glew/include",
"${workspaceRoot}/../../../libs/glfw/include",
"${workspaceRoot}/../../../libs/glm/include",
"${workspaceRoot}/../../../libs/json/include",
"${workspaceRoot}/../../../libs/pugixml/include",
"${workspaceRoot}/../../../libs/rtAudio/include",
"${workspaceRoot}/../../../libs/tess2/include",
"${workspaceRoot}/../../../libs/uriparser/include",
"${workspaceRoot}/../../../libs/utf8/include",
"${workspaceRoot}/../../../libs/poco/include",
"${workspaceRoot}/../../../libs/kiss/include",
"/usr/include/x86_64-linux-gnu/c++/5",
"/usr/include/pulse",
"/usr/include/cairo",
"/usr/include/gstreamer-1.0",
"/usr/include/glib-2.0",
"${workspaceRoot}",
"${workspaceRoot}/../../../addons/ofxGui/src"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "",
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}/../../../libs",
"${workspaceRoot}/../../../addons",
"${workspaceRoot}/../../../libs/openFrameworks"
]
},
"intelliSenseMode": "clang-x64",
"compilerPath": "/usr/local/bin/gcc-8",
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "Win32",
"includePath": [
"C:/msys64/mingw32/include/c++/7.4.0",
"C:/msys64/mingw32/i686-w64-mingw32/include",
"${workspaceRoot}/../../../libs",
"${workspaceRoot}/../../../addons",
"${workspaceRoot}/../../../libs/openFrameworks",
"${workspaceRoot}/../../../libs/openFrameworks/3d",
"${workspaceRoot}/../../../libs/openFrameworks/app",
"${workspaceRoot}/../../../libs/openFrameworks/communication",
"${workspaceRoot}/../../../libs/openFrameworks/events",
"${workspaceRoot}/../../../libs/openFrameworks/gl",
"${workspaceRoot}/../../../libs/openFrameworks/graphics",
"${workspaceRoot}/../../../libs/openFrameworks/math",
"${workspaceRoot}/../../../libs/openFrameworks/sound",
"${workspaceRoot}/../../../libs/openFrameworks/types",
"${workspaceRoot}/../../../libs/openFrameworks/utils",
"${workspaceRoot}/../../../libs/openFrameworks/video",
"${workspaceRoot}/../../../libs/boost/include",
"${workspaceRoot}/../../../libs/cairo/include",
"${workspaceRoot}/../../../libs/curl/include",
"${workspaceRoot}/../../../libs/fmod/include",
"${workspaceRoot}/../../../libs/FreeImage/include",
"${workspaceRoot}/../../../libs/freetype/include",
"${workspaceRoot}/../../../libs/glew/include",
"${workspaceRoot}/../../../libs/glfw/include",
"${workspaceRoot}/../../../libs/glm/include",
"${workspaceRoot}/../../../libs/json/include",
"${workspaceRoot}/../../../libs/pugixml/include",
"${workspaceRoot}/../../../libs/rtAudio/include",
"${workspaceRoot}/../../../libs/tess2/include",
"${workspaceRoot}/../../../libs/uriparser/include",
"${workspaceRoot}/../../../libs/utf8/include"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "",
"path": [
"${workspaceRoot}/../../../libs",
"${workspaceRoot}/../../../addons",
"${workspaceRoot}/../../../libs/openFrameworks"
]
},
"intelliSenseMode": "clang-x64",
"compilerPath": "C:/msys64/mingw32/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}

72
.vscode/launch.json

@ -0,0 +1,72 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"program": "${workspaceRoot}/bin/${workspaceFolderBasename}_debug"
},
"osx": {
"MIMode": "lldb",
"program": "${workspaceRoot}/bin/${workspaceFolderBasename}_debug.app/Contents/MacOS/${workspaceFolderBasename}_debug"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"program": "${workspaceRoot}/bin/${workspaceFolderBasename}_debug"
}
},
{
"name": "C++ Attach",
"type": "cppdbg",
"request": "attach",
"program": "enter program name, for example ${workspaceRoot}/a.out",
"processId": "${command:pickProcess}",
"linux": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
}
]
}

133
.vscode/tasks.json

@ -0,0 +1,133 @@
{
"version": "2.0.0",
"shell":{
"task": true
},
"tasks": [
{
"type": "shell",
"label": "Build RELEASE",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"command": "make -j -s 2>&1 && make RunRelease",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"type": "shell",
"label": "Build DEBUG",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"command": "make Debug -j -s 2>&1 || exit 1",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"type": "shell",
"label": "Clean DEBUG",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"command": "make CleanDebug",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"type": "shell",
"label": "Clean RELEASE",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"command": "make CleanRelease",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"type": "shell",
"label": "Clean ALL",
"presentation": {
"reveal": "always",
"panel": "shared"
},
"command": "make clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}

101
Demo.code-workspace

@ -0,0 +1,101 @@
{
"folders": [
{
"path": "."
},
{
"path": "${workspaceRoot}/../../../../libs/openFrameworks"
},
{
"path": "${workspaceRoot}/../../../../addons"
}
],
"settings": {
"files.associations": {
"ostream": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"format": "cpp",
"stdfloat": "cpp",
"__nullptr": "cpp"
}
}
}

71
Demo.qbs

@ -0,0 +1,71 @@
import qbs
import qbs.Process
import qbs.File
import qbs.FileInfo
import qbs.TextFile
import "../../../libs/openFrameworksCompiled/project/qtcreator/ofApp.qbs" as ofApp
Project{
property string of_root: "../../.."
ofApp {
name: { return FileInfo.baseName(sourceDirectory) }
files: [
'src/Player.cpp',
'src/Player.h',
'src/main.cpp',
'src/ofApp.cpp',
'src/ofApp.h',
]
of.addons: [
'ofxGui',
'ofxGui',
]
// additional flags for the project. the of module sets some
// flags by default to add the core libraries, search paths...
// this flags can be augmented through the following properties:
of.pkgConfigs: [] // list of additional system pkgs to include
of.includePaths: [] // include search paths
of.cFlags: [] // flags passed to the c compiler
of.cxxFlags: [] // flags passed to the c++ compiler
of.linkerFlags: [] // flags passed to the linker
of.defines: [] // defines are passed as -D to the compiler
// and can be checked with #ifdef or #if in the code
of.frameworks: [] // osx only, additional frameworks to link with the project
of.staticLibraries: [] // static libraries
of.dynamicLibraries: [] // dynamic libraries
// other flags can be set through the cpp module: http://doc.qt.io/qbs/cpp-module.html
// eg: this will enable ccache when compiling
//
// cpp.compilerWrapper: 'ccache'
Depends{
name: "cpp"
}
// common rules that parse the include search paths, core libraries...
Depends{
name: "of"
}
// dependency with the OF library
Depends{
name: "openFrameworks"
}
}
property bool makeOF: true // use makfiles to compile the OF library
// will compile OF only once for all your projects
// otherwise compiled per project with qbs
property bool precompileOfMain: false // precompile ofMain.h
// faster to recompile when including ofMain.h
// but might use a lot of space per project
references: [FileInfo.joinPaths(of_root, "/libs/openFrameworksCompiled/project/qtcreator/openFrameworks.qbs")]
}

13
Makefile

@ -0,0 +1,13 @@
# Attempt to load a config.make file.
# If none is found, project defaults in config.project.make will be used.
ifneq ($(wildcard config.make),)
include config.make
endif
# make sure the the OF_ROOT location is defined
ifndef OF_ROOT
OF_ROOT=$(realpath ../../..)
endif
# call the project makefile!
include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk

2
addons.make

@ -0,0 +1,2 @@
ofxGui
ofxGui

142
config.make

@ -0,0 +1,142 @@
################################################################################
# CONFIGURE PROJECT MAKEFILE (optional)
# This file is where we make project specific configurations.
################################################################################
################################################################################
# OF ROOT
# The location of your root openFrameworks installation
# (default) OF_ROOT = ../../..
################################################################################
OF_ROOT = ../../..
################################################################################
# PROJECT ROOT
# The location of the project - a starting place for searching for files
# (default) PROJECT_ROOT = . (this directory)
#
################################################################################
# PROJECT_ROOT = .
################################################################################
# PROJECT SPECIFIC CHECKS
# This is a project defined section to create internal makefile flags to
# conditionally enable or disable the addition of various features within
# this makefile. For instance, if you want to make changes based on whether
# GTK is installed, one might test that here and create a variable to check.
################################################################################
# None
################################################################################
# PROJECT EXTERNAL SOURCE PATHS
# These are fully qualified paths that are not within the PROJECT_ROOT folder.
# Like source folders in the PROJECT_ROOT, these paths are subject to
# exlclusion via the PROJECT_EXLCUSIONS list.
#
# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_EXTERNAL_SOURCE_PATHS =
################################################################################
# PROJECT EXCLUSIONS
# These makefiles assume that all folders in your current project directory
# and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
# to look for source code. The any folders or files that match any of the
# items in the PROJECT_EXCLUSIONS list below will be ignored.
#
# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
# string unless teh user adds a wildcard (%) operator to match subdirectories.
# GNU make only allows one wildcard for matching. The second wildcard (%) is
# treated literally.
#
# (default) PROJECT_EXCLUSIONS = (blank)
#
# Will automatically exclude the following:
#
# $(PROJECT_ROOT)/bin%
# $(PROJECT_ROOT)/obj%
# $(PROJECT_ROOT)/%.xcodeproj
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_EXCLUSIONS =
################################################################################
# PROJECT LINKER FLAGS
# These flags will be sent to the linker when compiling the executable.
#
# (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# Currently, shared libraries that are needed are copied to the
# $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
# add a runtime path to search for those shared libraries, since they aren't
# incorporated directly into the final executable application binary.
# TODO: should this be a default setting?
# PROJECT_LDFLAGS=-Wl,-rpath=./libs
################################################################################
# PROJECT DEFINES
# Create a space-delimited list of DEFINES. The list will be converted into
# CFLAGS with the "-D" flag later in the makefile.
#
# (default) PROJECT_DEFINES = (blank)
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_DEFINES =
################################################################################
# PROJECT CFLAGS
# This is a list of fully qualified CFLAGS required when compiling for this
# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
# defined in your platform specific core configuration files. These flags are
# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
#
# (default) PROJECT_CFLAGS = (blank)
#
# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
# your platform specific configuration file will be applied by default and
# further flags here may not be needed.
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_CFLAGS =
################################################################################
# PROJECT OPTIMIZATION CFLAGS
# These are lists of CFLAGS that are target-specific. While any flags could
# be conditionally added, they are usually limited to optimization flags.
# These flags are added BEFORE the PROJECT_CFLAGS.
#
# PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
#
# (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
#
# PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
#
# (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
#
# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
# file will be applied by default and further optimization flags here may not
# be needed.
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
# PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
################################################################################
# PROJECT COMPILERS
# Custom compilers can be set for CC and CXX
# (default) PROJECT_CXX = (blank)
# (default) PROJECT_CC = (blank)
# Note: Leave a leading space when adding list items with the += operator
################################################################################
# PROJECT_CXX =
# PROJECT_CC =

66
src/ImageViewer.cpp

@ -0,0 +1,66 @@
#include "ImageViewer.h"
ImageViewer::ImageViewer(){
}
void ImageViewer::setup(){
fbo.allocate(ofGetWindowWidth() / 2, ofGetWindowHeight() / 2, GL_RGBA);
}
void ImageViewer::update(string imagePath){
currentImage = imagePath;
if (currentImage != lastImage){
setImage(currentImage);
lastImage = currentImage;
}
}
void ImageViewer::draw(){
if(displayImage.isAllocated())
calcImageScalePos();
}
void ImageViewer::setImage(std::string imagePath){
if(displayImage.isAllocated())
displayImage.clear();
displayImage.load("images/rte-archive-football/" + imagePath);
}
void ImageViewer::calcImageScalePos(){
// Get the window dimensions
int windowWidth = ofGetWidth();
int windowHeight = ofGetHeight();
// Calculate the target width and height for the bottom left quadrant
int targetWidth = windowWidth / 3;
int targetHeight = windowHeight / 3;
// Calculate scaling factors to cover the entire quadrant
float scaleX = (float)targetWidth / (float)displayImage.getWidth();
float scaleY = (float)targetHeight / (float)displayImage.getHeight();
// Choose the larger scale factor to ensure the image covers the quadrant
float scale = std::max(scaleX, scaleY);
// Calculate the scaled width and height of the image
int scaledWidth = displayImage.getWidth() * scale;
int scaledHeight = displayImage.getHeight() * scale;
// Calculate the position offsets to center the image in the quadrant
int offsetX = (scaledWidth - targetWidth) / 2;
int offsetY = (scaledHeight - targetHeight) / 2;
// Begin drawing into the FBO
fbo.begin();
ofClear(0, 0, 0, 0); // Clear the FBO with a transparent color
// Draw the image, scaled and centered, into the FBO
displayImage.draw(-offsetX, -offsetY, scaledWidth, scaledHeight);
// End drawing into the FBO
fbo.end();
// Draw the FBO onto the screen at the bottom-left quadrant
fbo.draw(0, 2 * windowHeight / 3);
}

27
src/ImageViewer.h

@ -0,0 +1,27 @@
#ifndef _IMAGEVIEWER
#define _IMAGEVIEWER
#include "ofMain.h"
class ImageViewer {
public:
void setup();
void update(string imagePath);
void draw();
void setImage(std::string imageName);
void calcImageScalePos();
ofImage displayImage;
ofFbo fbo;
string currentImage;
string lastImage;
ImageViewer();
};
#endif

152
src/Player.cpp

@ -0,0 +1,152 @@
#include "Player.h"
Player::Player(){
hasVideo = false;
playerVideoIndex = 0;
req.setup("192.168.0.54", 2000, "search");
resp.filename = "fingers.mp4";
resp.frame = 50;
resp.index = 0;
}
void Player::setup(){
videoPlayer.setLoopState(OF_LOOP_NONE);
setupGUI();
int windowW = ofGetWindowWidth();
int windowH = ofGetWindowHeight();
fbo.allocate(windowW * 2 / 3, windowH, GL_RGBA);
}
void Player::update(){
if(videoPlayer.isLoaded())
hasVideo = true;
updateGUI();
videoPlayer.update();
playerCurrentFrame = videoPlayer.getCurrentFrame();
}
void Player::draw(){
if(videoPlayer.isLoaded()){
// Begin drawing into the FBO
fbo.begin();
ofClear(0, 0, 0, 0); // Clear the FBO with a transparent color
// Draw the video, scaled and centered, into the FBO
videoPlayer.draw(centerPosition.x, centerPosition.y, videoPlayer.getWidth() * std::max(fbo.getWidth() / videoPlayer.getWidth(), fbo.getHeight() / videoPlayer.getHeight()), videoPlayer.getHeight() * std::max(fbo.getWidth() / videoPlayer.getWidth(), fbo.getHeight() / videoPlayer.getHeight()));
// End drawing into the FBO
fbo.end();
// Draw the FBO onto the screen, at 1/3 from the left (i.e., right 2/3 of the screen)
fbo.draw(ofGetWidth() / 3, 0);
}
gui.draw();
}
void Player::setVideo(VPQuery query){
videoPath = query.filename;
videoPlayer.load("movies/" + videoPath);
videoPlayer.setFrame(query.frame);
setVideoPosition();
currentVideoLabel = query.filename;
currentIndexLabel = ofToString(query.index);
videoPlayer.play();
}
void Player::setVideoPosition(){
int playerW = videoPlayer.getWidth();
int playerH = videoPlayer.getHeight();
// Calculate the scaling to fit the 2/3 width and full height area
float targetWidth = fbo.getWidth();
float targetHeight = fbo.getHeight();
float scaleX = targetWidth / playerW;
float scaleY = targetHeight / playerH;
// Use the larger scaling factor to ensure coverage
float scale = std::max(scaleX, scaleY);
// Calculate scaled dimensions
int scaledWidth = playerW * scale;
int scaledHeight = playerH * scale;
// Center the video within the FBO
centerPosition = glm::vec2((targetWidth - scaledWidth) / 2, (targetHeight - scaledHeight) / 2);
}
void Player::setRandomFrame(){
int randomFrame = ofRandom(0, videoPlayer.getTotalNumFrames());
videoPlayer.setFrame(randomFrame);
}
string Player::getFrameName(){
string imagePath = resp.imagePath;
return imagePath;
}
void Player::setupGUI(){
gui.setup("Embeddings");
gui.setSize(300, 500);
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));
gui.add(happySlider.setup("Happy", 0.0, 0.0, 1.0));
gui.add(sadSlider.setup("Sad", 0.0, 0.0, 1.0));
gui.add(surpriseSlider.setup("Surprise", 0.0, 0.0, 1.0));
gui.add(neutralSlider.setup("Neutral", 0.0, 0.0, 1.0));
gui.add(currentFrameLabel.setup("Current Frame", ofToString(playerCurrentFrame)));
gui.add(currentVideoLabel.setup("Video Name", videoPath));
gui.add(currentIndexLabel.setup("Index", ofToString(playerVideoIndex)));
currentVector.angry = angrySlider;
currentVector.disgust = disgustSlider;
currentVector.fear = fearSlider;
currentVector.happy = happySlider;
currentVector.neutral = neutralSlider;
currentVector.sad = sadSlider;
currentVector.surprise = surpriseSlider;
lastVector = currentVector;
float guiWidth = gui.getWidth();
gui.setPosition(ofGetWindowWidth() - guiWidth, 0);
}
// Updates GUI with new values, and if it is different, send a POST query
void Player::updateGUI(){
currentVector.angry = angrySlider;
currentVector.disgust = disgustSlider;
currentVector.fear = fearSlider;
currentVector.happy = happySlider;
currentVector.neutral = neutralSlider;
currentVector.sad = sadSlider;
currentVector.surprise = surpriseSlider;
if(currentVector != lastVector){
// Send a request
resp = req.query(currentVector);
if(resp.frame != lastResp.frame){
setVideo(resp);
lastResp = resp;
}
lastVector = currentVector;
}
currentFrameLabel = ofToString(playerCurrentFrame);
}

62
src/Player.h

@ -0,0 +1,62 @@
#ifndef _PLAYER
#define _PLAYER
#include "ofMain.h"
#include "ofxGui.h"
#include "Request.h"
class Player {
public:
void setup();
void update();
void draw();
void setVideo(VPQuery query);
void setVideoPosition();
void setRandomFrame();
void setupGUI();
void updateGUI();
void updateVector();
void checkNewFrame();
string getFrameName();
ofVideoPlayer videoPlayer;
int playerCurrentFrame;
int playerTotalFrameNum;
int playerVideoIndex;
std::string videoPath;
bool hasVideo;
glm::vec2 centerPosition;
ofxPanel gui;
ofxFloatSlider angrySlider;
ofxFloatSlider disgustSlider;
ofxFloatSlider fearSlider;
ofxFloatSlider happySlider;
ofxFloatSlider sadSlider;
ofxFloatSlider surpriseSlider;
ofxFloatSlider neutralSlider;
ofxLabel currentFrameLabel;
ofxLabel currentVideoLabel;
ofxLabel currentIndexLabel;
Vector7D currentVector;
Vector7D lastVector;
Request req;
VPQuery resp;
VPQuery lastResp;
ofFbo fbo;
Player();
};
#endif

33
src/Request.cpp

@ -0,0 +1,33 @@
#include "Request.h"
Request::Request(){
}
void Request::setup(std::string ip, int port, std::string page){
request.method = ofHttpRequest::POST;
request.url = "http://" + ip + ":" + ofToString(port) + "/" + page;
request.headers["Content-Type"] = "application/json";
}
VPQuery Request::query(Vector7D input){
request.body = "{\"vector\": [" +
ofToString(input.angry) + "," +
ofToString(input.disgust) + "," +
ofToString(input.fear) + "," +
ofToString(input.happy) + "," +
ofToString(input.sad) + "," +
ofToString(input.surprise) + "," +
ofToString(input.neutral) + "]}";
auto response = http.handleRequest(request);
jsonResponse = ofJson::parse(response.data.getText());
VPQuery queryResponse;
queryResponse.filename = jsonResponse["filename"];
queryResponse.imagePath = jsonResponse["imagePath"];
queryResponse.frame = ofToInt(jsonResponse["frame"]) + 10;
queryResponse.index = jsonResponse["index"];
return queryResponse;
}

52
src/Request.h

@ -0,0 +1,52 @@
#ifndef _REQUEST
#define _REQUEST
#include "ofMain.h"
// Embeddings structure
struct Vector7D{
float angry;
float disgust;
float fear;
float happy;
float sad;
float surprise;
float neutral;
bool operator!=(const Vector7D &other) const {
return angry != other.angry ||
disgust != other.disgust ||
fear != other.fear ||
happy != other.happy ||
sad != other.sad ||
surprise != other.surprise ||
neutral != other.neutral;
}
};
// JSON -> Struct
struct VPQuery{
std::string filename;
std::string imagePath;
int frame;
int index;
};
class Request {
public:
void setup(std::string ip, int port, std::string page);
VPQuery query(Vector7D input);
ofHttpRequest request;
ofURLFileLoader http;
ofJson jsonResponse;
Request();
};
#endif

137
src/TSNEMap.cpp

@ -0,0 +1,137 @@
#include "TSNEMap.h"
TSNEMap::TSNEMap(){
image.load("images/happy.jpeg");
zoomLevel = 1.0;
}
void TSNEMap::setup(){
for (int i = 0; i < 5; ++i) {
ofImage img;
ImageObject obj;
ofPlanePrimitive plane;
img.load("images/happy.png");
int imageW = image.getWidth();
int imageH = image.getHeight();
// Maximum allowed dimensions for the plane
int maxWidth = 100;
int maxHeight = 100;
// Calculate aspect ratio
float aspectRatio = (float)imageW / (float)imageH;
// Determine plane dimensions based on aspect ratio and constraints
float planeW, planeH;
if (aspectRatio > (float)maxWidth / maxHeight) {
// Image is wider relative to the max constraints
planeW = maxWidth;
planeH = maxWidth / aspectRatio;
} else {
// Image is taller relative to the max constraints
planeH = maxHeight;
planeW = maxHeight * aspectRatio;
}
// Ensure that dimensions do not exceed constraints
if (planeH > maxHeight) {
planeH = maxHeight;
planeW = maxHeight * aspectRatio;
}
if (planeW > maxWidth) {
planeW = maxWidth;
planeH = maxWidth / aspectRatio;
}
plane.set(planeW, planeH); // Random width and height
plane.setPosition(ofRandom(-200, 200), ofRandom(-200, 200), 0); // Random position on XZ plane
plane.setResolution(2, 2);
plane.mapTexCoordsFromTexture(img.getTexture());
obj.texture = img;
obj.plane = plane;
obj.speedX = ofRandom(1, 5); // Random speed
obj.speedY = ofRandom(1, 5); // Random speed
obj.amplitudeX = ofRandom(0.01, 0.02); // Random amplitude
obj.amplitudeY = ofRandom(0.01, 0.02); // Random amplitude
obj.phaseX = ofRandom(0, TWO_PI); // Random phase
obj.phaseY = ofRandom(0, TWO_PI); // Random phase
objects.push_back(obj);
}
// Setup FBO
fbo.allocate(ofGetWindowWidth() / 3, ofGetWindowHeight() / 3 * 2, GL_RGBA);
cam.removeAllInteractions();
cam.addInteraction(ofEasyCam::TRANSFORM_TRANSLATE_XY,OF_MOUSE_BUTTON_LEFT);
cam.enableOrtho();
// Setup top-down orthographic camera
cam.setNearClip(-1000000);
cam.setFarClip(1000000);
}
void TSNEMap::update(){
if (!image.isAllocated()){
ofLogError() << "Image not found";
}
// Update oscillation
float time = ofGetElapsedTimef();
for (size_t i = 0; i < objects.size(); ++i) {
auto& object = objects[i];
float offsetX = object.amplitudeX * sin(object.speedX * time );
float offsetY = object.amplitudeY * sin(object.speedY * time );
object.plane.setPosition(object.plane.getPosition().x + offsetX, object.plane.getPosition().y + offsetY, 0);
}
}
void TSNEMap::draw(){
float time = ofGetElapsedTimef();
// Render the top-down view into the FBO
fbo.begin();
ofClear(0, 0, 0, 0); // Clear the FBO
cam.begin();
// ofEnableDepthTest();
// Render the planes
for (auto& object : objects) {
ofPushMatrix();
object.texture.getTexture().bind();
ofFill();
object.plane.draw(); // Draw the wireframe for visibility
object.texture.getTexture().unbind();;
ofPopMatrix();
}
// ofDisableDepthTest();
cam.end();
fbo.end();
// Draw the FBO to the screen
fbo.draw(0, 0, ofGetWindowWidth() / 3, ofGetWindowHeight() / 3 * 2);
}
void TSNEMap::setTexture(std::string imagePath){
image.load("images/rte-archive-football/" + imagePath);
}
void TSNEMap::keyPressed(int key) {
if (key == OF_KEY_UP) {
zoomLevel *= 0.9; // Zoom in
cam.setScale(zoomLevel, zoomLevel, zoomLevel);
} else if (key == OF_KEY_DOWN) {
zoomLevel *= 1.1; // Zoom out
cam.setScale(zoomLevel, zoomLevel, zoomLevel);
}
}

40
src/TSNEMap.h

@ -0,0 +1,40 @@
#ifndef _TSNEMAP
#define _TSNEMAP
#include "ofMain.h"
struct ImageObject {
float speedX;
float speedY;
float amplitudeX;
float amplitudeY;
float phaseX;
float phaseY;
ofPlanePrimitive plane;
ofImage texture;
};
class TSNEMap{
public:
void setup();
void draw();
void update();
void setTexture(std::string imagePath);
void updateCameraProjection();
void keyPressed(int key);
ofFbo fbo;
vector<ofPlanePrimitive> planes;
vector<ImageObject> objects;
ofEasyCam cam;
ofTexture demoTex;
ofImage image;
float zoomLevel;
TSNEMap();
};
#endif

17
src/main.cpp

@ -0,0 +1,17 @@
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
//Use ofGLFWWindowSettings for more options like multi-monitor fullscreen
ofGLWindowSettings settings;
settings.setSize(1920, 1080);
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
auto window = ofCreateWindow(settings);
ofRunApp(window, make_shared<ofApp>());
ofRunMainLoop();
}

83
src/ofApp.cpp

@ -0,0 +1,83 @@
#include "ofApp.h"
//--------------------------------------------------------------
using namespace glm;
void ofApp::setup(){
ofBackground(ofColor(0, 0, 0));
ofSetVerticalSync(true);
player.setup();
imageViewer.setup();
map.setup();
}
//--------------------------------------------------------------
void ofApp::update(){
player.update();
std::string imagePath = player.getFrameName();
imageViewer.update(imagePath);
map.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
player.draw();
imageViewer.draw();
map.draw();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
map.keyPressed(key);
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}

31
src/ofApp.h

@ -0,0 +1,31 @@
#pragma once
#include "ofMain.h"
#include "Player.h"
#include "Request.h"
#include "ImageViewer.h"
#include "TSNEMap.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
private:
Player player;
ImageViewer imageViewer;
TSNEMap map;
};
Loading…
Cancel
Save