Make A Security Camera With Python

Поделиться
HTML-код
  • Опубликовано: 4 июн 2024
  • Welcome back to another video! In this video, I'm going to show how to create a security camera system using OpenCV. We'll be detecting a face or body in the footage so a webcam or external camera that can connect to your computer is needed. We'll be using that camera through OpenCV and detecting a face or body before recording.
    💻 AlgoExpert is the coding interview prep platform that I used to ace my Microsoft and Shopify interviews. Check it out and get a discount on the platform using the code "techwithtim" algoexpert.io/techwithtim
    📄 Resources 📄
    OpenCV Tutorial Series: • OpenCV Python Tutorials
    Code In This Video: github.com/techwithtim/Python...
    OpenCV FourCC's: www.fourcc.org/codecs.php
    OpenCV HaarCascades: github.com/opencv/opencv/tree...
    Fix Pip (Mac): • How to Install Pygame ...
    Fix Pip (Windows): • How to Install Pygame ...
    ⭐️ Timestamps ⭐️
    00:00 | Overview
    01:15 | OpenCV Setup
    02:43 | Displaying Webcam Video
    06:35 | Detecting Faces and Bodies
    12:46 | Drawing Faces On Video
    16:09 | Saving And Recording Video
    20:25 | Security Camera Logic
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    💰 Courses & Merch 💰
    💻 The Fundamentals of Programming w/ Python: tech-with-tim.teachable.com/p...
    👕 Merchandise: teespring.com/stores/tech-wit...
    🔗 Social Medias 🔗
    📸 Instagram: / tech_with_tim
    📱 Twitter: / techwithtimm
    ⭐ Discord: / discord
    📝 LinkedIn: / tim-ruscica-82631b179
    🌎 Website: techwithtim.net
    📂 GitHub: github.com/techwithtim
    🔊 Podcast: anchor.fm/tech-with-tim
    🎬 My RUclips Gear 🎬
    🎥 Main Camera (EOS Canon 90D): amzn.to/3cY23y9
    🎥 Secondary Camera (Panasonic Lumix G7): amzn.to/3fl2iEV
    📹 Main Lens (EFS 24mm f/2.8): amzn.to/2Yuol5r
    🕹 Tripod: amzn.to/3hpSprv
    🎤 Main Microphone (Rode NT1): amzn.to/2HrZxXc
    🎤 Secondary Microphone (Synco Wireless Lapel System): amzn.to/3e07Swl
    🎤 Third Microphone (Rode NTG4+): amzn.to/3oi0v8Z
    ☀️ Lights: amzn.to/2ApeiXr
    ⌨ Keyboard (Daskeyboard 4Q): amzn.to/2YpN5vm
    🖱 Mouse (Logitech MX Master): amzn.to/2HsmRDN
    📸 Webcam (Logitech 1080p Pro): amzn.to/2B2IXcQ
    📢 Speaker (Beats Pill): amzn.to/2XYc5ef
    🎧 Headphones (Bose Quiet Comfort 35): amzn.to/2MWbl3e
    🌞 Lamp (BenQ E-reading Lamp): amzn.to/3e0UCr8
    🌞 Secondary Lamp (BenQ Screenbar Plus): amzn.to/30Dtafi
    💻 Monitor (BenQ EX2780Q): amzn.to/2HsmUPZ
    💻 Monitor (LG Ultrawide 34WN750): amzn.to/3dSD7tS
    🎙 Mic Boom Arm (Rode PSA 1): amzn.to/30EZw9m
    🎚 Audio Interface (Focusrite Scarlet 4i4): amzn.to/2TjXsih
    💸 Donations 💸
    💵 One-Time Donations: www.paypal.com/donate?hosted_...
    💰 Patreon: / techwithtim
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    ⭐️ Tags ⭐️
    - Tech With Tim
    - Security
    - OpenCV
    - Security Camera
    - Detecting Faces
    - Python
    ⭐️ Hashtags ⭐️
    #TechWithTim #SecurityCamera

Комментарии • 190

  • @Nostra.Damus14
    @Nostra.Damus14 2 года назад +299

    I think the best programming tutorial a youtuber can make is teaching how to read a module documentation efficiently and intuitively.

    • @tonystark3399
      @tonystark3399 2 года назад +9

      Absolutely true. If you find any please share it with mam/ sir

    • @animaluchisommicheal7622
      @animaluchisommicheal7622 2 года назад +2

      Couldn't agree more!!

    • @ZahidHasan-cc8tf
      @ZahidHasan-cc8tf 2 года назад

      Yes!

    • @tonymudau3005
      @tonymudau3005 2 года назад +2

      I see some bots in these chats ... really good bots ... check the comments carefully

    • @TechMalaya
      @TechMalaya 2 года назад

      yes, I am agree because this is the hardest part

  • @janisvelbergs6394
    @janisvelbergs6394 2 года назад +97

    Tim, you are the best. I hope there will be continue of this series (at least part two):
    1.) Manage files (delete records older than some period)
    2.) Notification on e-mail about new record
    3.) ... and more features with Python
    Tim, thank you for your RUclips content! ;)

    • @benfou2140
      @benfou2140 2 года назад +3

      Easy to find. Tim is just introducing the subject

  • @shftn2gear97
    @shftn2gear97 2 года назад +10

    The stuff you do for this community at no charge is just amazing. Thanks, Tim!

  • @sagshah10
    @sagshah10 2 года назад +8

    Great video as always Tim, I cant even imagine how stressful it must be to try to code and explain, but just thought I mention that for future it might help to include comments on your code as it will help reduce the amount of explanation you would need to do, and is usually better practice right. Thanks again for your awesome content.

  • @vishwanath-ts
    @vishwanath-ts 2 года назад +3

    Tim you're doing a great job!!
    Keep up the good work!!👍🏻

  • @kitgary
    @kitgary 2 года назад +20

    This guy is one of the best developer in the world!

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад +6

      Hes good at best not really the best

    • @johnwig285
      @johnwig285 2 года назад +1

      @@Bruh-sp2bj He said ONE of the best not the best. Ffs.

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад +4

      @@johnwig285 not even one of the best ffs. Decent

  • @wrangleroffroad4318
    @wrangleroffroad4318 2 года назад

    I like the way you explain and present your code, especially at the end of video wrapping up is really helpful. Thank you for awesome content!

  • @hedimak999
    @hedimak999 2 года назад +1

    you are such a great explainer dude ! honestly the video is simple to understand , concise and very very informative !!! you helped me a lot !

  • @shanerobins1329
    @shanerobins1329 2 года назад +1

    Tim, thanks for the example, very good.

  • @CKTEH9898
    @CKTEH9898 2 года назад +1

    I think I had complete the feature mention earlier in the vedio, but i will still follow this series to seek the better way of doing it.

  • @RunTheProgram
    @RunTheProgram 2 года назад +3

    when he creates a variable more than 10 letters long, you know his a legend

  • @ChiefRemoteOfficer
    @ChiefRemoteOfficer 2 года назад

    Damn, that is some good stuff. That CV library looks comprehensive. Thanks for sharing!

  • @FreshBrothersCZ
    @FreshBrothersCZ Год назад

    Very well explained, good job man!

  • @theGoogol
    @theGoogol 2 года назад

    Learning Python ... subbed because your content turns out to be HQ lessons.

  • @rcsteimer
    @rcsteimer 2 года назад +6

    To make your video start faster add this code to define some of the video parameters. It will cut the start of the video in half or more.
    cam=cv2.VideoCapture(1,cv2.CAP_DSHOW)
    cam.set(cv2.CAP_PROP_FRAME_WIDTH, width)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT,height)
    cam.set(cv2.CAP_PROP_FPS, 20)
    cam.set(cv2.CAP_PROP_FOURCC,cv2.VideoWriter_fourcc(*'mp4v'))

  • @tonymudau3005
    @tonymudau3005 2 года назад +1

    Thanks Tim... you are an amazing gent 🙏

  • @harrypoon2438
    @harrypoon2438 2 года назад +10

    I would love to see you talk about using a camera wirelessly (for instance using a raspberry pi with an esp32 cam)

    • @Joe-zg9eq
      @Joe-zg9eq 2 года назад +1

      Ig what you can do is give it a lot of storage and set up a ssh system so that you can wirelessly control your raspberry pi and thus you could see the recordings from anywhere in the world

    • @CharlieCocalon
      @CharlieCocalon Год назад

      Im following.

  • @4bt862
    @4bt862 2 года назад +1

    The best Python guy that creates a social engineering tools

  • @trevormckellen5613
    @trevormckellen5613 2 года назад +7

    after the opencv tutorials. this is just what i need

  • @melissaleigh3013
    @melissaleigh3013 2 года назад +2

    Tim, this is sooooo cool

  • @septimusseverus252
    @septimusseverus252 2 года назад +1

    This channel is simply a treasure

  • @Raahim
    @Raahim 2 года назад +3

    i literally just looked up how to detect motion with python on my 2nd monitor.... looked over on my 1st monitor youtube, and this video popped up!

  • @prestonwallitsch8636
    @prestonwallitsch8636 2 года назад +1

    This is really cool!

  • @konstantinosadamis2130
    @konstantinosadamis2130 2 года назад

    great work tim!

  • @sovereignlivingsoul
    @sovereignlivingsoul 4 дня назад

    excellent video, thanks for sharing, with that last statement regarding showing the video frame, i use a raspberry pi, could you set a key press that will show the current video, as if you wake up to a sound and hit the key to show the camera live view

  • @manu-gt9gr
    @manu-gt9gr 2 года назад +2

    this the type of videos i wana watch, thanks bro!

  • @FnanAsfaha
    @FnanAsfaha 8 месяцев назад

    I like it you are actually a genius

  • @soapcarvingasmr7686
    @soapcarvingasmr7686 2 года назад

    Best Developer in the World

  • @youssefelamrani7905
    @youssefelamrani7905 2 года назад +3

    heey Tim great video, which is better : build our own classifier or use the built in classifiers for safety and robustness reasons like if someone is building a bank security system, and how can we use this open cv code to interact with a real camera like in banks, thanks budy

  • @CallumForster
    @CallumForster 2 года назад +2

    What module do I need to make the import command colour be red and not the pink colour it usually is

  • @ryanwalker4660
    @ryanwalker4660 Год назад

    I followed along and got a working security program written in python, awesome thank you very much. I've just started learning Python but I've watched a few of your videos, the others being the python curses/ncurses tutorials, awesome videos and explanation of the examples. Thank you.
    *** how can I redirect where the video gets saved, as of now all files are saved in the directory where the script resides in, thanks.

  • @tanmaypatel4152
    @tanmaypatel4152 2 года назад +1

    Nice video, Tim👍

  • @Dalan76
    @Dalan76 2 года назад

    Great tutorial !!

  • @ilikeyoursmile6215
    @ilikeyoursmile6215 2 года назад +1

    Hey Tim, What is your Color Theme do you use? Mine are kinda boring I want to change to something and I think what you're using is gonna work.

  • @kolboy2028
    @kolboy2028 2 года назад

    hey tim, great video. can you please tell me how can I record the audio along with the video?

  • @LamethHUN
    @LamethHUN 2 года назад +12

    Great video! One small bug: You are using the same cascade for body and face:
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    bodies = face_cascade.detectMultiScale(gray, 1.3, 5)

    • @Hog-n
      @Hog-n 2 года назад +3

      My detectMultiScale isnt working it just gives me an error

    • @ABODY734
      @ABODY734 2 года назад

      @@Hog-n same here :(

  • @tonyd2776
    @tonyd2776 2 года назад +2

    I’m 43 yrs old and want to be as smart and articulate as this kid when I grow up

  • @BeRaikwal
    @BeRaikwal 2 года назад +1

    dude i just wanna take ur blessing ahahahaha U ARE SO GOOD AT IT

  • @cjay9615
    @cjay9615 2 года назад

    Legend, thank you

  • @fastmamajama
    @fastmamajama 18 дней назад

    awesome stuff. i wrote a camera app in android but it is really hard. i got a camera in my roof that records things that fly over my house. i want to set up a python camera that will record only birds but the end goal is record ufos. that kinda script would be priceless for the ufo community.

  • @hectorbarrera9496
    @hectorbarrera9496 2 года назад

    Excellent video, thank you, so I have one question, can I do the same with an ip camera?

  • @ihatethesensors
    @ihatethesensors 2 года назад

    Very very interesting!

  • @suphotnarapong355
    @suphotnarapong355 Год назад

    Thank you very much

  • @justchris846
    @justchris846 2 года назад +2

    Do you have a tutorial showing how to set up visual studio code?

  • @hammad8954
    @hammad8954 2 года назад +2

    Great Video! could make a part two in which the webcam detects a person and opens a door if the right person's face is detected. It would be really cool!

  •  2 года назад +2

    Great stuff. Possible bug on line 25.

  • @tcgvsocg1458
    @tcgvsocg1458 2 года назад +3

    Its really good!
    Can you show how to creat a screen recorder in python

  • @samsonnxumalo392
    @samsonnxumalo392 Год назад

    Thanks Tim

  • @AndreiDante
    @AndreiDante 2 года назад

    Can you make a body tracer that gives same input as a keyboard? For example: if you lower your upper body to the right (keeping legs in the same place, facing the camera), this move would be equivalent to you pressing right arrow key. Is that possible in pure python?

  • @thinkfacts2225
    @thinkfacts2225 2 года назад

    tim you are amazing love from india

  • @heineken2295
    @heineken2295 2 года назад

    thx for the tutorial)))

  • @eaircelle3263
    @eaircelle3263 2 года назад

    Hello Tim,
    sorry, but nothing more than the many tutorials on this subject.
    I would have hoped from you that you would divide the screen for four cameras,
    that you say after 5 seconds start cam 1, the body is in front of cam 2 so it starts after the first one goes off if it detects a body.
    I would have wanted you to show how the video can take a photo when you detect the face ... ect
    but you still the best;)

  • @tejasvmaheshwari5658
    @tejasvmaheshwari5658 2 года назад +1

    Could you please make a video on easing-functions?

  • @WHOAMI-xx3lx
    @WHOAMI-xx3lx 8 месяцев назад

    thank you so much

  • @Venaber
    @Venaber 2 года назад

    Thank you

  • @disrael2101
    @disrael2101 2 года назад +2

    your explanation skills are exceptional.. you know exactly when it start become confusing and then you stop and explain it.. every line is explained.. i couldn't ask for a better tutorial.. i literally feel it's like a private tutorial 1on1.. exceptional work.. just one question on line 38 when the result is false isn't it just goes to the if statement on the line above aka line 37 and hence it will never check if there's a 'new' body/face? or when the if is false it returns to the upper most scope?

  • @HamzaArslan
    @HamzaArslan 2 года назад +16

    Me when my code doesn't run properly: 13:29
    Me when my code does work: 13:28

  • @kakissakis1997i
    @kakissakis1997i 2 года назад

    hello TIM you are the best youtuber/programmer python spesialist for me..i am a new programmer i lvoe python and i am making tons of your videos to practise and get any better in this..so if you can make a video of this camera project to make it even better?perhaps send an email notification on your phone or somethink like that? thx a lot

  • @JAHNAVITBBTCS
    @JAHNAVITBBTCS 2 года назад +1

    Sir once we record the recording will be save to our local system. How can we upload or store the recording made by the webcam to cloud?

  • @podcastdzfan
    @podcastdzfan 2 года назад

    you re the best

  • @LayprangTradder
    @LayprangTradder 2 года назад

    Thank bro..

  • @deshansalitha2477
    @deshansalitha2477 2 года назад

    thanks for project

  • @evilwizard7931
    @evilwizard7931 2 года назад

    I had to fix the pipX install on my friends windows box, python nor was pip wasn't in the path & pipenv wasn't installed. The hardest part for me was trying to find out where python (& pipenv) lives on windows so I could just add them myself to the system environment. Once the windows system knows where python is, the Tim way works. I was thinking you should write a python module app script to try the various methods of install, then realised, you'd need to have installed that module to use it (segfault: redo from start lol)

  • @joiker2pen
    @joiker2pen 2 года назад +2

    Where do business save these video recordings usually? on a local server or in some cloud? if the cloud how do they connect the cameras to there?

    • @DarkGharren
      @DarkGharren 2 года назад +7

      Normally you would save it on a local device. I don't really see the point in having it in a cloud, unless maybe you employ a separate security firm that needs access to the data. You also probably wouldn't stream directly to a cloud (raw video data is huge), it makes more sense to encode the data locally and then send the completed file to the cloud.

  • @emanuelcara316
    @emanuelcara316 2 года назад +1

    How can we generate data from this program? For example to generate data in a database, location or how many different people where spotted in different time period?

  • @rickysonarcix9830
    @rickysonarcix9830 2 года назад

    very cool 😎

  • @agneaybnair9519
    @agneaybnair9519 2 года назад +2

    Hey Tim can you please create a video on regular expressions in python

  • @ziyad7780
    @ziyad7780 2 года назад

    Amazing

  • @ABODY734
    @ABODY734 2 года назад +1

    Hi amazing video like always but i have an error after writing
    { faces = face_cascade.detectMultiScale(gray, 1.3, 5) } if i remove this line it's works what should i do ?

  • @steveburrows4747
    @steveburrows4747 2 года назад +1

    what coding platform did u use, please I really want to do this and I love your vids

  • @kadirgurani2162
    @kadirgurani2162 2 года назад +1

    Could you add some code to detect somebody ‘s face and this give some output like opening a door???

  • @emanuelbarreira2007
    @emanuelbarreira2007 2 года назад

    to end the delay of turn on the camera, jus do this: cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)

  • @mak448a
    @mak448a 5 месяцев назад

    Who misses this Tim who didn't make hyper-stimulating videos?

  • @bereck7735
    @bereck7735 2 года назад +1

    Nice

  • @wrestelman1
    @wrestelman1 2 года назад +1

    Any idea on how to make it work where it doens't record YOU but everyone else?

  • @borceacasian7425
    @borceacasian7425 2 года назад +1

    what IDE are you using in combination with tabnine?

    • @TeoHandle
      @TeoHandle 2 года назад

      Sublime Text bro

  • @lolexXD.
    @lolexXD. 8 месяцев назад

    Can u make when u turn pc on to you get notification on phone that your computer turned on?

  • @nospill_kunai6192
    @nospill_kunai6192 2 года назад

    What if I wanted to make a face ID thing, where my computer would do something when I enter it's camera?

  • @mocerlaalacbaino
    @mocerlaalacbaino 2 года назад +1

    "this is your daily dose of internet"

  • @theplant4046
    @theplant4046 Год назад

    Question what if camera detect a person wears mask like hiding his face does program start recording?

  • @svoper3338
    @svoper3338 2 года назад +2

    Does this work with a phone camera

  • @solmanpalestinian
    @solmanpalestinian 2 года назад

    Can you make a program to detect thermal cameras?

  • @mhdmodocluber9591
    @mhdmodocluber9591 2 года назад

    It’s okay, but how can I transmit image by RTSP protocol?

  • @colourfultoreador8467
    @colourfultoreador8467 2 года назад

    cool video

  • @raymondperez7970
    @raymondperez7970 Год назад

    Import cv2 doesn’t work for me, what else can I do? I love your videos

  • @mantravora6119
    @mantravora6119 5 месяцев назад

    If i do it laptop, will it require external camera or not?

  • @crimsonflash-eo2xs
    @crimsonflash-eo2xs Год назад

    What algorithm does this use?

  • @SKTWoodDesign
    @SKTWoodDesign 2 года назад

    Nice .How can I run multiple camera using this code?

  • @Motopysch
    @Motopysch Год назад +1

    How can it detect the difference between family persons faces and real theft persons??

  • @abdsaad
    @abdsaad 2 года назад

    What editor is he using

  • @roscianyt
    @roscianyt 2 года назад

    cap = cv2.VideoCapture(0, cv2.CAP_DSHOW) will open fast

  • @vaidhyanathansm7625
    @vaidhyanathansm7625 2 года назад +8

    Aren't we supposed to use body_cascade (for bodies) in line 23 ?

  • @stevehoward8671
    @stevehoward8671 2 года назад

    What about using a stream from an IP camera?

  • @SztiviBig
    @SztiviBig Год назад

    correkt

  • @cll-dy8bd
    @cll-dy8bd 2 года назад

    I have no idea what this guy is saying, but im really interested

  • @nicolapesce8911
    @nicolapesce8911 2 года назад

    it doesn't save the videos at the end of the recordings. I already checked in the folder when the code is saved.

  • @zephic6276
    @zephic6276 2 года назад

    Machine learning with EMG sensor plz

  • @seyedmohsen2306
    @seyedmohsen2306 Год назад

    Hi
    How about audio
    How read video and audio together

  • @youssefelamrani7905
    @youssefelamrani7905 2 года назад +1

    i have a problem in line 23, i'm using Collab and it gives me this error : OpenCV(4.1.2) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor

  • @AddersOtter
    @AddersOtter 2 года назад

    Lol I put the timestamp generation + assignment to 'out' on the wrong side of the if/else conditions, and that caused a file to generate every few frames/every second in real time.