• Community
  • how do i add confidence values to boxes?

Hi someone made me a quick piece of code that switches a relay when a item is detected i would like to see the confidence value on screen so i can see how well my model is working. i didn't know if this in the main.py or models .json file?
Cheers
Adam

edit
i believe he used parts of the people counter demo. The host is a raspberry pi and I have trained my own model. So far I have just been adjusting the confidence value in the .json file so can tune it but would like to see the actual value on screen which would help. Hopefully someone can point me in the right Direction

    Luxonis-Lukasz nice one thank you for this!! Will have a look at it today and see if I can get it working
    Cheers
    Adam

    hi i thought i'd post the main.py file code

    import logging
    import threading
    import argparse
    import ctypes
    import json
    import time
    import os
    from pathlib import Path

    import cv2
    from modules import Solenoid
    from depthai_utils import DepthAI
    from multiprocessing import Process, Manager
    parser = argparse.ArgumentParser()
    parser.add_argument('-m', '--model', default='poa', choices=list(os.listdir('./models')))
    args = parser.parse_args()

    debug = True

    if name == "main":

    Start threading

    p = Process(target=store, args=(shared_results, ))

    p.daemon = True

    p.start()

    # Initialize the model
    d = DepthAI(model_name=args.model)
    
    # Initialize the solenoid object
    sol = Solenoid(12)
    
    for frame, detections in d.run():
        if len(detections) >= 1:
             
             print ("Weed found")
             sol.run(True)
            
        else:
            sol.run(False)
    
        if debug:
            cv2.putText(frame, "Find Poa", (20, 20), cv2.FONT_HERSHEY_TRIPLEX, 0.9, 255)
            img_h = frame.shape[0]
            img_w = frame.shape[1]
            for detection in detections:
                left, top = int(detection.x_min * img_w), int(detection.y_min * img_h)
                right, bottom = int(detection.x_max * img_w), int(detection.y_max * img_h)
                cv2.rectangle(frame, (left, top), (right, bottom), (0, 0,255), 5)
            cv2.imshow('Result', frame)
            
            if cv2.waitKey(1) == ord('q'):
                cv2.destroyAllWindows()
                break
    del d