OpenCV Python Tutorial #3 - Cameras and VideoCapture

  Рет қаралды 166,117

Tech With Tim

Tech With Tim

Күн бұрын

Welcome to this Python OpenCV tutorial. In this video, I'll be talking about cameras and video capture within OpenCV. Specifically, I'll be showing you how we can load our webcam, how we can view that in live time, and how we can manipulate the image from the camera feed.
💻 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
📄 Relevant Documentation: opencv-python-tutroals.readth...
📝Code For This Series: github.com/techwithtim/OpenCV...
🔍 Playlist: • OpenCV Python Tutorials
⭐️ Timestamps ⭐️
00:00 | Introduction
00:50 | Displaying video capture device
07:11 | Mirroring video multiple times
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
💰 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 KZbin 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 ⭐️
- Images within OpenCV
- Image Manipulation OpenCV
- Image Fundamentals OpenCV
- Python
- Computer vision
- Cameras and video capture
⭐️ Hashtags ⭐️
#OpenCV #Python #CameraCapture

Пікірлер: 135
@kingchavez152
@kingchavez152 3 жыл бұрын
What the heck i just started learning opencv and i found you channel and you just started uploading tutorials. Perfect lol
@barrotem5627
@barrotem5627 3 жыл бұрын
I am about to finish a face recognition project using OpenCV and this appears to be a great series for those who wish to learn the basics. Ty so much Tim ! You make a difference for the future generations 😎
@brendanhealy7226
@brendanhealy7226 3 жыл бұрын
Great video as always Tim. For anyone who is interested, here is a function to rotate the image to any chosen angle. def rotate(img, angle, rotPoint=None): (height, width) = img.shape[:2] # set rotation point as center of image if not specified if rotPoint is None: rotPoint = (width//2, height//2) rotMat = cv.getRotationMatrix2D(rotPoint, angle, 1.0) dimensions = (width,height) return cv.warpAffine(img, rotMat, dimensions)
@codingwithflavio8534
@codingwithflavio8534 2 жыл бұрын
IT DOESNT WORK
@twentylush
@twentylush 2 жыл бұрын
works on my end 👍
@codingwithflavio8534
@codingwithflavio8534 2 жыл бұрын
@@twentylush it doesnt your wrong, im right
@sunwukong6268
@sunwukong6268 3 жыл бұрын
Thanks again. Very nice tutorial, I really like these. And I like the fact, that you run into errors and show what could happen and how to possibly handle these errors.
@leonvanzyl
@leonvanzyl 3 жыл бұрын
Hi Tim, I'm a recent subscriber to your channel. I've been coding now for 13 years, but is new to Python. Your knowledge is impressive young man, and your explanations are crystal clear. Keep up the brilliant work!
@cherifboumaiza147
@cherifboumaiza147 2 жыл бұрын
You are great in the way you explain things ! That shows a lot of control to what you do ! Thanks a lot
@jameswilkinson8851
@jameswilkinson8851 3 жыл бұрын
I like this series, very easy to follow as always, looking forward to the next one.. Thank You.
@MarceloRodrigues-yx3ty
@MarceloRodrigues-yx3ty 3 жыл бұрын
Looking forward for part #4... Thank you for the awesome tutorials.
@avivran1198
@avivran1198 2 жыл бұрын
Hi. great stuff for opencv beginners. thanks for the goodwill and the work done to make these videos available
@droneguy69
@droneguy69 2 жыл бұрын
Great tutorials Tim. Keep making them.
@abdullatifnizamani6850
@abdullatifnizamani6850 4 ай бұрын
You explained everything so simply and details
@draytonlav
@draytonlav 3 жыл бұрын
Cool project! Just finished!
@HarshanGandamalla
@HarshanGandamalla 11 ай бұрын
thank you tim..It's great learning CV
@TopMusic-rw3yz
@TopMusic-rw3yz 2 жыл бұрын
Great tutorials!!!!!!!!!!
@ananthramvijayaraj4554
@ananthramvijayaraj4554 3 жыл бұрын
Love your vids tim!! Excited for the codejam 3 results
@binaprajapati3593
@binaprajapati3593 3 жыл бұрын
Same here
@ananthramvijayaraj4554
@ananthramvijayaraj4554 3 жыл бұрын
What was your teams name?
@binaprajapati3593
@binaprajapati3593 3 жыл бұрын
@@ananthramvijayaraj4554 didn't participate, but nice to see the video to get project ideas
@ananthramvijayaraj4554
@ananthramvijayaraj4554 3 жыл бұрын
@@binaprajapati3593 ahhh even that’s pretty fun, you should participate next time
@CodingWorm
@CodingWorm 3 жыл бұрын
Part 4 Coming Soon, he should have said
@KSATica
@KSATica Жыл бұрын
thank you thank you your video tutorial helped....
@jollokim1948
@jollokim1948 3 жыл бұрын
This is awesome
@NHY6CK
@NHY6CK 7 ай бұрын
I had to make some changes to make the code work for me but at the end it did so thanks! I love it
@rontarrant
@rontarrant 4 ай бұрын
Please share the changes you made.
@shaulchamoula4863
@shaulchamoula4863 3 жыл бұрын
Hi Tim, Thank you SO much, What do you think of alpr (Automatic License Plate Recognition)? First recognize plate/s then recognize digits in plate.
@omereid7525
@omereid7525 2 жыл бұрын
THANKS VERY GOOD
@rafiksalmi2826
@rafiksalmi2826 Ай бұрын
Thank you
@pranitg2039
@pranitg2039 3 жыл бұрын
15:30 Tim, Can we somehow make use of the .T Attribute of numpy ndarray so as to swap the the height and width?
@ihatethesensors
@ihatethesensors 2 жыл бұрын
Awesome tutorial man! Btw, you can still do it with the 4 different rotations if they are all squares. It looks really trippy... Here's the code: import numpy as np import cv2 cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() h = frame.shape[0] w = frame.shape[1] strip = abs(w - h)//2 edge = min(w, h) square = np.zeros((edge, edge, frame.shape[2]), np.uint8) square = frame[:, strip:-strip] small = cv2.resize(square, (0, 0), fx=0.5, fy=0.5) square[:edge//2, :edge//2] = cv2.rotate(small, cv2.ROTATE_90_CLOCKWISE) square[edge//2:, :edge//2] = cv2.rotate(small, cv2.ROTATE_180) square[:edge//2, edge//2:] = cv2.rotate(small, cv2.ROTATE_90_COUNTERCLOCKWISE) square[edge//2:, edge//2:] = small cv2.imshow('frame', square) if cv2.waitKey(1) == ord('p'): break cap.release() cv2.destroyAllWindows()
@hedimak999
@hedimak999 2 жыл бұрын
yooo dude thanks , im learning facial recognition and rotating 90 deg angles is needed for that , thank you for your addition.
@vatsaplaysguitar
@vatsaplaysguitar 2 жыл бұрын
amazing tutorial tim, im not getting the auto predict/ complete thingy in my sublime text like you, how do i enable/fix this?
@HipHop-cz6os
@HipHop-cz6os 3 жыл бұрын
Will u upload videos on object detection using yolo?
@alijebrailzade7439
@alijebrailzade7439 3 жыл бұрын
Hello Tim can you make a video "python STATIC TYPING with mypy"? It turns dynamic language to complete static language.
@steventeasdale9082
@steventeasdale9082 5 ай бұрын
Hi Tim, I know you did these videos a few years ago now, but I am just starting out with OpenCV and have begun watching your videos, I don't have a "webcam", is there anyway I can use the camera attached to my Raspberry PI 4/5?? Do I need to SSH into my Pi? Any help much appreciated!! Great videos, keep em coming
@moralexbme
@moralexbme Жыл бұрын
Thank you for this tutorial! I am using a fisheye camera with multiple viewing angles where i can change then number in the link (cap = cv.VideoCapture('blablabla/mjpg/4
@harshalghatol4182
@harshalghatol4182 3 жыл бұрын
A quick question ,could we have also used frame.shape[1] instead of cap.get(3) as well as for height? if we could or could not , can you please justify.Thank You for such a good video.
@TechWithTim
@TechWithTim 3 жыл бұрын
Yep!
@Chorum1975
@Chorum1975 2 жыл бұрын
Really nice video! May you explain how to get that video into a Frame or Label without using Pillow? If i use Pillow the video is very slow ...
@py_tok5589
@py_tok5589 3 жыл бұрын
LOVELY
@lessonscript
@lessonscript 3 жыл бұрын
@itsjxelito
@itsjxelito 2 жыл бұрын
use cv2.VideoCapture(0, cv2.CAP_DSHOW) If cv2.VideoCapture(0) is taking awhile to display webcam
@giochkhaidze7234
@giochkhaidze7234 Жыл бұрын
THANKS
@xinglinjiang4952
@xinglinjiang4952 2 жыл бұрын
at what point the physical camera start to work? i am try to precisely control the starting time of two identical cameras so they can be frame synchronized. first i would like do it by software. but i can also div the hard ware (the easist way should be starting the power supply at the same time by a shared switch).
@Nikiwe_
@Nikiwe_ 2 жыл бұрын
Thanks a lot Tim. How do I use a different camera, for example, proscilica cameras. Do I have to use its IP address like cv2.videocapture(‘IP address’)? Or do I have to say cv2.videocapture(1)?
@Meganano
@Meganano 2 жыл бұрын
the first if it doesnt connect via usb👍
@MK-vd4yx
@MK-vd4yx 2 жыл бұрын
Nice T-shirt buddy
@aaravgp1332
@aaravgp1332 3 жыл бұрын
how can we record the video into another video or screen share using openCV or add frames to an existing video.
@oOWaschBaerOo
@oOWaschBaerOo 2 жыл бұрын
i have one big issue with open cv, in that i cant change the size of the resulting window manually, by dragging the sides or clicking on maximize, is there a way to achieve this with open cv ?
@jn7071
@jn7071 2 жыл бұрын
Hi, I am now to Python, which platform you use to run the python script?
@viveknayar8677
@viveknayar8677 2 жыл бұрын
Hey, so why did we not create a canvas or array when displaying video capture device? ps: great video!
@parth2teja
@parth2teja 3 жыл бұрын
Exact 1000th viewer and 100th liker
@justwatchv
@justwatchv 3 жыл бұрын
❤️❤️❤️
@electronicmag16
@electronicmag16 3 жыл бұрын
Is there a better way to select the devices than by arbitrary number? Like for instance by name of the device or usb port of the webcam? I had looked into it but I could only find python-c++ solutions, which were effective, but rather complicated... Wondering if you knew a better solution Tim. Thank you :D
@Aminoquiz
@Aminoquiz Жыл бұрын
Hi, did you find one ? I can't figure which number is my plugged-in webcam...
@adanflores4410
@adanflores4410 Жыл бұрын
@@Aminoquiz me too, now you know?
@ico-theredstonesurgeon4380
@ico-theredstonesurgeon4380 3 жыл бұрын
how does that comma in the square brakets work?
@josuenlandu8907
@josuenlandu8907 2 жыл бұрын
Thanks a lot Tim for all. I have a concern about Third video : OpenCV Python Tutorial #3 - Cameras and VideoCapture. When I run the code, the webcam opens, but only for a fraction of a second. I send the capture in the appendix.
@josuenlandu8907
@josuenlandu8907 2 жыл бұрын
I couldn't send the capture
@mrtechtonics2209
@mrtechtonics2209 Жыл бұрын
Hey which IDE do you use?
@adityapradhan7201
@adityapradhan7201 3 жыл бұрын
I press q, the window is destroyed but cap.release() doesn't free up my webcam resource. Can you tell me what could be the issue here?
@kouseiarima8805
@kouseiarima8805 Жыл бұрын
Is it possible to access another e.g. camera of another pc, like you are the admin and accessible only to you?
@ahmedzia7000
@ahmedzia7000 2 жыл бұрын
HI! How can i save a video without displaying the video on monitor i tried commenting out cv2.imshow and also the waitkey but it saves the video which doesnot open like sort of a damaged file
@duygukocar7623
@duygukocar7623 Жыл бұрын
Can I use Ip camera port and ip address in 2:12 ? Can I record some part of Ip camera video?
@dhxbcmd
@dhxbcmd 2 жыл бұрын
thank you for your lecture wonder Start video recording key = 'F5' Video recording pause key ='F6' End section (off) key ='q' If you can tell me how to do it, thank you.
@pranaygundu
@pranaygundu 3 жыл бұрын
hey "tech with tim youtube ":) , I just started open cv course and I am really enjoying it :). but should I need to master the math behind openCV functions ???? to be a good programmer .........whatever :) ...........
@ersinbardakc
@ersinbardakc 3 ай бұрын
I am mirroring android phone screen to pc. Can I use that screen for opencv ?
@ahmed.m.haniya
@ahmed.m.haniya 3 жыл бұрын
👌👍
@unsalpisirgen9204
@unsalpisirgen9204 2 жыл бұрын
how do i count people passing by a camera can you help me with this. The camera is looking at people from above and I want to count the people passing under it. How do I do it?
@klintkrossa6885
@klintkrossa6885 3 жыл бұрын
I would like to display current temperature on a black back ground. how do I make an infinite loop black screen? Then how do I add the text?
@jonasstrabel
@jonasstrabel 3 жыл бұрын
Why would you use cv2 if you just want to display text with black background?
@klintkrossa6885
@klintkrossa6885 3 жыл бұрын
@@jonasstrabel to have a display for a webpage that is dynamic, like temperature.
@jonasstrabel
@jonasstrabel 3 жыл бұрын
@@klintkrossa6885 I don't thing open cv2 is the way to go for that matter.
@madstudios1688
@madstudios1688 Жыл бұрын
how can i make my own python 3d camera tracker? i want to learn how extract camera motion data from imagine sequence and use it in a 3d program
@subba5735
@subba5735 2 жыл бұрын
Can you please make video about black background on image
@gustavojuantorena
@gustavojuantorena 3 жыл бұрын
First :D
@technohub4348
@technohub4348 2 жыл бұрын
Hey @Teach With tim please help me with this problem opencv camera frame black !!
@yashwanthj9305
@yashwanthj9305 Жыл бұрын
I am getting error has no attribute video capture in cv2 module how to overcome it
@tomherbert5396
@tomherbert5396 2 жыл бұрын
Is this possible thru a browser?
@loarddragongammer941
@loarddragongammer941 10 ай бұрын
when heared as key i heared ass key that got me crakin' up
@bhavyanshsharma3925
@bhavyanshsharma3925 Жыл бұрын
can anyone help??? i am not able to access my video......there's just an orange screen in the frame window but not the video
@akshayshrivastava6057
@akshayshrivastava6057 2 жыл бұрын
how we can access the camera after deployment of our app please make another tutorial regarding this how to get the link we could use it in our videocapture
@sfvarandas
@sfvarandas 3 жыл бұрын
I have no image, only a black box. I don't know why. My webcam lights up but no image.
@PhoneArtistry
@PhoneArtistry 7 ай бұрын
I write the same code and trying to play a mp4 video but it will constantly giving me an error. And I can't fix that. The error is: cv.imshow("frame", frame) cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:971: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' please help me with that if anyone can
@superbrokeengineer
@superbrokeengineer 3 жыл бұрын
Could u tell me my pycharm can’t use VideoCaptue
@Pradeep_Rai_Thota
@Pradeep_Rai_Thota 3 жыл бұрын
Please let me know which the screen recorder you are using to create videos
@jaideepm572
@jaideepm572 3 жыл бұрын
OBS
@scotttresor
@scotttresor 3 жыл бұрын
i have this problem how can i resolve this
@kilovolt2494
@kilovolt2494 2 жыл бұрын
why in the world did they do it like this? What was the problem to created .get_width() method?
@vandanapal3011
@vandanapal3011 2 жыл бұрын
how to capture image and import then convert sketch in python can u send source code
@corydkiser
@corydkiser 3 жыл бұрын
object detection pls
@fareedzafar813
@fareedzafar813 Жыл бұрын
documentation link is dead....
@adityak1231
@adityak1231 3 жыл бұрын
I'm getting an error at 5:56 Abort trap: 6 It is not exactly an error. It has been handled by cv2 I think. How do I fix this? PS: I'm on MacOS 11
@mohan_hamal
@mohan_hamal 3 жыл бұрын
The problem seems to be for macOS. Check StackOverflow, there seems to be a solution there.
@adityak1231
@adityak1231 3 жыл бұрын
@@mohan_hamal Yeah it is because of the privacy settings. It runs properly when executed through the Terminal.
@magicmagus1459
@magicmagus1459 3 жыл бұрын
@@adityak1231 yes same for me. code works when running in terminal. Did u find a way for it to work when running through sublime text?
@adityak1231
@adityak1231 3 жыл бұрын
@@magicmagus1459 I haven't figured out a way to do it. I don't even think it can be done because in the privacy settings it doesn't show the option of allowing camera access to VS Code. Idk about Sublime because I don't have it. You can check in System Preferences if you want to.
@dasturlash7266
@dasturlash7266 3 жыл бұрын
Omad Okalar Omad !
@binaprajapati3593
@binaprajapati3593 3 жыл бұрын
5th I guess
@prasannan-robots
@prasannan-robots 3 жыл бұрын
Second
@kashyapsantoki4889
@kashyapsantoki4889 3 жыл бұрын
I think no one got heart from Tim. But this ❤️ is for u Tim from INDIA.
@binaprajapati3593
@binaprajapati3593 3 жыл бұрын
Not true, I had got heart from tim, and me too from india
@harish884
@harish884 3 жыл бұрын
Which ide do you use
@Wasif_Akand
@Wasif_Akand Жыл бұрын
Sublime Text
@anaymittal7720
@anaymittal7720 2 жыл бұрын
How can I take a picture instantly without the window opening?
@Life-zx5wp
@Life-zx5wp 3 жыл бұрын
AttributeError: module 'cv2.cv2' has no attribute 'videoCapture' i got this error and it's not working
@vinamis
@vinamis 3 жыл бұрын
V ideo
@howarddelosreyes463
@howarddelosreyes463 2 жыл бұрын
OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imshow' anyone else having this issue?
@oes2546
@oes2546 2 жыл бұрын
Yes
@jyothishmohan5613
@jyothishmohan5613 3 жыл бұрын
Try this for 2nd and 4th quadrant upside down.......... image[:height//2,:width//2] = smaller_frame[::-1] image[:height//2,width//2:] = smaller_frame image[height//2:,width//2:] = smaller_frame[::-1] image[height//2:,:width//2] = smaller_frame
@tanishtyagi1301
@tanishtyagi1301 3 жыл бұрын
first
@RedHeadphone
@RedHeadphone 3 жыл бұрын
What if don't cap.release()
@jonasstrabel
@jonasstrabel 3 жыл бұрын
your pc explodes
@darthkroxis
@darthkroxis 3 жыл бұрын
Tim go realize in the video the SLAM method
@feraudyh
@feraudyh 2 жыл бұрын
Would it not be better to get the width and height before the loop?
@jeferson1556
@jeferson1556 2 жыл бұрын
Which app is he using
@Wasif_Akand
@Wasif_Akand Жыл бұрын
Sublime Text
@alpanamhashilkar960
@alpanamhashilkar960 3 жыл бұрын
760th viewer
@aprameyamandal4346
@aprameyamandal4346 3 жыл бұрын
Third
@coolghoul9
@coolghoul9 Ай бұрын
you made stereograms
@kimkong1668
@kimkong1668 3 жыл бұрын
Is it just me or does Tim look like Meelo from Legend of Korra?
@naveen.m9847
@naveen.m9847 3 жыл бұрын
How to make simple app with python
@ananthramvijayaraj4554
@ananthramvijayaraj4554 3 жыл бұрын
Kivy/ Flutter i guess
@jaideepm572
@jaideepm572 3 жыл бұрын
tkinter is Easier if You are just Getting Started
@erfansadeghinezhad9780
@erfansadeghinezhad9780 3 жыл бұрын
Forth😂
@raffayirfan
@raffayirfan 3 жыл бұрын
hello
@NinjaAhmed-cp3pe
@NinjaAhmed-cp3pe 3 жыл бұрын
8th
@flextapemyass
@flextapemyass 3 жыл бұрын
Girls: Python is so booooring Guys: 16:48
@domillima
@domillima 4 ай бұрын
Sowry
OpenCV Python Tutorial #4 - Drawing (Lines, Images, Circles & Text)
13:51
Stream Live Video from Mobile Phone Camera with Python and Open CV
6:47
Python Simplified
Рет қаралды 60 М.
Make me the happiest man on earth... 🎁🥹
00:34
A4
Рет қаралды 11 МЛН
Final increíble 😱
00:39
Juan De Dios Pantoja 2
Рет қаралды 45 МЛН
Why You Should Always Help Others ❤️
00:40
Alan Chikin Chow
Рет қаралды 82 МЛН
OpenCV Python Tutorial #1 - Introduction & Images
14:52
Tech With Tim
Рет қаралды 329 М.
OpenCV Python Tutorial #2 - Image Fundamentals and Manipulation
15:43
Tech With Tim
Рет қаралды 119 М.
Image Processing with OpenCV and Python
20:38
Rob Mulla
Рет қаралды 127 М.
Rust's Alien Data Types 👽 Box, Rc, Arc
11:54
Code to the Moon
Рет қаралды 133 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,4 МЛН
IP camera stream using RTSP and openCV python
4:09
Yahiya Mulla
Рет қаралды 83 М.
Object Tracking with Opencv and Python
30:03
Pysource
Рет қаралды 592 М.
Make me the happiest man on earth... 🎁🥹
00:34
A4
Рет қаралды 11 МЛН