I have trained my custom dataset, I am using webcam to detect the custom object which has been trained. It detect the cardboard box.
My scenario is that whenever it detect the cardboard box it has to send email , which works fine. The cardboard box once placed in a location will be replaced to another location after 5 to 8 hours, until then it will remain in the original location, so constantly the cardboard box is getting detected and email is being sent continuously. How do i restrict so email gets send only one time.
If the original count increases then email will be sent again.
Please provide solution to fix the problem
Based on the information provided in the extracts, you can modify your code to keep track of the number of boxes detected and only send an email when this count changes. This can be done by adding a global variable to keep track of the previous count of boxes.
Here’s a simplified version of how you could modify your
prev_count = 0
def execute_trigger(overlayed_image, raw_image, current_count):
if current_count != prev_count:
print("Image successfully saved! Attempting to send email.")
message = gmail.send_message(**params)
prev_count = current_count
In this code,
current_count would be the number of boxes currently detected. The function now only sends an email if the current count of boxes is different from the previous count. After sending the email, it updates
prev_count to the current count.
Please note that this is a simplified example and you might need to adjust it to fit your specific use case and code structure.
For more details on how to integrate custom actions with Roboflow, you can refer to this blog post.
Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, and forum. If this solves your issue, please mark it as the solution using the checkbox icon. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.
Hi @Jaishankar_Vetrivel - this seems to be a post-processing logic problem.
You probably want to set up two rules:
- Count Increase Store the count of each inference. If the count ever increases, send an email. You may want to add smoothing here (e.g., you will only send an email every 10 minutes for an increase to the same number) - that will prevent cases where you briefly detect a new box and then the count decreases for a frame.
- Location Change I would define some minimum centroid distance that a box needs to move over ~30 frames or so in order to have the location changed. You’ll only want to send one of these emails every ~10 minutes or so as well (to prevent rapid emails while the box is being moved)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.