flasker module

Flask server .. rubric:: Example

$ python flasker.py

class flasker.FluServer

Bases: object

callLineDetector(image)
callyolo(image)
ret_inf_lat()

Returns the last TFS(EI) inf time delta.

flasker.align()

API endpoint to Run the entire service and give appropriate response.

Example

Sample Request:

{"UUID":"a43f9681-a7ff-43f8-a1a6-f777e9362654","Quality_parameters":{"brightness":"10"},"RDT_Type":"Flu_Audere","Include_Proof":"False"}

Response codes

0=> No Flu detected

1=> Type A Flu detected

2=> Type B Flu detected

3=> Both type A and B detected

Negative values indicate error conditions

-1=> Invalid(No Control Line detected)

-2=> No RDT found in image

Example

Sample API response:

{"UUID":"a43f9681-a7ff-43f8-a1a6-f777e9362654",rc":0,"msg":"No Flu","Include_Proof":"False"}
flasker.angle_with_yaxis(p1, p2, img, centers)

Compute angle by which image should be rotated,scale factor and returns a translated image

Parameters
  • p1 (numpy.array) – X,Y of top pattern 1

  • p2 (numpy.array) – X,Y of bottom arrow 2

  • img (numpy.ndarray) – Image with channels last format

  • centers (list) – Centers of red and blue line (Used for debugging only)

Returns

3-element list containing

  • angle (numpy.float): Angle to rotate Clock wise

  • image (numpy.ndarray): Translated image

  • centers (list): List of transformed centers (Used for debugging only)

flasker.euclidianDistance(p1, p2)

Compute euclidian distance between p1 and p2

Parameters
  • p1 (numpy.array) – X,Y of point 1

  • p2 (numpy.array) – X,Y of point 2

Returns

Distance between two points

Return type

numpy.float

flasker.generateRDTcrop(boxes, im0, targets)

Generate RDT cropped image from object detection output

Parameters
  • boxes (numpy.ndarray) – Bounding boxes of objects detected and the confidence score

  • im0 (numpy.ndarray) – Input image

  • targets (dict) – Centers of red and blue line (Used for debugging only)

Returns

Response with RDT crop if found

Return type

dict

flasker.postProcessDetections(labels)

PostProcess object detection output

Parameters

labels (numpy.ndarray) – Bounding boxes of objects detected and the confidence score

Returns

Post processed detections

Return type

dict

flasker.reduceByConfidence(dictBoxC, dictBoxL)

This function handles multple object detection by selecting the one with the highest score.

Parameters
  • dictBoxC (dict) – Objects detected and confidence

  • dictBoxL (dict) – Objects detected and bounding box

Returns

Filtered list of Objects detected and bounding boxes

Return type

dict

flasker.returnCentre(tlbr)

This function returns centre of bounding box.

Parameters

tlbr (list) – list of values in str [topleft_x,topleft_y,bottomright_x,bottomright_y]

Returns

Centre cordinates of bounding box

Return type

list

flasker.returnROI(img, centers)

Return cropped RDT

Parameters
  • img (numpy.ndarray) – Image with channels last format

  • centers (list) – Centers of red and blue line (Used for debugging only)

Returns

2-element tuple containing

  • image (numpy.ndarray): RDT image

  • centers (list): List of transformed centers (Used for debugging only)

flasker.rotate_bound(image, angle, centers)

Return cropped RDT

Parameters
  • image (numpy.ndarray) – Image with channels last format

  • angle (numpy.float) – Angle to rotate image clockwise

  • centers (list) – Centers of red and blue line (Used for debugging only)

Returns

2-element tuple containing

  • image (numpy.ndarray): Rotated image

  • centers (list): List of transformed centers (Used for debugging only)