Facial Tracking App Debugging

  • Upload
    swonera

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

  • 8/12/2019 Facial Tracking App Debugging

    1/5

  • 8/12/2019 Facial Tracking App Debugging

    2/5

    filter true if the source should be filtered. Only applies if the matrix containsmore than just translation.

    Returns A bitmap that represents the specified subset of source

    Throws

    ??? - there may be more information from the compiler but this is enough to get started.(the missing part if the exception that is thrown but can leave this out for now)

    Questions about code:

    Does the matrix m need to be the same dimension as the bitmap?What does the filter do to the source?

    Matrix Manipulations:

    Here is a good document that I found on matrix manipulations for reference.http://www.ux.uis.no/~hirpa/KdB/FEM/MatrixHandout.pdf

    Questions about the math:

    In order to correct for the mirroring, the columns should be inverted.How can this be done in code?

    Analysis:

    1) Basically the order of the elements should be reversed to fix the display.

    a11 a12 a13 a14 a15 a16

    a16 a15 a14 a13 a12 a11This can be done algorithmically but may be too slow for large bit maps. It is good to

    look back at createBitmap to determine if there is a way to use the the matrix operationto perform the transform of the data.

    http://www.ux.uis.no/~hirpa/KdB/FEM/MatrixHandout.pdfhttp://www.ux.uis.no/~hirpa/KdB/FEM/MatrixHandout.pdf
  • 8/12/2019 Facial Tracking App Debugging

    3/5

    2) The definition of the matrix class for Android provides more details on the operationsthat can be performed through the specification of the 3x3 matrix.

    The Matrix class holds a 3x3 matrix for transforming coordinates. Matrix does not havea constructor, so it must be explicitly initialized using either reset() - to construct an

    identity matrix, or one of the set..() functions (e.g. setTranslate, setRotate, etc.).

    Since we want to flip the values around the X axis to remove the mirroring, the matrixshown below is used.

    -1

    1

    1

    0 0

    00

    0 03) Here is some additional information on Wikipedia that explains how this works.http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#

    Uniform scaling and reflection:

    Multiplying every vector with a constant real number k is represented by the diagonalmatrixwhose entries on the diagonal are all equal to k. Mechanically, this correspondsto stretching a rubber sheet equally in all directions such as a small area of the surface

    of an inflating balloon. All vectors originating at origin(i.e., the fixed point on the balloonsurface) are stretched equally with the same scaling factor k while preserving its originaldirection. Thus, every non-zero vector is an eigenvector with eigenvalue k. Whether thetransformation is stretching (elongation, extension, inflation), or shrinking (compression,deflation) depends on the scaling factor: if k > 1, it is stretching; if 0 < k < 1, it isshrinking. Negative values of k correspond to a reversal of direction, followed by astretch or a shrink, depending on the absolute value of k.

    Implementation:

    Open the project for OpenCV and select the face-detection sample files. The file to be

    modified is the SampleCVViewBase.java file.

    Scroll down to the section shown in the screen shot.

    http://en.wikipedia.org/wiki/Diagonal_matrixhttp://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#http://en.wikipedia.org/wiki/Origin_%28mathematics%29http://en.wikipedia.org/wiki/Origin_%28mathematics%29http://en.wikipedia.org/wiki/Diagonal_matrixhttp://en.wikipedia.org/wiki/Diagonal_matrixhttp://en.wikipedia.org/wiki/Diagonal_matrixhttp://en.wikipedia.org/wiki/Diagonal_matrixhttp://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#http://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors#
  • 8/12/2019 Facial Tracking App Debugging

    4/5

    Change the line

    bmp = processFrame(mCamera);to Bitmap temp_bmp = processFrame(mCamera);The new code will be inserted after this line and before

    mFps.measure();

    New code:

    // setting up the steps for fixing the mirror issue with the front

    facing camera

    Matrix rotateRight = newMatrix();

    if(android.os.Build.VERSION.SDK_INT>13)

    {// matrix for mirroring of the image

    float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1}; rotateRight = newMatrix();

    Matrix matrixMirrorY = newMatrix();

    matrixMirrorY.setValues(mirrorY);

    rotateRight.postConcat(matrixMirrorY);

    }

  • 8/12/2019 Facial Tracking App Debugging

    5/5

    // use the createBitmap to implement the mirror operation

    bmp = Bitmap.createBitmap(temp_bmp, 0, 0,

    temp_bmp.getWidth(), temp_bmp.getHeight(), rotateRight, true);