test_with_camera

test_with_camera.load_labels(path)

Load labels from text file

Parameters:

path – Path to text file containing labels

Returns:

List of labels

Return type:

labels

class test_with_camera.Interpreter(model_path)

Load TFLite model and allocate tensors

model_path

Path to TFLite model

interpreter

TFLite interpreter

get_interpreter()

Get TFLite interpreter

Returns:

TFLite interpreter

Return type:

interpreter

get_details() tuple

Get input and output details

Returns:

Input details output_details: Output details height: Height of input tensor width: Width of input tensor

Return type:

input_details

class test_with_camera.Detection(frame, height, width, interpreter, input_detail, output_detail)

Detect objects in frame using TFLite model

frame

Input frame

height

Frame height

width

Frame width

interpreter

TFLite interpreter

input_detail

Input details

output_detail

Output details

scores

Confidence scores

boxes

Bounding box coordinates

classes

Class indices

num_detections

Number of detections

nms(boxes, scores, iou_threshold)

Non-maximum suppression

Parameters:
  • boxes – Bounding box coordinates

  • scores – Confidence scores

  • iou_threshold – IoU threshold

Returns:

Indices of boxes to keep

Return type:

keep

interpret()

Interpret the frame and make predictions

Parameters:
  • frame – Input frame

  • height – Frame height

  • width – Frame width

  • interpreter – TFLite interpreter

  • input_details – Input details

  • output_details – Output details

Returns:

Number of detections scores: Confidence scores boxes: Bounding box coordinates classes: Class indices

Return type:

num_detections

classFilter(classdata) list

Filter classes

Parameters:

classdata – Class data

Returns:

Filtered classes

YOLOdetect(output_data) tuple

Detect objects using YOLO

Parameters:

output_data – Output data

Returns:

Bounding box coordinates, class indices, and confidence scores

make_boxes(scores, xyxy)

Draw bounding boxes on frame

Parameters:
  • frame – Input frame

  • scores – Confidence scores

  • xyxy – Bounding box coordinates

Returns:

Frame with bounding boxes

make_boxes_2()

Draw bounding boxes on frame version 2

Returns:

Frame with bounding boxes