hi everyone i am new to this Community i want to custmize the user frame to filter like the low confidence score of detected object and increse width and height of frame so plz help me to modify this and on which script to modify to display
Hey @vinaygouda.ttssl,
To filter and process only high-confidence detections in your Hailo application, you can modify the detection loop to check the confidence level of each detection and only proceed with those that meet a certain confidence threshold. Here’s an example of how you can update the code to focus on confidence scores:
for detection in detections:
label = detection.get_label()
bbox = detection.get_bbox()
confidence = detection.get_confidence()
if label == "person" and confidence > 0.5: # Adjust the confidence threshold as needed
string_to_print += f"Detection: {label} {confidence:.2f}\n"
detection_count += 1
if user_data.use_frame:
# Note: using imshow will not work here, as the callback function is not running in the main thread
# Print the detection count on the frame
cv2.putText(frame, f"Detections: {detection_count}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
# Display additional information from user_data
cv2.putText(frame, f"{user_data.new_function()} {user_data.new_variable}", (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
# Convert the frame to BGR format
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
user_data.set_frame(frame)
Key Changes:
- Confidence Filtering: Added a condition to check if the detection confidence is above a certain threshold (e.g.,
0.5
). This ensures that only detections with a confidence score higher than 0.5 are processed and drawn.
You can adjust the confidence threshold (0.5
in this example) to match your accuracy needs. A higher threshold will result in fewer, but more reliable, detections.
To resize the frame after processing it in your Hailo application, you can use OpenCV’s resize
function. Here’s how to incorporate frame resizing into your existing code:
import cv2
# Assuming 'frame' is your original frame
# Specify the desired size
width, height = 800, 600 # Example dimensions
# Resize the frame
resized_frame = cv2.resize(frame, (width, height), interpolation=cv2.INTER_LINEAR)
# Continue with any further processing on resized_frame
Key Changes:
- Frame Resizing: The
cv2.resize
function is used to adjust the frame’s dimensions to the specified width and height. TheINTER_LINEAR
interpolation method offers a good balance between speed and quality.
This resizing code should be added after all detections and frame modifications are completed and just before any final steps, such as displaying or saving the frame. Adjust the width
and height
values to fit your application’s requirements.
without using the userframe flag i want to custmize bcz if i use it display two frame
HEY, Did you find the solution, i am also facing the same issue that two windows is getting generated when using user frame but i don’t wan to do that is there a way to do so??