11.6: Computer Vision: Motion Detection - Processing Tutorial

  Рет қаралды 102,498

The Coding Train

The Coding Train

Күн бұрын

In this computer vision tutorial, I show how to analyze the pixels of a video to detect motion. This technique is also known as frame differencing.
Support this channel on Patreon: / codingtrain
Send me your questions and coding challenges!
Contact: / shiffman
Links discussed in this video:
Computer Vision for Artists and Designers Essay by Golan Levin: www.flong.com/t...
Image Processing in Computer Vision: openframeworks....
Source Code for the Video Lessons: github.com/Cod...
p5.js: p5js.org/
Processing: processing.org
For More Computer Vision videos: • Computer Vision
For More Coding Challenges: • Coding Challenges
Help us caption & translate this video!
amara.org/v/QbrN/
📄 Code of Conduct: github.com/Cod...

Пікірлер: 83
@paladin1147
@paladin1147 5 жыл бұрын
I thought I would really choke on this one because it seemed hard for me to comprehend but after checking the video twice and really focusing in, I got it. You really did such an amazing job on this one. I really appreciate what you do .Even after 2 years your learning people. Seriously! Best teacher man!!!
@bomggotge305
@bomggotge305 8 жыл бұрын
This is a best lesson I've ever seen.
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
I'm so glad to hear!
@philipbraatz1948
@philipbraatz1948 7 жыл бұрын
4:41 This whole time I thought you were just a floating torso until today
@ArthurPierrot
@ArthurPierrot 7 жыл бұрын
So funny when you dance :D I understand why no people disliked that video, it's soooo cool !! Great Job !
@beladn710
@beladn710 2 жыл бұрын
LOL the funniest programming course ever, it proves that the line between genius and madness is very narrow
@ayitsalex2893
@ayitsalex2893 5 жыл бұрын
Dude coders are allowed to have fun, our brains would catch on fire if we couldn't have a laugh while working :D
@martinboom01
@martinboom01 6 жыл бұрын
Hey man, you ruin my imaginations of adobe programmers skills :D It seems to me that adobe master collection should be done in a week !!
@lucianomartinez85
@lucianomartinez85 8 жыл бұрын
hello, since I met your channel (6 hours ago) I'm learning twice in college! I can not stop watching and wanting to know more. how do you explain is understandable, although I do not speak your language (I'm writing this on google translator). I have a question for you: manages to capture the moviento of a beam of light with background subtraction. but I need to replace the entire motion detected by figures (ellipses) to emulate the movement of light (infrared light) in a more visually appealing way. the violet ellipse ellipse (lerpX, lerpY, 36, 36); It is a single figure, following a movement. as I can make every pixel in moviento be replaced by hundreds of ellipses? Thank you!!
@lucianomartinez85
@lucianomartinez85 7 жыл бұрын
hello ! im from argetina , im a student in multimedial arts , where are you from?
@ShokoCC
@ShokoCC 6 жыл бұрын
Same here, I'm from Peru tho
@kikizhu1358
@kikizhu1358 4 жыл бұрын
Hey just wondering if there is a source code for this series. Coding train on GitHub only has 1-9 : (
@audreyli836
@audreyli836 6 жыл бұрын
Thank you for bringing so much fun to the lessons!
@twistedsim
@twistedsim 8 жыл бұрын
9:28 best.moment.ever
@theodoremichels756
@theodoremichels756 6 жыл бұрын
As always, thank you so much for creating such helpful content. I was trying to find the code from this lesson on GitHub, but didn't see it - does it exist anywhere else? Thanks in advance!
@tobiasmortier5102
@tobiasmortier5102 3 жыл бұрын
I tripple hit the like button when you started dancing xD keep it up
@naraendrareddy273
@naraendrareddy273 2 жыл бұрын
Now I have a question. We have detected the objects. But how do we calculate the velocity of the objects if we want to?
@bazaci
@bazaci 6 ай бұрын
All these videos are so helpful and fun. Thanks .
@bryphi77
@bryphi77 7 жыл бұрын
I finally have something of value to comment... yay!!! This works better if the loop is placed in the capture/movie event. Dan... You are the emperor of teaching. This series in particular has been so helpful to me. I have tried to implement a nearest point algorithm in the past and failed, but I was easily able to fallow along and actually learn and understand well the process. Thanks so so so so so much... again!!!!!!!!!!!
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
so glad to hear, thank you!
@nagarjunareddipaku678
@nagarjunareddipaku678 5 жыл бұрын
Hey at 11.12 sec there you have done betterjob. So I a have an idea about, can you make a program for that exactly 3d virtual frame( fix your face then when you giving input as your face to webcam when it matches to your frame as you did at 11.12, then only it has to take the image ) so can you do that. Or tell me where I can get that exactly. Please. Thank you
@MilanKarakas
@MilanKarakas 7 жыл бұрын
It will be very useful with addition of servo motors as an automated camera tracking. Thanks.
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
+WildMania great idea!
@faces_of_places
@faces_of_places 7 жыл бұрын
your lessons are just genius! thanks a 1000 times!
@prateekpriyaranjanpradhan3963
@prateekpriyaranjanpradhan3963 6 жыл бұрын
Sir , can we use this software and codes to interface other hardware devices? like taking the data output to give input to other devide?
@robertobrenes5283
@robertobrenes5283 2 жыл бұрын
Yes you can, there is a serial interface in processing as far as I know but I bet there are like 10 different ways to do that
@leamucho
@leamucho 6 жыл бұрын
Thank you Daniel!!! and also for the book!!! :D
@alessiaganzerla335
@alessiaganzerla335 Жыл бұрын
ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 1 this is what appears even if I copy and paste the code
@rodrigovasconcelos1660
@rodrigovasconcelos1660 3 ай бұрын
I'm also having this trouble
@vvzen
@vvzen 8 жыл бұрын
Great video, as always! Somebody knows a good webcam for macOS that can turn off auto white balance/exposure? Any tips or amazon links? I'd like to buy one for some experimentation with OpenCV. Thanks!
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
Would love to know myself!
@i.i
@i.i 6 жыл бұрын
I want to do this with p5.js :
@operationskate7
@operationskate7 6 жыл бұрын
I tried to replicate this in python with OpenCV but the double for loop calculation seemed to be taking way too long and made the stream look like a slide show. Any suggestions?
@operationskate7
@operationskate7 6 жыл бұрын
I tried using threads as well but that gave weird results.
@louen8413
@louen8413 2 жыл бұрын
Kind of late for a reply... but might be useful for someone else. I'm gonna guess, either you need a faster computer (not much you can do there except getting one), or a camera with a lower resolution, perhaps you're capturing video in FullHD or so, which makes the "for" loop waaaay slower. In his use case, with 640x480, it means the loop is iterating 307.200 times per frame, now, with FullHD (1920x1080) that would be 2.073.600 times, that's almost 7 times more interations, therefore, 7x slower.
@reactorscience
@reactorscience 7 жыл бұрын
Amazing tutorials, you make learning all this super easy and your dance is awesome too.
@TheCodingTrain
@TheCodingTrain 7 жыл бұрын
Thank you!
@TheLukinho94
@TheLukinho94 7 жыл бұрын
It is possible to move the function of the threhsold in a class and then recall it when a key is pressed?
@arhamcodes
@arhamcodes 6 жыл бұрын
Why it shows Null Pointer Exception when I try to copy video capture to previous image after video.read() method ?
@selvapriya4115
@selvapriya4115 5 жыл бұрын
i try to track white pixel in a image, when the pixel moves,it merge with non moving white pixels.. how can i seperate moving and non moving pixel in a image using opencv c++
@AdrienSales
@AdrienSales 4 жыл бұрын
As walays, great session. ANy hint on how to process a Youtbe live stream and perform that kind of stuff ? I saw your demo on P5.js, but not for processing. Thank you again.
@Chris-hr8lt
@Chris-hr8lt 4 жыл бұрын
hey i cant find the source code in the repository
@prajwalwaingankar3636
@prajwalwaingankar3636 4 жыл бұрын
@@hsbrathen1 sketch motion detection right?
@daviddg182
@daviddg182 7 жыл бұрын
Where do I find the p5.js version of this?
@guruteja7151
@guruteja7151 5 жыл бұрын
Is there a way to find out if a user is talking with in a image frames of video, I mean with out audio??
@Ejotei
@Ejotei 7 жыл бұрын
can someome help me please?! I need to make a processing file that increases the volume of a track by detecting motion from a webcam, I'm very new to all of this and managed to get the webcam and track working however I have no clue on how to get it to change volume based on motion.
@sarahkatecre8
@sarahkatecre8 6 жыл бұрын
Okay so.... all is fine and dandy except the rectangle that draws the black and white motion detection is stretched thin across the top of my canvas, and my webcam is a small square underneath - neither of which take up the entire canvas and the ellipse just stays in the center of the webcam drawing.... I assume this is due to the dimensions? Can't find what to change tho? Please help :(
@sarahkatecre8
@sarahkatecre8 6 жыл бұрын
Update.... Checked original source code used, to see if I just made an error myself and it still came up... "video = new Capture(this, cameras[3]);" (line 24 of source code given in link in description....) Changed [3] to [1] and it seemed to solve it for me... Leaving this up for anyone who comes across this in the future - let me know if it helps :o p.s. in case you couldn't tell, I don't have much experience in this... but that's why I watch these videos XD
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Glad you figured it out! You can try this: printArray(Capture.list()); This will show you all the various camera options/resolutions that are possible!
@sarahkatecre8
@sarahkatecre8 6 жыл бұрын
The Coding Train Thanks so much ☺
@tommyvanini9019
@tommyvanini9019 6 жыл бұрын
Hello to everyone. Dan, your videos are absolutely amazing! Thanks you for all the wonderful things that you teach us! I have a question, if someone is so kind to answer it. I tried to change the dimension of the window, but it seems to work only with 640x360, even if I changed the dimensions of the PImage too. The strange thing is that I tried to hard code the dimensions to 1280x720 and, even if my webcam can give me those resolutions: [0] "name=HP Truevision Full HD,size=640x480,fps=30" [1] "name=HP Truevision Full HD,size=176x144,fps=30" [2] "name=HP Truevision Full HD,size=320x240,fps=30" [3] "name=HP Truevision Full HD,size=352x288,fps=30" [4] "name=HP Truevision Full HD,size=640x360,fps=30" [5] "name=HP Truevision Full HD,size=1280x720,fps=10" [6] "name=HP Truevision Full HD,size=1920x1080,fps=5" [7] "name=HP Truevision Full HD,size=640x480,fps=30" [8] "name=HP Truevision Full HD,size=176x144,fps=30" [9] "name=HP Truevision Full HD,size=320x240,fps=30" [10] "name=HP Truevision Full HD,size=352x288,fps=30" [11] "name=HP Truevision Full HD,size=640x360,fps=30" [12] "name=HP Truevision Full HD,size=1280x720,fps=30" [13] "name=HP Truevision Full HD,size=1920x1080,fps=30" it works only with [4] and at size(640, 360), not other sizes. I think that the problem is in the nested for loop because sometimes it gives me the Array out of bound error. Does someone know how to fix this problem? If you do, I'd be very pleased to hear your solution. Again thank you Dan for your work!
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Would you mind asking at discourse.processing.org/! It's a better platform for Processing and p5.js related code questions. You can share code there easily! Feel free to link from here to your post.
@giacomoandrigo462
@giacomoandrigo462 6 жыл бұрын
Hi! I have a problem to solve. I would like that once a pixel become (let's say) black thanks to the motion, it stays black forever. The aim is to draw the path of a moving object. Any hint?
@danthemancasey
@danthemancasey 6 жыл бұрын
HINT? Create waspixelblack[loc] to store if each pixel was black, place in if statement... if threshold && waspixelblack == false. Anything more would surpass "hint".
@vilhovainio132
@vilhovainio132 5 жыл бұрын
Or you don't have background in draw
@DogwafflDan
@DogwafflDan 8 жыл бұрын
How about a video on gradient space compositing?
@cap-advaith
@cap-advaith 5 жыл бұрын
Nice
@mallikebadat7337
@mallikebadat7337 6 жыл бұрын
Sir, which language is good for computer vision?
@peterha2204
@peterha2204 5 ай бұрын
Never sorry to watch your videos!
@NansEverything
@NansEverything 7 жыл бұрын
could it be used with movie file like mp4 or mov??
@sarthakkumar150
@sarthakkumar150 5 жыл бұрын
Loved the dance
@SuperRandomdud
@SuperRandomdud 8 жыл бұрын
Is there a way of making this program locate multiple people at a time, about 20?
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
take a look at the more recent blob detection videos.
@peterhayman1789
@peterhayman1789 7 жыл бұрын
awesome! thisd be neat to use javas robot class to move the mouse! im hopin to use it to look around in skyrim :-)
@user-kz2xi4ef3r
@user-kz2xi4ef3r 6 жыл бұрын
best lesson....
@Avriox
@Avriox 8 жыл бұрын
How do you always "cool" algorithms to recreate in code?
@TheCodingTrain
@TheCodingTrain 8 жыл бұрын
Suggestions from others!
@TidalMaker
@TidalMaker 7 жыл бұрын
"I am a magic pink dot manipulator."
@user-ui2qk6jg5n
@user-ui2qk6jg5n 5 жыл бұрын
where can i find this code? did u upload it anywhere? thanks
@TheCodingTrain
@TheCodingTrain 5 жыл бұрын
I need to work on organizing this better but here you go! github.com/CodingTrain/website/tree/master/Tutorials/Processing/11_video
@geoffwagner4935
@geoffwagner4935 Жыл бұрын
Good t-shirts are the ones that need no explanation by the wearer
@thanapongpanichob4500
@thanapongpanichob4500 7 жыл бұрын
9.20 WTF!!! what the funnyyy hahahahah:DDDD
@shoaibmirza3082
@shoaibmirza3082 8 жыл бұрын
nice !
@furrane
@furrane 8 жыл бұрын
As always :)
@borjonx
@borjonx 6 жыл бұрын
MOTION DANCE DETECTOR!!!! mmChuh mmChuh mmChuh mmChuh mmChuh mmChuh mmChuh mmChuh --TheMagicPinkDotManipulator circa 2016
@dsorangerpvpandpve
@dsorangerpvpandpve 6 жыл бұрын
17:07
@prashanthkumar0
@prashanthkumar0 6 жыл бұрын
awesome dance 😂
@AWANIT22
@AWANIT22 7 жыл бұрын
if u r sending. send me separate code for each.
@JGunlimited
@JGunlimited 7 жыл бұрын
Links to code are in the video description.
@dndamian
@dndamian 4 жыл бұрын
dude! coders don't dance!
@TheCodingTrain
@TheCodingTrain 4 жыл бұрын
This coder does :) - The Coding Train Team
@dndamian
@dndamian 4 жыл бұрын
The Coding Train love your tutorials! Thank you for sharing the knowledge!!! Greetings from the galapagos islands
@dheepakgobinath4346
@dheepakgobinath4346 5 жыл бұрын
Paithiyam
11.7: Computer Vision: Blob Detection - Processing Tutorial
21:07
The Coding Train
Рет қаралды 129 М.
11.4: Introduction to Computer Vision - Processing Tutorial
22:52
The Coding Train
Рет қаралды 264 М.
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 54 МЛН
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 56 МЛН
小丑在游泳池做什么#short #angel #clown
00:13
Super Beauty team
Рет қаралды 40 МЛН
when you have plan B 😂
00:11
Andrey Grechka
Рет қаралды 61 МЛН
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 917 М.
10.7: Painting with Pixels - Processing Tutorial
13:48
The Coding Train
Рет қаралды 121 М.
Reveal Invisible Motion With This Clever Video Trick
14:20
Steve Mould
Рет қаралды 2,6 МЛН
Motion Detection Alarm System in Python
19:20
NeuralNine
Рет қаралды 39 М.
Coding Challenge 166: ASCII Text Images
22:42
The Coding Train
Рет қаралды 1,1 МЛН
12.1: What is the Kinect? - Kinect and Processing Tutorial
16:34
The Coding Train
Рет қаралды 198 М.
Coding Challenge #112: 3D Rendering with Rotation and Projection
33:13
The Coding Train
Рет қаралды 202 М.
AI can't cross this line and we don't know why.
24:07
Welch Labs
Рет қаралды 577 М.
I run untested, viewer-submitted code on my 500-LED christmas tree.
45:17
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 54 МЛН