1. Introduction
This project aims to develop an AI Powered Gunshot Detecion System for Wildlife Protection using the Infineon PSoC6 AI Kit and EdgeImpulse
OR DeepCraft Studio. The system will:
- Collect real-time sound data from the built-in microphone sensor .
- Stream this data to DeepCraft Studio for AI model training.
- Train an AI model to detect Gunshoot sound.
- Deploy the trained model to the PSoC6 AI Kit using ModusToolbox.
- Provide alerts to users.
2. Hardware & Software Requirements
Hardware:- Infineon PSoC6 AI Kit (with dual XENSIV™ digital MEMS Microphone sensor)
- USB/UART connection for data streaming
- DeepCraft Studio (AI model training)
- ModusToolbox (PSoC6 firmware development)
Im surprised To find a ready--made Example In DeepCraft Studio for Gun Detection
So This project will be divided to two sections
Section 1 DeepCraft StudioFirst I will start to test and Deploy the ready made Model.
Section 2 EDGE IMPULSEThen I will use EDGE Impulse to make my Model and Train it using my streamed XENSIV™ digital MEMS microphones Data sets.
Both Models will be deployed and Tested On PSOC 6 AI KIT.
3. Section 1Steps to Implement the Project using the ready-made Model.
in this section I will Generate The code for the ready-made Model using DeepCraft Studio
wait for the Job to be finishedthen Download the best Trained Model
select Infineon PSOC in the architecture, PSOC6 in Target Device, The output Folder and press Generate Code
after Generating model.c & model.h files, you can find themodel files in the infineon folder copy Both Files model.c & model.h then we will go through deploy using Modustoolbox
1- open modustoolbox software and select your workspace
2- Create new project using New Application Wizard
3-select CY8CKIT-062S2-AI PSOC as your BSP Then Next
4- in Machine learning Section just choose DEEPCRAFT Deploy Model Motion, and Rename the project as you like and press create
5- After creating your Modus Project open the models folder and just replace model.c and model.h with the generated files from DeepCraft Studio
you can add your custom code to main, c file to do any thing when the model run successfuly, in This Project The RED LED will Turn on When a Gunshoot Detected And a warning message will be send to console.
if(best_label >0 )
Gunshoot
{
cyhal_gpio_write(CYBSP_USER_LED2,CYBSP_LED_STATE_OFF); //Turn RED LED ON WHEN Detected
}
else {cyhal_gpio_write(CYBSP_USER_LED2,CYBSP_LED_STATE_ON);}
if(best_label >0 )
{
cyhal_gpio_write(CYBSP_USER_LED2,CYBSP_LED_STATE_OFF); //Turn RED LED ON WHEN ANOMALLY Detected
}
else {cyhal_gpio_write(CYBSP_USER_LED2,CYBSP_LED_STATE_ON);}
for now I would like to run only the ready model to test its working just Build the Project and wait to finish with no errors
6- program your kit and open a serial console from Modustoolbox or putty or Tera Term as you like ( Baud :115200, 8, none, 1 )
1.Bench Testing
- Simulate gunshoot sound using pre-recorded different gunshot sounds
- Verify if the AI model detects The gunshoots.
Test & Validate the System
2.Real-World Testing
- Attach the PSoC6 in wild life forest.
- Monitor
- predictions vs. actual failures.
As shown here in the next video the model is working even if the Ai kit is in a different noise enviroments
4. Section 2Steps to Implement the Project using EDGE IMPULSE Model.1- clone the original impulse.
https://studio.edgeimpulse.com/public/133765/latest
2-collect data and create label.
3- Generate Feature from the collected data.
4- Test deploy the impulse in the browser
3.Optimizations
- Adjust sampling rate..
- Fine-tune AI model thresholds.
- The PSoC6 will continuously monitor sounds around it.
- If Gunshoots sound are detected, it will trigger an alert (LED/UART message).
- Users receive early warnings for Gunshoot in the forest.
5. Conclusion
5. ConclusionThis project demonstrates how to:
- Stream real-time microphone data to DeepCraft Studio.
- Train an AI model for recognize Gunshoots.
- Deploy the model on PSoC6 using ModusToolbox.
- Detect Gunshoots early and alert users.
My Project github
https://github.com/eslamfayad/Gunshot_Detecion_System
My EdgeImpulse Project
Comments