Skip to main content
. 2020 Apr 15;20(8):2226. doi: 10.3390/s20082226
Algorithm 1 Keyframe Extraction Algorithm
  • 1:

    procedureKeyframesExtraction(M)

  • 2:

       inputs: M={X1,X2,X3,,Xn}, given input sequence of frames

  • 3:

       persistent: n, total number of frames

       k, total number of nearest neighbors

       N={X^1,X^2,X^3,,X^k}, retrieved nearest neighbors

       D={d1,d2,d3,,dk}, distances computed for each nearest neighbor

       Φ={ϕ1,ϕ2,ϕ3,,ϕc}, candidate keyframes

       Ψ={ψ1,ψ2,ψ3,,ψs}, final selected keyframes

       t, threshold value

  • 4:

       kn2

  • 5:

       s1

  • 6:

       while (length(M)0) do

  • 7:

        X1extractFrame(M)

  • 8:

        [N,D]findNearestNeighbours(M,X1,k)

  • 9:

        i1

  • 10:

        while (i<k) do

  • 11:

         if (di<t) then

  • 12:

            ϕiX^i

  • 13:

            ii+1

  • 14:

         end if

  • 15:

        end while

  • 16:

        Φsort(Φ)

  • 17:

        ψsmedian(Φ)

  • 18:

        MMΦ

  • 19:

        ss+1

  • 20:

       end while

  • 21:

    end procedure