From 3b50097277560f293934812693e5e0176ab2539e Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 18 Apr 2024 22:53:23 -0400 Subject: [PATCH 1/5] patch hardcoded value --- src/Applications/KinectHandWavy.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Applications/KinectHandWavy.cpp b/src/Applications/KinectHandWavy.cpp index 552fd08..ba2d3cd 100644 --- a/src/Applications/KinectHandWavy.cpp +++ b/src/Applications/KinectHandWavy.cpp @@ -84,8 +84,13 @@ void KinectHandWavy::drawPreviewMaskRectangle() { // Draw a semi-transparent rectangle over each of the three the actuated sections. void KinectHandWavy::drawPreviewActuatedSections() { + + // Get the width in inches of the the full transform surface (need to cast shape display manager object first). + float transformWidth = ((TransformIOManager*)m_CustomShapeDisplayManager)->m_Transform_W; + // Get the actuated section dimensions from the CustomShapeDisplayManager - float pixelsPerInch = m_kinectManager->m_mask.getWidth() / 104.75 ; // <-- this is a problem, the transform width (104.75) needs to be available from the apps. + float pixelsPerInch = m_kinectManager->m_mask.getWidth() / transformWidth; + std::vector sections = m_CustomShapeDisplayManager->createSections(pixelsPerInch); // Create a frame buffer with the same dimensions as the cropped signal. From 92f3c198dfbc18835a7f362191ea598b1fbacef3 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Thu, 18 Apr 2024 22:54:15 -0400 Subject: [PATCH 2/5] additional preview for video app --- src/Applications/VideoPlayerApp.cpp | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Applications/VideoPlayerApp.cpp b/src/Applications/VideoPlayerApp.cpp index a803df2..d2fc8c9 100755 --- a/src/Applications/VideoPlayerApp.cpp +++ b/src/Applications/VideoPlayerApp.cpp @@ -47,6 +47,37 @@ void VideoPlayerApp::updateHeights() { void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int height) { // Draw the video file. video.draw(30, 300, 544, 128); + + // Get the width in inches of the the full transform surface. + float transformWidth = ((TransformIOManager*)m_CustomShapeDisplayManager)->m_Transform_W; + + // Calculate the pixels per inch conversion rate. + float pixelsPerInch = video.getWidth() / transformWidth; + + // Create the actuated pixel sections. + std::vector sections = m_CustomShapeDisplayManager->createSections(pixelsPerInch); + + // Create a frame buffer with the same dimensions as the video + ofFbo fbo; + fbo.allocate(video.getWidth(), video.getHeight(), GL_RGBA); // GL_RGBA for transparency + + // Begin drawing into the frame buffer + fbo.begin(); + ofClear(0, 0, 0, 0); // Clear the buffer with transparent black + + // Draw the rectangles into the frame buffer + for (int i = 0; i < sections.size(); i++) { + ofRectangle section = sections[i]; + + ofSetColor(100,100,255,200); + ofDrawRectangle(section); + } + + // End drawing into the frame buffer + fbo.end(); + + // Draw the frame buffer at the same position and scale as the video + fbo.draw(30, 300, 544, 128); } string VideoPlayerApp::appInstructionsText() { From 39fa126c72c1d42ecc00e900679da4c1f709404c Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 20 Apr 2024 18:33:38 -0400 Subject: [PATCH 3/5] :fire: remove dead code --- src/Applications/VideoPlayerApp.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Applications/VideoPlayerApp.cpp b/src/Applications/VideoPlayerApp.cpp index d2fc8c9..8c5630a 100755 --- a/src/Applications/VideoPlayerApp.cpp +++ b/src/Applications/VideoPlayerApp.cpp @@ -25,9 +25,7 @@ void VideoPlayerApp::updateHeights() { // Grayscale ensures that there is only one brightness value per pixel (instead of three channel RGB). m_videoPixels.setImageType(OF_IMAGE_GRAYSCALE); - - //ofPixels onlyPinPixels = m_CustomShapeDisplayManager->getPinPixelsOnly(m_videoPixels); - + // Pass the current video frame to the shape display manager to get the actuated pixels. ofPixels livePixels = m_CustomShapeDisplayManager->cropToActiveSurface(m_videoPixels); From 8fa4ef81ec35162f47c9fdb4a03919219d6f4e47 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 20 Apr 2024 18:35:12 -0400 Subject: [PATCH 4/5] rename previewFrameBuffer from "fbo" which is not very descriptive. Also adds more detail to the comments. --- src/Applications/VideoPlayerApp.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Applications/VideoPlayerApp.cpp b/src/Applications/VideoPlayerApp.cpp index 8c5630a..d123cab 100755 --- a/src/Applications/VideoPlayerApp.cpp +++ b/src/Applications/VideoPlayerApp.cpp @@ -43,7 +43,7 @@ void VideoPlayerApp::updateHeights() { } void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int height) { - // Draw the video file. + // Draw the current video frame as a base; . video.draw(30, 300, 544, 128); // Get the width in inches of the the full transform surface. @@ -55,12 +55,12 @@ void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int he // Create the actuated pixel sections. std::vector sections = m_CustomShapeDisplayManager->createSections(pixelsPerInch); - // Create a frame buffer with the same dimensions as the video - ofFbo fbo; - fbo.allocate(video.getWidth(), video.getHeight(), GL_RGBA); // GL_RGBA for transparency + // Create a frame buffer for the preview with the same dimensions as the video. + ofFbo previewFrameBuffer; + previewFrameBuffer.allocate(video.getWidth(), video.getHeight(), GL_RGBA); // GL_RGBA for transparency // Begin drawing into the frame buffer - fbo.begin(); + previewFrameBuffer.begin(); ofClear(0, 0, 0, 0); // Clear the buffer with transparent black // Draw the rectangles into the frame buffer @@ -72,10 +72,10 @@ void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int he } // End drawing into the frame buffer - fbo.end(); + previewFrameBuffer.end(); // Draw the frame buffer at the same position and scale as the video - fbo.draw(30, 300, 544, 128); + previewFrameBuffer.draw(30, 300, 544, 128); } string VideoPlayerApp::appInstructionsText() { From b98262b83f4cf7647c2b914fcff2898349205dd5 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 28 Apr 2024 15:05:20 -0400 Subject: [PATCH 5/5] split out section preview into separate function --- src/Applications/VideoPlayerApp.cpp | 7 ++++++- src/Applications/VideoPlayerApp.hpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Applications/VideoPlayerApp.cpp b/src/Applications/VideoPlayerApp.cpp index d123cab..b2fa431 100755 --- a/src/Applications/VideoPlayerApp.cpp +++ b/src/Applications/VideoPlayerApp.cpp @@ -46,6 +46,11 @@ void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int he // Draw the current video frame as a base; . video.draw(30, 300, 544, 128); + // Draw the preview of the actuated pixels sections. + drawSectionPreviewFrameBuffer(30, 300, 544, 128); +} + +void VideoPlayerApp::drawSectionPreviewFrameBuffer(int x, int y, int width, int height) { // Get the width in inches of the the full transform surface. float transformWidth = ((TransformIOManager*)m_CustomShapeDisplayManager)->m_Transform_W; @@ -75,7 +80,7 @@ void VideoPlayerApp::drawGraphicsForShapeDisplay(int x, int y, int width, int he previewFrameBuffer.end(); // Draw the frame buffer at the same position and scale as the video - previewFrameBuffer.draw(30, 300, 544, 128); + previewFrameBuffer.draw(x, y, width, height); } string VideoPlayerApp::appInstructionsText() { diff --git a/src/Applications/VideoPlayerApp.hpp b/src/Applications/VideoPlayerApp.hpp index 59fb046..c22287c 100755 --- a/src/Applications/VideoPlayerApp.hpp +++ b/src/Applications/VideoPlayerApp.hpp @@ -16,6 +16,8 @@ class VideoPlayerApp : public Application { void setup(); void update(float dt); void drawGraphicsForShapeDisplay(int x, int y, int width, int height); + void drawSectionPreviewFrameBuffer(int x, int y, int width, int height); + string appInstructionsText(); void keyPressed(int key);