]> git.sesse.net Git - nageru/commitdiff
Update some comments.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 4 Jul 2018 20:21:39 +0000 (22:21 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 4 Jul 2018 20:21:39 +0000 (22:21 +0200)
flow.cpp
motion_search.frag
sobel.frag

index 47cebba7918c84471583629367192795b7aff19b..e59a4812e8e2dcd0a3eef18be621d8b98c1b6c00 100644 (file)
--- a/flow.cpp
+++ b/flow.cpp
@@ -494,7 +494,7 @@ int main(void)
 
                // Densification.
 
-               // Set up an output texture.
+               // Set up an output texture (initially zero).
                GLuint dense_flow_tex;
                glCreateTextures(GL_TEXTURE_2D, 1, &dense_flow_tex);
                //glTextureStorage2D(dense_flow_tex, 1, GL_RGB16F, level_width, level_height);
index 5f2b6f8c2e1c79ffaee0de5b9c04ace4153b0f1d..0c5dcc4c1e68810d12d220f9af3cfe6d76d4e5c8 100644 (file)
@@ -95,6 +95,10 @@ void main()
        } else {
                initial_u = prev_flow.xy / prev_flow.z;
        }
+
+       // Note: The flow is in OpenGL coordinates [0..1], but the calculations
+       // generally come out in pixels since the gradient is in pixels,
+       // so we need to convert at the end.
        vec2 u = initial_u;
 
        for (uint i = 0; i < num_iterations; ++i) {
index 4fd12a37d40025241bd7bf8f5dab80eb63146fa2..9feab1ee6b26ba5c614fd5f0ad2cc920e31f58eb 100644 (file)
@@ -11,12 +11,19 @@ void main()
        // There are two common Sobel filters, horizontal and vertical
        // (see e.g. Wikipedia, or the OpenCV documentation):
        //
-       //  [-1 0 1]     [ 1  2  1]
-       //  [-2 0 2]     [ 0  0  0]
-       //  [-1 0 1]     [-1 -2 -1]
+       //  [1 0 -1]     [-1 -2 -1]
+       //  [2 0 -2]     [ 0  0  0]
+       //  [1 0 -1]     [ 1  2  1]
        // Horizontal     Vertical
        //
-       // Computing both at once allows us to get away with eight
+       // Note that Wikipedia and OpenCV gives entirely opposite definitions
+       // with regards to sign! This appears to be an error in the OpenCV
+       // documentation, forgetting that for convolution, the filters must be
+       // flipped. We have to flip the vertical matrix again comparing to
+       // Wikipedia, though, since we have bottom-left origin (y = up)
+       // and they define y as pointing downwards.
+       //
+       // Computing both directions at once allows us to get away with eight
        // texture samples instead of twelve.
 
        float x_left   = tc.x - inv_image_size.x;