diff --git a/src/optflow/optflow-demo.cpp b/src/optflow/optflow-demo.cpp index ca305c866..cb0ef73af 100644 --- a/src/optflow/optflow-demo.cpp +++ b/src/optflow/optflow-demo.cpp @@ -3,10 +3,11 @@ constexpr unsigned long WIDTH = 1920; constexpr unsigned long HEIGHT = 1080; constexpr float SCALE_FACTOR = 0.5f; -constexpr bool OFFSCREEN = false; +constexpr bool OFFSCREEN = true; constexpr int VA_HW_DEVICE_INDEX = 0; constexpr float SCENE_CHANGE_THRESH = 0.29f; constexpr float SCENE_CHANGE_THRESH_DIFF = 0.1f; +constexpr float MAX_POINTS = 500000.0; #include "../common/subsystems.hpp" #include @@ -69,7 +70,7 @@ void visualize_sparse_optical_flow(const cv::UMat& prevGrey, const cv::UMat &nex float area = cv::contourArea(hull); float density = (detectedPoints.size() / area); float stroke = 30.0 * sqrt(area / (nextGrey.cols * nextGrey.rows * 4)); - size_t currentMaxPoints = density * 500000.0; + size_t currentMaxPoints = density * MAX_POINTS; size_t copyn = std::min(detectedPoints.size(), (size_t(std::ceil(currentMaxPoints)) - prevPoints.size())); if (prevPoints.size() < currentMaxPoints) { @@ -159,7 +160,7 @@ int main(int argc, char **argv) { break; cv::resize(videoFrame, resized, frameBufferSize); - cv::resize(resized, down, cv::Size(0, 0), SCALE_FACTOR, SCALE_FACTOR); + cv::resize(videoFrame, down, cv::Size(WIDTH * SCALE_FACTOR, HEIGHT * SCALE_FACTOR)); cv::cvtColor(resized, background, cv::COLOR_RGB2BGRA); cv::cvtColor(down, downNextGrey, cv::COLOR_RGB2GRAY); diff --git a/src/tetra/tetra-demo.cpp b/src/tetra/tetra-demo.cpp index 2002fc7d4..994900852 100644 --- a/src/tetra/tetra-demo.cpp +++ b/src/tetra/tetra-demo.cpp @@ -12,7 +12,7 @@ constexpr const int VA_HW_DEVICE_INDEX = 0; using std::cerr; using std::endl; -void init_tetrahedron() { +void init_scene() { glViewport(0, 0, WIDTH, HEIGHT); glColor3f(1.0, 1.0, 1.0); @@ -30,7 +30,7 @@ void init_tetrahedron() { glRotatef(70, 0, 1, 0); } -void render_tetrahedron() { +void render() { glViewport(0, 0, WIDTH , HEIGHT ); glRotatef(1, 0, 1, 0); glClearColor(0.0f, 0.0f, 1.0f, 1.0f); @@ -103,14 +103,14 @@ int main(int argc, char **argv) { cv::UMat frameBuffer; cv::UMat videoFrame; - init_tetrahedron(); + init_scene(); while (true) { //Activate the OpenCL context for OpenGL gl::bind(); //Render using OpenGL gl::begin(); - render_tetrahedron(); + render(); gl::end(); //Aquire the frame buffer for use by OpenCL diff --git a/src/video/video-demo.cpp b/src/video/video-demo.cpp index c41ca3778..c67627a3b 100644 --- a/src/video/video-demo.cpp +++ b/src/video/video-demo.cpp @@ -15,7 +15,7 @@ using std::cerr; using std::endl; using std::string; -void init_tetrahedron() { +void init_scene() { glViewport(0, 0, WIDTH, HEIGHT); glColor3f(1.0, 1.0, 1.0); @@ -33,7 +33,7 @@ void init_tetrahedron() { glRotatef(70, 0, 1, 0); } -void render_tetrahedron() { +void render() { //Render a tetrahedron using immediate mode because the code is more concise for a demo glViewport(0, 0, WIDTH, HEIGHT); glRotatef(1, 0, 1, 0); @@ -125,7 +125,7 @@ int main(int argc, char **argv) { cv::UMat videoFrame; cv::UMat videoFrameRGBA; - init_tetrahedron(); + init_scene(); //Activate the OpenCL context for VAAPI va::bind(); @@ -154,7 +154,7 @@ int main(int argc, char **argv) { //Render using OpenGL gl::begin(); - render_tetrahedron(); + render(); gl::end(); //Aquire the frame buffer for use by OpenCL