OpenCV Python Tutorial #3 - Cameras and VideoCapture
HTML-код
- Опубликовано: 10 май 2024
- 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 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 ⭐️
- Images within OpenCV
- Image Manipulation OpenCV
- Image Fundamentals OpenCV
- Python
- Computer vision
- Cameras and video capture
⭐️ Hashtags ⭐️
#OpenCV #Python #CameraCapture
What the heck i just started learning opencv and i found you channel and you just started uploading tutorials. Perfect lol
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 😎
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.
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!
You are great in the way you explain things ! That shows a lot of control to what you do ! Thanks a lot
I like this series, very easy to follow as always, looking forward to the next one.. Thank You.
Looking forward for part #4... Thank you for the awesome tutorials.
Hi.
great stuff for opencv beginners. thanks for the goodwill and the work done to make these videos available
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)
IT DOESNT WORK
works on my end 👍
@@twentylush it doesnt
your wrong, im right
Great tutorials Tim. Keep making them.
You explained everything so simply and details
Cool project! Just finished!
thank you tim..It's great learning CV
Love your vids tim!! Excited for the codejam 3 results
Same here
What was your teams name?
@@ananthramvijayaraj4554 didn't participate, but nice to see the video to get project ideas
@@binaprajapati3593 ahhh even that’s pretty fun, you should participate next time
I had to make some changes to make the code work for me but at the end it did so thanks! I love it
Please share the changes you made.
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()
yooo dude thanks , im learning facial recognition and rotating 90 deg angles is needed for that , thank you for your addition.
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.
thank you thank you your video tutorial helped....
Great tutorials!!!!!!!!!!
This is awesome
15:30 Tim, Can we somehow make use of the .T Attribute of numpy ndarray so as to swap the the height and width?
amazing tutorial tim, im not getting the auto predict/ complete thingy in my sublime text like you, how do i enable/fix this?
Hello Tim can you make a video "python STATIC TYPING with mypy"? It turns dynamic language to complete static language.
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
THANKS VERY GOOD
Will u upload videos on object detection using yolo?
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 ...
Thank you
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.
Yep!
use cv2.VideoCapture(0, cv2.CAP_DSHOW)
If cv2.VideoCapture(0) is taking awhile to display webcam
THANKS
Hey, so why did we not create a canvas or array when displaying video capture device?
ps: great video!
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
Part 4 Coming Soon, he should have said
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 :) ...........
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).
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.
how can we record the video into another video or screen share using openCV or add frames to an existing video.
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)?
the first if it doesnt connect via usb👍
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 ?
Nice T-shirt buddy
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
Hi, did you find one ? I can't figure which number is my plugged-in webcam...
@@Aminoquiz me too, now you know?
LOVELY
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.
I couldn't send the capture
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
Hi, I am now to Python, which platform you use to run the python script?
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
Is it possible to access another e.g. camera of another pc, like you are the admin and accessible only to you?
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
Can you please make video about black background on image
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
I am mirroring android phone screen to pc. Can I use that screen for opencv ?
how does that comma in the square brakets work?
❤️❤️❤️
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?
Hey which IDE do you use?
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?
Can I use Ip camera port and ip address in 2:12 ? Can I record some part of Ip camera video?
I am getting error has no attribute video capture in cv2 module how to overcome it
when heared as key i heared ass key that got me crakin' up
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?
Why would you use cv2 if you just want to display text with black background?
@@jonasstrabel to have a display for a webpage that is dynamic, like temperature.
@@klintkrossa6885 I don't thing open cv2 is the way to go for that matter.
Hey @Teach With tim please help me with this problem
opencv camera frame black !!
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
👌👍
how to capture image and import then convert sketch in python can u send source code
I have no image, only a black box. I don't know why. My webcam lights up but no image.
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
The problem seems to be for macOS. Check StackOverflow, there seems to be a solution there.
@@mohan_hamal Yeah it is because of the privacy settings. It runs properly when executed through the Terminal.
@@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?
@@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.
why in the world did they do it like this? What was the problem to created .get_width() method?
I think no one got heart from Tim. But this ❤️ is for u Tim from INDIA.
Not true, I had got heart from tim, and me too from india
Please let me know which the screen recorder you are using to create videos
OBS
Is this possible thru a browser?
object detection pls
OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imshow'
anyone else having this issue?
Yes
Omad Okalar Omad !
i have this problem how can i resolve this
Could u tell me my pycharm can’t use VideoCaptue
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
Exact 1000th viewer and 100th liker
How can I take a picture instantly without the window opening?
AttributeError: module 'cv2.cv2' has no attribute 'videoCapture'
i got this error and it's not working
V ideo
5th I guess
documentation link is dead....
First :D
Second
Which ide do you use
Sublime Text
you made stereograms
Tim go realize in the video the SLAM method
Would it not be better to get the width and height before the loop?
What if don't cap.release()
your pc explodes
Is it just me or does Tim look like Meelo from Legend of Korra?
Which app is he using
Sublime Text
How to make simple app with python
Kivy/ Flutter i guess
tkinter is Easier if You are just Getting Started
first
Third
760th viewer
hello
Girls: Python is so booooring
Guys: 16:48
8th
Forth😂
this is kinda complicated actually