Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Kinect manager and Telepresence mode #25

Merged
merged 34 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c73d99b
add newer, simplified kinect manager code
jdub233 Dec 27, 2024
e526617
switch the app manager to simple
jdub233 Dec 28, 2024
d878dec
switch shape io managers
jdub233 Dec 28, 2024
26ccd97
use ofImage for image resizing
jdub233 Dec 28, 2024
0732d0c
initial kinect hand wavy
jdub233 Dec 28, 2024
8b93d07
:pencil: add commentary
jdub233 Dec 28, 2024
fa49a2a
:bug: patch bug where width was used twice
jdub233 Dec 28, 2024
d69140e
adapt wave contours to use the simple kinect manager
jdub233 Dec 28, 2024
1259dd1
get the ofShortPixels depth data and cast it
jdub233 Dec 28, 2024
38226c9
Merge pull request #24 from mitmedialab/wave-contours-kinect-simple
jdub233 Dec 28, 2024
ef0266b
add a blur to the depth data
jdub233 Dec 28, 2024
b7c4d3c
add telepresence app files
jdub233 Dec 29, 2024
2bd1311
add camera references
jdub233 Dec 29, 2024
e3361fd
add telepresence to app manager
jdub233 Dec 29, 2024
9f1f809
:fire: remove unused function
jdub233 Dec 29, 2024
9b0f757
spacing fix
jdub233 Dec 29, 2024
2d19c21
remove ofImage scaler from transform io manager
jdub233 Dec 29, 2024
40d0c54
Merge pull request #26 from mitmedialab/fix-escher-mode
jdub233 Dec 29, 2024
accaee4
use vectors
jdub233 Dec 30, 2024
27ef243
:pencil: add additional comments
jdub233 Dec 30, 2024
5b01b1a
enhance raindrop
jdub233 Dec 30, 2024
b9433fd
add keyboard control for the rainfall rate
jdub233 Dec 30, 2024
95e4754
add text to report the current rain level
jdub233 Dec 31, 2024
2dd069e
:fire: remove unused
jdub233 Dec 31, 2024
c9bf233
:mute: remove logging
jdub233 Dec 31, 2024
7a19976
:pencil: adjust comment
jdub233 Dec 31, 2024
3e0f92d
Merge pull request #27 from mitmedialab/wave-contour-improvements
jdub233 Dec 31, 2024
8614281
uses separate vector to track app order
jdub233 Dec 31, 2024
d400f5d
Merge pull request #28 from mitmedialab/add-app-ordering
jdub233 Jan 1, 2025
ae4facc
add an open source true type font
jdub233 Jan 2, 2025
fdce5fb
:sparkles: add large graphical buttons
jdub233 Jan 2, 2025
7ed2e7b
move and minimize the ofxgui panel
jdub233 Jan 2, 2025
ba2b82b
change vertical spacing
jdub233 Jan 2, 2025
56d2740
Merge pull request #29 from mitmedialab/graphical-buttons
jdub233 Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bin/data/SourceSans3-Regular.ttf
Binary file not shown.
12 changes: 12 additions & 0 deletions neoForm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
B006626C26FF99AB717C7CD4 /* utf8_mosq.c in Sources */ = {isa = PBXBuildFile; fileRef = D1822FF66A31138F103D3C2F /* utf8_mosq.c */; };
B266578FC55D23BFEBC042E7 /* ofxGuiGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ECF8674C7975F1063C5E30CA /* ofxGuiGroup.cpp */; };
B56FE57CC35806596D38118C /* ofxSliderGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 802251BAF1B35B1D67B32FD0 /* ofxSliderGroup.cpp */; };
B916F1112D1F503800BC378D /* kinectManagerSimple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B916F10F2D1F503800BC378D /* kinectManagerSimple.cpp */; };
B916F1142D20C87A00BC378D /* Telepresence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B916F1132D20C87A00BC378D /* Telepresence.cpp */; };
B917C91A2D0F882700F26C4C /* AmbientWave.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B917C9182D0F882700F26C4C /* AmbientWave.cpp */; };
B917C91D2D0F8E3400F26C4C /* TransitionApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B917C91B2D0F8E3300F26C4C /* TransitionApp.cpp */; };
B951ED692CEA6F6E00C74190 /* WaveModeContours.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B951ED652CEA6F6E00C74190 /* WaveModeContours.cpp */; };
Expand Down Expand Up @@ -572,6 +574,10 @@
B88A80AA34B79BD6DA9253DE /* sse_utils.hpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = sse_utils.hpp; path = ../../../addons/ofxOpenCv/libs/opencv/include/opencv4/opencv2/core/sse_utils.hpp; sourceTree = SOURCE_ROOT; };
B8A2CBF3E24E6E5026B13A90 /* ofxBase3DVideo.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = ofxBase3DVideo.h; path = ../../../addons/ofxKinect/src/ofxBase3DVideo.h; sourceTree = SOURCE_ROOT; };
B8F39F6EBA0607ECB7D18D89 /* handle_disconnect.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; name = handle_disconnect.c; path = "../../../addons/ofxMQTT-1.5.0/libs/mosquitto/src/handle_disconnect.c"; sourceTree = SOURCE_ROOT; };
B916F10F2D1F503800BC378D /* kinectManagerSimple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = kinectManagerSimple.cpp; path = KinectManager/kinectManagerSimple.cpp; sourceTree = "<group>"; };
B916F1102D1F503800BC378D /* KinectManagerSimple.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = KinectManagerSimple.hpp; path = KinectManager/KinectManagerSimple.hpp; sourceTree = "<group>"; };
B916F1122D20C87A00BC378D /* Telepresence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Telepresence.hpp; path = Applications/Telepresence.hpp; sourceTree = "<group>"; };
B916F1132D20C87A00BC378D /* Telepresence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Telepresence.cpp; path = Applications/Telepresence.cpp; sourceTree = "<group>"; };
B917C9182D0F882700F26C4C /* AmbientWave.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AmbientWave.cpp; path = Applications/AmbientWave.cpp; sourceTree = "<group>"; };
B917C9192D0F882700F26C4C /* AmbientWave.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = AmbientWave.hpp; path = Applications/AmbientWave.hpp; sourceTree = "<group>"; };
B917C91B2D0F8E3300F26C4C /* TransitionApp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TransitionApp.cpp; path = Applications/TransitionApp.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1711,6 +1717,8 @@
371A3F038DAEE97357696076 /* MqttTransmissionApp.cpp */,
9173510537C7D6FE1E419118 /* SinglePinDebug.hpp */,
1EBB8A7F45CEE5C6E85F5CCA /* SinglePinDebug.cpp */,
B916F1122D20C87A00BC378D /* Telepresence.hpp */,
B916F1132D20C87A00BC378D /* Telepresence.cpp */,
AE527AF4F7B13F64D57C5A79 /* VideoPlayerApp.hpp */,
F4FC5A5BDD199FB703850D0B /* VideoPlayerApp.cpp */,
B951ED662CEA6F6E00C74190 /* WaveModeContours.hpp */,
Expand Down Expand Up @@ -1855,6 +1863,8 @@
908777B64CF600EA529CC7B2 /* KinectManager */ = {
isa = PBXGroup;
children = (
B916F10F2D1F503800BC378D /* kinectManagerSimple.cpp */,
B916F1102D1F503800BC378D /* KinectManagerSimple.hpp */,
9539AAE52CF78FE5E2AF134B /* KinectManager.cpp */,
5193EDEA22E0D8246414432A /* KinectTracker.cpp */,
4A4E9C4F8DC15EE848455F2E /* KinectManager.hpp */,
Expand Down Expand Up @@ -2903,6 +2913,7 @@
1985F508DABADFBFD7EE6A21 /* thread_mosq.c in Sources */,
1F0F9FBF69381509F6969127 /* time_mosq.c in Sources */,
F527E399D8A82479A7082187 /* tls_mosq.c in Sources */,
B916F1142D20C87A00BC378D /* Telepresence.cpp in Sources */,
B006626C26FF99AB717C7CD4 /* utf8_mosq.c in Sources */,
549DA215810C4915DA94ED9F /* util_mosq.c in Sources */,
BCC0588F6EE7A6B94548C546 /* util_topic.c in Sources */,
Expand All @@ -2919,6 +2930,7 @@
169D3C72FDE6C5590A1616F5 /* ofxCvFloatImage.cpp in Sources */,
FB09C6B2A1DA0EA217240CB8 /* ofxCvGrayscaleImage.cpp in Sources */,
E212C821D1064B92DD953A42 /* ofxCvHaarFinder.cpp in Sources */,
B916F1112D1F503800BC378D /* kinectManagerSimple.cpp in Sources */,
63020F16C7E8DED980111241 /* ofxCvImage.cpp in Sources */,
D3301F6A0B43BB293ED97C1D /* ofxCvShortImage.cpp in Sources */,
933A2227713C720CEFF80FD9 /* tinyxml.cpp in Sources */,
Expand Down
134 changes: 104 additions & 30 deletions src/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void AppManager::setup() {
// kinectManager = new KinectManager();
// Depth thresholds for the kinect are set here.

kinectManager = new KinectManager(255, 90, 20);
kinectManager = new KinectManagerSimple();

// zero timeOfLastUpdate tracker
timeOfLastUpdate = elapsedTimeInSeconds();
Expand Down Expand Up @@ -58,6 +58,11 @@ void AppManager::setup() {

kinectHandWavy = new KinectHandWavy(m_serialShapeIOManager, kinectManager);
applications["kinectHandWavy"] = kinectHandWavy;

// Telepresence mode takes 16 bit thresholding values as parameters here.
telepresence = new Telepresence(m_serialShapeIOManager, kinectManager,
255 * 256, 140 * 256, cam);
applications["telepresence"] = telepresence;

equationMode = new EquationMode(m_serialShapeIOManager);
applications["equationMode"] = equationMode;
Expand All @@ -71,28 +76,61 @@ void AppManager::setup() {
ambientWave = new AmbientWave(m_serialShapeIOManager);
applications["AmbientWave"] = ambientWave;

// Set up the order of the applications in the order vector
applicationOrder.push_back("videoPlayer");
applicationOrder.push_back("waveModeContours");
applicationOrder.push_back("equationMode");
applicationOrder.push_back("telepresence");
applicationOrder.push_back("kinectHandWavy");
applicationOrder.push_back("AmbientWave");
applicationOrder.push_back("singlePinDebug");
applicationOrder.push_back("axisChecker");
applicationOrder.push_back("mqttTransmission");

// innitialize GUI
gui.setup("modes:");
gui.setPosition(5, 35);
gui.setPosition(5, 20);

// IMPORTANT: ofxGui uses raw pointers to ofxButton, so an automatic resize
// of modeButtons will invalidate all existing pointers stored in gui.
// DO NOT .push_back MORE THAN applications.size()!!!!
modeButtons.reserve(applications.size());

for (map<string, Application *>::iterator iter = applications.begin(); iter != applications.end(); iter++) {
Application *app = iter->second;

modeButtons.push_back(ofxButton());
modeNames.push_back(iter->first);
auto p_button = modeButtons.back().setup(app->getName());
gui.add(p_button);

// shape display heights, if they are accessible
}

int appIndex = 1; // Initialize an index for iteration

// Iterate over the applicationOrder vector and add the corresponding app to the GUI
for (const auto& appName : applicationOrder) {
Application *app = applications[appName];

modeButtons.push_back(ofxButton());
modeNames.push_back(appName);

// Construct the new button name with the index prepended
std::string buttonName = std::to_string(appIndex) + ": " + app->getName();
auto p_button = modeButtons.back().setup(buttonName);
gui.add(p_button);

appIndex++;
}

// Collapse the GUI panel for now to make room for the new graphical buttons.
gui.minimize();

// set default application
setCurrentApplication("mqttTransmission");

// *** Rectangular button setup ***
// Load a font for the button text.
ofTrueTypeFont::setGlobalDpi(72);
displayFont20.load("SourceSans3-Regular.ttf", 20);

// Set up the buttons by creating an ofRectangle for each application
for (int i = 0; i < applicationOrder.size(); i++){
ofRectangle button;
button.set(20, 60 + 65*i, 240, 50);
applicationButtons.push_back(button);
}

}

// initialize the shape display and set up shape display helper objects
Expand Down Expand Up @@ -229,7 +267,7 @@ void AppManager::draw() {

// draw text
int menuLeftCoordinate = 21;
int menuHeight = 350;
int menuHeight = 680;
string title = currentApplication->getName() + (showDebugGui ? " - Debug" : "");
ofDrawBitmapString(title, menuLeftCoordinate, menuHeight);
menuHeight += 30;
Expand All @@ -245,12 +283,45 @@ void AppManager::draw() {
menuHeight += 30;

// if there isn't already a debug gui, draw some more information
if (!showDebugGui || currentApplication == applications["water"] || currentApplication == applications["stretchy"]) {
if (!showDebugGui || currentApplication == applications["waveModeContours"] || currentApplication == applications["stretchy"]) {
ofDrawBitmapString(currentApplication->appInstructionsText(),menuLeftCoordinate, menuHeight);
menuHeight += 20;
}

gui.draw();

// Draw the rectangular buttons for each application.
for (int i = 0; i < applicationButtons.size(); i++){
if (applications[applicationOrder[i]] == currentApplication){
// Green for the current application
ofSetColor(ofColor::seaGreen);
} else if (applicationSwitchBlocked && applications[applicationOrder[i]] == applications[lastSelectedApplicationName]){
// Dark green for the target application during the transition, so that there is immediate button feedback.
ofSetColor(ofColor::darkGreen);
} else {
// Dark blue for the unselected applications.
ofSetColor(ofColor::midnightBlue);
}
// Draw a rounded rectangle for the application button with a 20 pixel radius.
ofDrawRectRounded(applicationButtons[i], 20);

// Make a stroke around the current application button
if (applications[applicationOrder[i]] == currentApplication){
ofSetColor(ofColor::white);
ofNoFill();
ofSetLineWidth(2);
ofDrawRectRounded(applicationButtons[i], 20);
ofFill();
}

// Make a string with the name of the application with the loop index plus one prepended.
Application *app = applications[applicationOrder[i]];
string applicationOrderString = ofToString(i+1) + ": " + app->getName();

// Add label for application button
ofSetColor(ofColor::white);
displayFont20.drawString(applicationOrderString, applicationButtons[i].x + 25, applicationButtons[i].y + 30);
}

// draw shape and color I/O images

Expand Down Expand Up @@ -356,20 +427,13 @@ void AppManager::keyPressed(int key) {
showDebugGui = !showDebugGui;
} else if (key == ' ') {
paused = !paused;
} else if (key > '0' && key <= '9' && (key - '0') < applications.size()) {
int num = key - '0';
for (map<string, Application *>::iterator iter = applications.begin(); iter != applications.end(); iter++) {
// skip over empty entries created by checks
if (iter->second == nullptr)
continue;
num--;
// num == 0 when iter gets to the Nth app
if (num == 0) {
setCurrentApplication(iter->first);
break;
}
}
}
} else if (key > '0' && key <= '9') {
int num = key - '0';
if (num > 0 && num <= applicationOrder.size()) {
setCurrentApplication(applicationOrder[num - 1]);
lastSelectedApplicationName = applicationOrder[num - 1];
}
}
/*else if (key == '1') {
setCurrentApplication("mqttTransmission");
} else if (key == '2') {
Expand Down Expand Up @@ -397,7 +461,17 @@ void AppManager::keyPressed(int key) {
void AppManager::keyReleased(int key) {};
void AppManager::mouseMoved(int x, int y) {};
void AppManager::mouseDragged(int x, int y, int button) {};
void AppManager::mousePressed(int x, int y, int button) {};
void AppManager::mousePressed(int x, int y, int button) {
// Check if any of the application buttons were clicked
for (int i = 0; i < applicationButtons.size(); i++){
if (applicationButtons[i].inside(x, y)){
// Set the current application to the one that was clicked.
setCurrentApplication(applicationOrder[i]);
// Also set the last selected application, so that the button can be highlighted during the transition to the new application.
lastSelectedApplicationName = applicationOrder[i];
}
}
};
void AppManager::mouseReleased(int x, int y, int button) {};
void AppManager::windowResized(int w, int h) {};
void AppManager::gotMessage(ofMessage msg) {};
Expand Down
22 changes: 19 additions & 3 deletions src/AppManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "TransformIOManager.hpp"

// External Device Managers
#include "KinectManager.hpp"
#include "KinectManagerSimple.hpp"

// major classes
#include "Application.hpp"
Expand All @@ -43,6 +43,7 @@
#include "DepthDebugApp.hpp"

#include "KinectHandWavy.hpp"
#include "Telepresence.hpp"

#include "EquationMode.hpp"

Expand Down Expand Up @@ -78,6 +79,9 @@ class AppManager : public ofBaseApp {
shared_ptr<ofAppBaseWindow> displayWindow;
shared_ptr<ofAppBaseWindow> projectorWindow;

// pointer to camera, lives in DisplayApp
ofVideoGrabber *cam;

// lets settings window access main window stuff
friend class DisplayApp;
friend class ProjectorApp;
Expand All @@ -94,10 +98,19 @@ class AppManager : public ofBaseApp {
SerialShapeIOManager *m_serialShapeIOManager;

// external devices
KinectManager *kinectManager;
KinectManagerSimple *kinectManager;

// applications
map<string, Application *> applications;
unordered_map<string, Application *> applications;
std::vector<std::string> applicationOrder; // Vector to maintain insertion order of applications

// Graphical buttons, made of rectangles
std::vector<ofRectangle> applicationButtons;
ofTrueTypeFont displayFont20;
// Track the last application that was selected, so we can give it a button status during the transition
// because it won't be the active application until the transition is complete.
std::string lastSelectedApplicationName;

Application *currentApplication;

// debugging applications
Expand All @@ -115,6 +128,9 @@ class AppManager : public ofBaseApp {
// hand wavy application
KinectHandWavy *kinectHandWavy;

// Telepresence
Telepresence *telepresence;

EquationMode *equationMode;

WaveModeContours *waveModeContours;
Expand Down
Loading