Motion Detection Alarm System in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 มิ.ย. 2024
  • In this video, we build a motion detection alarm system, which recognizes movement in Python.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine.com/books/
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/
    Timestamps:
    (0:00) Intro
    (0:11) Preview
    (1:26) Coding Alarm System
    (15:44) Demonstration
    (18:47) Outro
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 55

  • @nopaallo1147
    @nopaallo1147 6 หลายเดือนก่อน +1

    Great presentation, detailed explanation, could not have asked for more

  • @Krishna-kb9ul
    @Krishna-kb9ul ปีที่แล้ว

    Dude this is awesome, i have been searching for almost same project, now i just need to alter it to meet my needs , thanks alot ❣️

  • @musabizimana3587
    @musabizimana3587 ปีที่แล้ว

    Thanks man, learning so much from these videos

  • @arek7198
    @arek7198 ปีที่แล้ว

    Thanks a lot, good presentation.

  • @tcgvsocg1458
    @tcgvsocg1458 ปีที่แล้ว

    thx a lot really interesting i will try it right now

  • @vincenzo3292
    @vincenzo3292 ปีที่แล้ว +1

    Thank you. Can you recommend a tutorial on how to set up a camera with a computer that runs this code? Appreciate your help.

  • @mehdimojaradi
    @mehdimojaradi ปีที่แล้ว

    You're really great 👍

  • @skgamedev
    @skgamedev ปีที่แล้ว

    Really good video

  • @francescologrillo443
    @francescologrillo443 ปีที่แล้ว +1

    thank you , can i have a hint how select different cam and send mail?

  • @vidya-laxmi
    @vidya-laxmi ปีที่แล้ว

    Impressive...One!

  • @musabizimana3587
    @musabizimana3587 ปีที่แล้ว

    is there a video on how to set up our IDE to look like yours?

  • @ndmdm1578
    @ndmdm1578 ปีที่แล้ว

    i use this motion on my program. i increase the value of threshold.sum to 1000 and even 9999 to verify if it work but still its sensitive to movement..what should i do?

  • @andystevens3474
    @andystevens3474 ปีที่แล้ว

    excellent video

  • @duscraftphoto
    @duscraftphoto ปีที่แล้ว

    This was great! One issue that I ran into (because I'm stupid and wasn't paying attention to what I was doing ha ha) is that the cam window has to be selected and in the foreground for the waitKey to be triggered by the key press. If the terminal is selected, it will just type the keyboard output to the terminal and do nothing.
    I'm sure I'm the only idiot that did this, but just incase anyone else made the same mistake... I figured I'd save you the waitKey Google sinkhole you may end up in ha ha.
    Keep up the great content, Flori!

  • @felixronnoh
    @felixronnoh 11 หลายเดือนก่อน

    Nice one.

  • @tcgvsocg1458
    @tcgvsocg1458 ปีที่แล้ว

    can you do a soft for card (like yugioh, magic ,pokemon) that add card show on camera to database with the number of card associate? that can be really itneresting

  • @tmusic1001
    @tmusic1001 11 หลายเดือนก่อน

    when I write 'cv2.' it doesn't show me its options like VideoCapture(), but I write it manually and it works properly how to fix it?

  • @zerlinalilin
    @zerlinalilin หลายเดือนก่อน

    works!, thanks!

  • @user-rm3ed8tr7z
    @user-rm3ed8tr7z ปีที่แล้ว +2

    Traceback (most recent call last):
    File "/Users/vladimir/Desktop/Projects_TH-cam/main.py", line 36, in
    difference = cv2.absdiff(frame_bw, start_frame)
    cv2.error: OpenCV(4.7.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:650: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'

    • @flarexlucifer
      @flarexlucifer ปีที่แล้ว

      i'm also getting same error

  • @charlesbanana6060
    @charlesbanana6060 10 หลายเดือนก่อน

    I don't know if you will still reply, but I want to get a smart bulb, and then turn it to a specific color after motion is detected. I can already turn the bulb on and off using voice commands and change is color. Do you think it will be possible this way? Plus, I also wanted to ask if you could give me a bit more details about the type of cameras I can use and how I can connect them to my computer etc. I want fire cameras dey up at the same point, pointing in all four directions.

    • @alertsByJarvis
      @alertsByJarvis 4 หลายเดือนก่อน

      How do u add python code into bulb?

    • @qwezxc23456
      @qwezxc23456 3 หลายเดือนก่อน

      ​There are Python libraries for smart bulbs. You connect to the bulb over wi-fi specifying it's IP address​ in Python code.@@alertsByJarvis

  • @shenzo00ff
    @shenzo00ff 8 หลายเดือนก่อน +1

    Anyone tell me how does he opens his camera/webcam in the video ?

  • @SiLiDNB
    @SiLiDNB ปีที่แล้ว

    Thanks

  • @Solexdballer
    @Solexdballer ปีที่แล้ว

    Awesome Dude......

  • @spike868
    @spike868 ปีที่แล้ว

    Cool

  • @benezer4937
    @benezer4937 11 หลายเดือนก่อน

    It didnt shows my webcam? My webcam light is turned on but its not showing any video

  • @meditation_and_focus245
    @meditation_and_focus245 ปีที่แล้ว

    boss my winsound is not producing any sound

  • @justacoder_
    @justacoder_ ปีที่แล้ว

    alarm_mode = not alarm_mode
    wow this is mindblowing lol

  • @gemini1014
    @gemini1014 ปีที่แล้ว +3

    I am having a prob
    AttributeError: 'NoneType' object has no attribute 'shape.'
    any support is appreciated

    • @kevinflanigan8653
      @kevinflanigan8653 ปีที่แล้ว +1

      Same problem here --> frame = imutils.resize(frame, width=500)

    • @kevinflanigan8653
      @kevinflanigan8653 ปีที่แล้ว

      Figured it out. Tabbing error. Duh!

    • @jamesfraser7394
      @jamesfraser7394 ปีที่แล้ว

      @@kevinflanigan8653 Very old newbie wondering what tab position should be?

    • @kevinflanigan8653
      @kevinflanigan8653 ปีที่แล้ว +1

      @@jamesfraser7394 I believe my problem was that I had the "key_pressed = cv2.waitKey(30)" statement and the two subsequent "if statements" indented too far to the right. Had pull the group back by one tab. I hope that helps.

    • @ladislav6291
      @ladislav6291 ปีที่แล้ว

      Hi there
      That's because your camera won't turn on, so there's no picture
      Try to change this
      cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
      for this
      cap = cv2.VideoCapture(0)
      I hope it helped you

  • @koongfu00
    @koongfu00 2 หลายเดือนก่อน

    How to make this work on a linux server without Qt?

  • @sarthaksingh7570
    @sarthaksingh7570 10 หลายเดือนก่อน +1

    This program was used in squid game Red light and green light...😅😅😅

  • @larianemouad4884
    @larianemouad4884 ปีที่แล้ว +1

    Anyone having troubles with the opencv lib, for me it can't find the references

  • @splou6777
    @splou6777 ปีที่แล้ว +1

    I have errors at import cv2 and impot imutils

    • @shenzo00ff
      @shenzo00ff 8 หลายเดือนก่อน +1

      Bro first install in cmd

    • @havocff4900
      @havocff4900 8 หลายเดือนก่อน

      ​@@shenzo00ffbro source code available ? Can u share the link

  • @philtoa334
    @philtoa334 ปีที่แล้ว

    Thx_.

  • @codenerd7823
    @codenerd7823 ปีที่แล้ว

    11sec only

  • @jamesfraser7394
    @jamesfraser7394 ปีที่แล้ว

    What is causing this...Very old inspired newbie asking.
    Traceback (most recent call last):
    File "/home/aladdinsane/vpyenv/detectmotion/detectmotion.py", line 21, in
    start_frame = imutils.resize(start_frame, width=500)
    File "/home/aladdinsane/vpyenv/detectmotion/lib/python3.10/site-packages/imutils/convenience.py", line 69, in resize
    (h, w) = image.shape[:2]
    AttributeError: 'NoneType' object has no attribute 'shape'

    • @jamesfraser7394
      @jamesfraser7394 ปีที่แล้ว

      I'm sure it's not opening the cam on my MacBook so no image.

    • @ladislav6291
      @ladislav6291 ปีที่แล้ว +2

      @@jamesfraser7394 Hi James
      Here is the code that works on mac
      You need import playsound and download some alarm ring :) enjoy
      import threading
      from playsound import playsound
      import cv2
      import imutils
      cap = cv2.VideoCapture(0)
      cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
      cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
      _, start_frame = cap.read()
      start_frame = imutils.resize(start_frame, width=500)
      start_frame = cv2.cvtColor(start_frame, cv2.COLOR_BGR2GRAY)
      start_frame = cv2.GaussianBlur(start_frame, (21,21), 0)
      alarm = False
      alarm_mode = False
      alarm_counter = 0
      def beep_alarm():
      global alarm
      for _ in range(5):
      if not alarm_mode:
      break
      print('ALARM')
      playsound ('/Applications/Sienna/songs/alert.wav')
      alarm = False
      while True:
      _, frame = cap.read()
      frame = imutils.resize(frame, width=500)
      if alarm_mode:
      frame_bw = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
      frame_bw = cv2.GaussianBlur(frame_bw, (5, 5), 0)
      difference = cv2.absdiff(frame_bw, start_frame)
      threshold = cv2.threshold(difference, 25,255, cv2.THRESH_BINARY)[1]
      start_frame = frame_bw
      if threshold.sum() > 300:
      alarm_counter += 1
      else:
      if alarm_counter > 0:
      alarm_counter -= 1
      cv2.imshow("Cam", threshold)
      else:
      cv2.imshow("Cam", frame)
      if alarm_counter > 20:
      if not alarm:
      alarm = True
      threading.Thread(target=beep_alarm).start()
      key_pressed = cv2.waitKey(30)
      if key_pressed == ord('t'):
      alarm_mode = not alarm_mode
      alarm_counter = 0
      if key_pressed == ord('q'):
      alarm_mode = False
      break
      cap.release()
      cv2.destroyAllWindows()

    • @jamesfraser7394
      @jamesfraser7394 ปีที่แล้ว

      @@ladislav6291 Thanks Ladislav!!!

    • @ladislav6291
      @ladislav6291 ปีที่แล้ว

      @@jamesfraser7394 You're welcome

  • @guilhermeschitzamaral8627
    @guilhermeschitzamaral8627 8 หลายเดือนก่อน

    ⥊ 55: 135
    0: Good (if not good, then not zero)
    1: Ethics
    2: Problem-Solution
    3: Consent
    4: Emotion/Will
    5: To Testify/To Meet
    6: Why/Who/When/How/Where/What
    7: Information
    8: Stability
    9: Sanity/Seriousness
    10: Network (Good Network, because zero)
    11: Justice
    13: Death
    16: Tower
    20: Judgement
    21: Solving Problems with Ethics
    22: Resistance
    23: Resilience
    30: Good Wave
    32: Discernment
    33: Sacred
    40: Good Force
    44: Free Love
    50: Good Expression
    55: War
    57: Counter-Terrorism
    60: Good Reason
    70: Good Information
    80: Good Stability
    90: Good Seriousness
    95: Only One Global Fiat Currency
    96: Blockchain
    97: Anarchy
    98: Vegan
    99: Revolution
    100: Liberation
    444: Direct Digital Democracy
    555: Diplomacy
    1000: Possible Conversation Method using numbers to convey meaning
    For ex.: 6022: Good Reason to Resist.