Movement detector and capture whit telegram alarm, work in linux and windows.
git clone https://github.com/GUCHIHACKER/Movement_detector_telegram.git
cd Movement_detector_telegram
pip install -r requirements.txt
Create a telegram bot and add it to a group. Help Page
The chat id of the group can be found here https://web.telegram.org/a/#chat-id
In this part of the code change the bot token and in chatid for yours.
...
sound_enabled = True
token = 'your-bot-token' # Change to your telegram bot token
chat_id = 'your-chat-id' # Change to the chatid of the group you created
alarm_sound = pygame.mixer.Sound('alarm.mp3')
output_folder = 'images_alarm'
...
Change the number in this part of the code, if you want to do it with a secondary camera put the number 1 and if you have more than 2 cameras, 2,3,4,etc...
...
from tkinter import filedialog
pygame.init()
i = 45
e = 25
cap = cv2.VideoCapture(0) # Change this number to switch cameras (Default: 0)
audio_playing = False
start_time = None
prev_frame = None
...
Clearly you can change the alarm by changing the alarm.mp3 file to any other audio file clearly naming it the same name as the original one
python main.py
To stop the tool press the esc key.
The use of high quality webcams is recommended to improve detection, throughout the project I was using a 1080p action cam and it was great.
If you have a lot of problems with false positives due to camera quality or anything else you can change a parameter in the code.
...
motion_pixels = np.sum(thresh) // 255
if motion_pixels > 100: # The larger this number is, the less sensitive the detector is, change it if you have problems with false positives
if e >= 30:
threading.Thread(target=lambda: telegram_bot_msg(), daemon=True).start()
e = 0
...