OpenCV Python Tutorial #3 - Cameras and VideoCapture

  Рет қаралды 165,457

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
@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!
@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.
@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
@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?
@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.
@draytonlav
@draytonlav 3 жыл бұрын
Cool project! Just finished!
@HarshanGandamalla
@HarshanGandamalla 11 ай бұрын
thank you tim..It's great learning CV
@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.
@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.
@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?
@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
@TopMusic-rw3yz
@TopMusic-rw3yz 2 жыл бұрын
Great tutorials!!!!!!!!!!
@jollokim1948
@jollokim1948 3 жыл бұрын
This is awesome
@HipHop-cz6os
@HipHop-cz6os 3 жыл бұрын
Will u upload videos on object detection using yolo?
@KSATica
@KSATica Жыл бұрын
thank you thank you your video tutorial helped....
@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
@alijebrailzade7439
@alijebrailzade7439 3 жыл бұрын
Hello Tim can you make a video "python STATIC TYPING with mypy"? It turns dynamic language to complete static language.
@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👍
@aaravgp1332
@aaravgp1332 3 жыл бұрын
how can we record the video into another video or screen share using openCV or add frames to an existing video.
@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
@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).
@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!
@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 ?
@rafiksalmi2826
@rafiksalmi2826 Ай бұрын
Thank you
@omereid7525
@omereid7525 2 жыл бұрын
THANKS VERY GOOD
@jn7071
@jn7071 2 жыл бұрын
Hi, I am now to Python, which platform you use to run the python script?
@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 ...
@CodingWorm
@CodingWorm 3 жыл бұрын
Part 4 Coming Soon, he should have said
@ico-theredstonesurgeon4380
@ico-theredstonesurgeon4380 3 жыл бұрын
how does that comma in the square brakets work?
@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
@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?
@mrtechtonics2209
@mrtechtonics2209 Жыл бұрын
Hey which IDE do you use?
@duygukocar7623
@duygukocar7623 Жыл бұрын
Can I use Ip camera port and ip address in 2:12 ? Can I record some part of Ip camera video?
@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
@viveknayar8677
@viveknayar8677 2 жыл бұрын
Hey, so why did we not create a canvas or array when displaying video capture device? ps: great video!
@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?
@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?
@py_tok5589
@py_tok5589 3 жыл бұрын
LOVELY
@itsjxelito
@itsjxelito 2 жыл бұрын
use cv2.VideoCapture(0, cv2.CAP_DSHOW) If cv2.VideoCapture(0) is taking awhile to display webcam
@giochkhaidze7234
@giochkhaidze7234 Жыл бұрын
THANKS
@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
@lessonscript
@lessonscript 3 жыл бұрын
@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.
@technohub4348
@technohub4348 2 жыл бұрын
Hey @Teach With tim please help me with this problem opencv camera frame black !!
@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.
@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 2 ай бұрын
I am mirroring android phone screen to pc. Can I use that screen for opencv ?
@tomherbert5396
@tomherbert5396 2 жыл бұрын
Is this possible thru a browser?
@justwatchv
@justwatchv 3 жыл бұрын
❤️❤️❤️
@sfvarandas
@sfvarandas 3 жыл бұрын
I have no image, only a black box. I don't know why. My webcam lights up but no image.
@superbrokeengineer
@superbrokeengineer 3 жыл бұрын
Could u tell me my pycharm can’t use VideoCaptue
@yashwanthj9305
@yashwanthj9305 Жыл бұрын
I am getting error has no attribute video capture in cv2 module how to overcome it
@scotttresor
@scotttresor 3 жыл бұрын
i have this problem how can i resolve this
@subba5735
@subba5735 2 жыл бұрын
Can you please make video about black background on image
@ahmed.m.haniya
@ahmed.m.haniya 3 жыл бұрын
👌👍
@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
@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
@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
@fareedzafar813
@fareedzafar813 Жыл бұрын
documentation link is dead....
@MK-vd4yx
@MK-vd4yx 2 жыл бұрын
Nice T-shirt buddy
@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
@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
@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.
@feraudyh
@feraudyh 2 жыл бұрын
Would it not be better to get the width and height before the loop?
@harish884
@harish884 3 жыл бұрын
Which ide do you use
@Wasif_Akand
@Wasif_Akand Жыл бұрын
Sublime Text
@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
@anaymittal7720
@anaymittal7720 2 жыл бұрын
How can I take a picture instantly without the window opening?
@loarddragongammer941
@loarddragongammer941 10 ай бұрын
when heared as key i heared ass key that got me crakin' up
@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
@corydkiser
@corydkiser 3 жыл бұрын
object detection pls
@parth2teja
@parth2teja 3 жыл бұрын
Exact 1000th viewer and 100th liker
@howarddelosreyes463
@howarddelosreyes463 2 жыл бұрын
OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imshow' anyone else having this issue?
@oes2546
@oes2546 2 жыл бұрын
Yes
@dasturlash7266
@dasturlash7266 3 жыл бұрын
Omad Okalar Omad !
@jeferson1556
@jeferson1556 2 жыл бұрын
Which app is he using
@Wasif_Akand
@Wasif_Akand Жыл бұрын
Sublime Text
@RedHeadphone
@RedHeadphone 3 жыл бұрын
What if don't cap.release()
@jonasstrabel
@jonasstrabel 3 жыл бұрын
your pc explodes
@binaprajapati3593
@binaprajapati3593 3 жыл бұрын
5th I guess
@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
@darthkroxis
@darthkroxis 3 жыл бұрын
Tim go realize in the video the SLAM method
@prasannan-robots
@prasannan-robots 3 жыл бұрын
Second
@coolghoul9
@coolghoul9 Ай бұрын
you made stereograms
@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
@gustavojuantorena
@gustavojuantorena 3 жыл бұрын
First :D
@aprameyamandal4346
@aprameyamandal4346 3 жыл бұрын
Third
@alpanamhashilkar960
@alpanamhashilkar960 3 жыл бұрын
760th viewer
@kimkong1668
@kimkong1668 3 жыл бұрын
Is it just me or does Tim look like Meelo from Legend of Korra?
@raffayirfan
@raffayirfan 3 жыл бұрын
hello
@NinjaAhmed-cp3pe
@NinjaAhmed-cp3pe 3 жыл бұрын
8th
@tanishtyagi1301
@tanishtyagi1301 3 жыл бұрын
first
@flextapemyass
@flextapemyass 3 жыл бұрын
Girls: Python is so booooring Guys: 16:48
@domillima
@domillima 4 ай бұрын
Sowry
@erfansadeghinezhad9780
@erfansadeghinezhad9780 3 жыл бұрын
Forth😂
OpenCV Python Tutorial #4 - Drawing (Lines, Images, Circles & Text)
13:51
OpenCV Python Tutorial #2 - Image Fundamentals and Manipulation
15:43
Tech With Tim
Рет қаралды 118 М.
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 11 МЛН
FastAPI, Flask or Django - Which Should You Use?
9:49
Tech With Tim
Рет қаралды 30 М.
OpenCV Python Tutorial #1 - Introduction & Images
14:52
Tech With Tim
Рет қаралды 328 М.
3 Python Projects I’d Put On MY Resume
14:49
Tech With Tim
Рет қаралды 36 М.
How To Actually Make $10k A Month Coding
14:54
Tech With Tim
Рет қаралды 75 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 105 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1 МЛН