measureExposure()
checkExposure()
measureSharpness()
checkSharpness()
measureCentering()
checkCentering()
measureSize()
checkSize()
measureOrientation()
checkOrientation()
checkGlare()
getInstructionText()
getSummaryText()
Signature: RDT(Context context, String rdtName)
Purpose: Object for holding all of the parameters that are loaded from the configuration file for the RDT of interest
Parameters:
Context context
: theContext
object for the app'sActivity
String rdtName
: theString
used to reference the RDT design inconfig.json
Signature: enum ExposureResult
Purpose: An Enumeration
object for specifying the exposure quality of the image
Possible Values:
UNDER_EXPOSED
: the image is too darkNORMAL
: the image has just the right amount of lightOVER_EXPOSED
: the image is too bright
Signature: enum SizeResult
Purpose: An Enumeration
object for specifying whether the RDT has a reasonable scale in the image
Possible Values:
SMALL
: the RDT is too small in the imageRIGHT_SIZE
: the RDT has just the right size in the imageLARGE
: the RDT is too large in the imageINVALID
: the RDT could not be found in the image
Signature: RDTCaptureResult(boolean allChecksPassed, Mat resultMat, MatOfPoint2f boundary, boolean flashEnabled, ExposureResult exposureResult, boolean isSharp, boolean isCentered, SizeResult sizeResult, boolean isOriented, double angle, boolean isGlared, boolean fiducial)
Purpose: Object for holding all of the parameters that describe whether a candidate video framed passed all of the quality checks
Parameters:
boolean allChecksPassed
: whether this candidate video frame is clear enough for interpretationMat resultMat
: the RDT image tightly cropped around the result windowMatOfPoint2f boundary
: the corners of the bounding box around the detected RDTboolean flashEnabled
: whether the flash was active during the image capture process for this frameExposureResult exposureResult
: whether the candidate video frameinput
has a reasonable brightnessboolean isSharp
: whether the candidate video frameinput
has a reasonable sharpnessboolean isCentered
: whether theboundary
of the detected RDT is sufficiently in the middle of the screen for consistent interpretationSizeResult sizeResult
: whether theboundary
of the detected RDT has a reasonable size for consistent interpretationboolean isOriented
: whether theboundary
of the detected RDT has a reasonable orientation for consistent interpretationdouble angle
: the orientation of the RDT's vertical axis relative to the vertical axis of the video frame (e.g., 0° = upright, 90° = right-to-left, 180° = upside-down, 270° = left-to-right)boolean isGlared
: whether there is glare within the detected RDT's result windowboolean fiducial
: whether the fiducial was detected (if one was specified)
Signature: RDTInterpretationResult(Mat resultMat, boolean topLine, boolean middleLine, boolean bottomLine)
Purpose: Object for holding all of the parameters that describe the test result that is detected on the completed RDT
Parameters:
Mat resultMat
: the RDT image tightly cropped around the result windowboolean topLine
: whether the top line was detected in the result windowboolean middleLine
: whether the middle line was detected in the result windowboolean bottomLine
: whether the bottom line was detected in the result window
Signature: Rect viewfinderRect = getViewfinderRect(Mat inputMat)
Purpose: Returns the rectangle corresponding to the viewfinder that the user sees (i.e., region-of-interest) for image quality
Parameters:
Mat inputMat
: the candidate video frame
Returns:
Rect viewfinderRect
: the viewfinder rectangle
Signature: RDTCaptureResult captureResult = assessImage(Mat inputMat, boolean flashEnabled)
Purpose: Processes the candidate video frame to see if it passes all of the quality checks needed to ensure high likelihood of correct automatic analysis
Parameters:
Mat inputMat
: the candidate video frame (in RGBA)boolean flashEnabled
: whether the flash was active during the image capture process for this frame
Returns:
RDTCaptureResult captureResult
: the capture results
Signature: MatOfPoint2f boundary = detectRDT(Mat inputMat)
Purpose: Locates the RDT within the image (if one is presents) produces a bounding box around it
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)
Returns:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT if one is present, otherwise a blank MatOfPoint2f
Signature: Mat debugMat = drawKeypointsAndMatches(Mat inputMat, MatOfPoint boundary, MatOfKeyPoint keypoints, MatOfDMatch matchesMat)
Purpose: Draws an image for debugging the feature-based template matching approach for RDT detection
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)MatOfPoint2f boundary
: the corners of the bounding box around the detected RDTMatOfKeyPoint keypoints
: the SIFT keypoints within the video frameMatOfDMatch matchesMat
: the correspondence between the different keypoints
Returns:
Mat debugMat
: an image with keypoint matches drawn between the reference image and the candidate video frame
Signature: float[] mBuff = measureExposure(Mat inputMat)
Purpose: Calculates the brightness histogram of the candidate video frame
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)
Returns:
float[] mBuff
: a 256-element histogram that quantifies the number of pixels at each brightness level for the greyscale version ofinputMat
Signature: ExposureResult exposureResult = checkExposure(Mat inputMat)
Purpose: Determines whether the candidate video frame has sufficient lighting without being too bright
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)
Returns:
ExposureResult exposureResult
: whetherinputMat
has a reasonable brightness
Signature: double sharpness = measureSharpness(Mat inputMat)
Purpose: Calculates the Laplacian variance of the candidate video frame as a metric for sharpness
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)
Returns:
double sharpness
: the Laplacian variance ofinputMat
Signature: boolean isSharp = checkSharpness(Mat inputMat)
Purpose: Determines whether the candidate video frame is focused
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)
Returns:
boolean isSharp
: whetherinputMat
has a reasonable sharpness
Signature: Point center = measureCentering(MatOfPoint2f boundary)
Purpose: Identifies the center of the detected RDT
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
Point center
: the (x, y) coordinate corresponding to the center of the RDT
Signature: boolean isCentered = checkCentering(MatOfPoint2f boundary, Size size)
Purpose: Determines whether the detected RDT is close enough towards the center of the candidate video frame
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDTSize size
: the size of the candidate video frame
Returns:
boolean isCentered
: whether theboundary
of the detected RDT is sufficiently in the middle of the screen for consistent interpretation
Signature: double dimension = measureSize(MatOfPoint2f boundary, boolean isHeight)
Purpose: Measures the desired dimension of the bounding box around the detected RDT
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDTboolean isHeight
: whether the output should be the height (true) or width (false)
Returns:
double dimension
: the desired dimension in pixels
Signature: SizeResult sizeResult = checkSize(MatOfPoint2f boundary, Size size)
Purpose: Determines whether the detected RDT is a reasonable size within the camera frame
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDTSize size
: the size of the candidate video frame
Returns:
SizeResult sizeResult
: whether theboundary
of the detected RDT has a reasonable size for consistent interpretation
Signature: double angle = measureOrientation(MatOfPoint2f boundary)
Purpose: Measures the orientation of the RDT relative to the camera's perspective (assumes vertical RDT where height > width)
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
double angle
: the orientation of the RDT's vertical axis relative to the vertical axis of the video frame (0° = upright, 90° = right-to-left, 180° = upside-down, 270° = left-to-right)
Signature: double isOriented = checkOrientation(MatOfPoint2f boundary)
Purpose: Determines whether the detected RDT is a reasonable orientation within the camera frame
Parameters:
MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
boolean isOriented
: whether theboundary
of the detected RDT has a reasonable orientation for consistent interpretation
Signature: boolean isGlared = checkIfGlared(Mat inputMat, MatOfPoint2f boundary)
Purpose: Determines if there is glare within the detected RDT's result window (often due to protective covering of the immunoassay)
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
boolean isGlared
: whether there is glare within the detected RDT's result window
Signature: int instruction = getInstructionText(boolean isCentered, SizeResult sizeResult, boolean isOriented, boolean isGlared)
Purpose: Generate the most logical instruction to help the user fix a single quality check
Parameters:
boolean isCentered
: whether theboundary
of the detected RDT is sufficiently in the middle of the screen for consistent interpretationSizeResult sizeResult
: whether theboundary
of the detected RDT has a reasonable size for consistent interpretationboolean isOriented
: whether theboundary
of the detected RDT has a reasonable orientation for consistent interpretationboolean isGlared
: whether there is glare within the detected RDT's result window
Returns:
int instruction
: the ID of the instruction text to be found inres/values/strings.xml
Signature: String[] summaryText = String[] getSummaryText(ExposureResult exposureResult, boolean isSharp, boolean isCentered, SizeResult sizeResult, boolean isOriented, boolean isGlared)
Purpose: Generate text that can be shown on the screen to summarize all quality checks
Parameters:
ExposureResult exposureResult
: whether the candidate video frame has a reasonable brightnessboolean isSharp
: whether the candidate video frame has a reasonable sharpnessboolean isCentered
: whether theboundary
of the detected RDT is sufficiently in the middle of the screen for consistent interpretationSizeResult sizeResult
: whether theboundary
of the detected RDT has a reasonable size for consistent interpretationboolean isOriented
: whether theboundary
of the detected RDT has a reasonable orientation for consistent interpretationboolean isGlared
: whether there is glare within the detected RDT's result window
Returns:
String[] summaryText
: summary for each quality checking component
Signature: boolean isBloody = checkBloody(Mat inputMat, MatOfPoint2f boundary)
Purpose: Determines if there is blood within the detected RDT's result window
Parameters:
Mat inputMat
: the candidate video frame (in grayscale)MatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
boolean isBloody
: whether there is blood within the detected RDT's result window
Signature: Mat resultWindow = cropResultWindow(Mat inputMat, MatOfPoint2f boundary)
Purpose: Crops out the detected RDT's result window as a rectangle
Parameters:
Mat inputMat
: the candidate video frameMatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
Mat resultWindow
: the RDT image tightly cropped and de-skewed around the result window
Signature: Mat resultWindow = cropResultWindowWithFidicual(Mat inputMat)
Purpose: Uses color clustering to identify explicit 'fiducials' (densely colored markers) on the detected RDT that can be used as reference points for locating the result window
Parameters:
Mat inputMat
: the candidate video frame (in RGBA and de-skewed)
Returns:
Mat resultWindow
: the RDT image tightly cropped and de-skewed around the result window
Signature: Mat enhancedMat = Mat enhanceResultWindow(Mat resultWindowMat)
Purpose: Applies CLAHE to enhance faint marks on the RDT's result window
Parameters:
Mat resultWindowMat
: the RDT's result window (in RGBA)
Returns:
Mat enhancedMat
: a contrast-enhanced version of the RDT's result window
Signature: InterpretationResult interpResult = interpretRDT(Mat inputMat, MatOfPoint2f boundary)
Purpose: Interprets any lines that appear within the detected RDT's result window
Parameters:
Mat inputMat
: the image known to have a clear RDT in the video frameMatOfPoint2f boundary
: the corners of the bounding box around the detected RDT
Returns:
InterpretationResult interpResult
: the test results