Thanks, Sentdex, You saved my 10$ on udemy, and I need not buy any course on udemy for learning OpenCV. I also suggested this tutorial-series to my friends for their projects.
For the guys getting 0KB files... Use this: import cv2 cap = cv2.VideoCapture(0) w=int(cap.get(cv2.CAP_PROP_FRAME_WIDTH )) h=int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT )) fourcc = cv2.VideoWriter_fourcc(*'MJPG') out = cv2.VideoWriter('output.avi',fourcc, 20.0, (w,h)) while(True): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) try: out.write(frame) except: print 'ERROR - Not writting to file' cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() out.release() cv2.destroyAllWindows() It's a problem with the codec. You can also call the videoWriter as "out = cv2.VideoWriter('output.avi',-1, 20.0, (w,h))" and it will let you pic which one of the available to use.
My teacher suggested your courses and i found your videos very fluent and useful. I used a video file instead of webcam and I saved a video but new video file was just 5 kb
I came across your video while searching for a solution to my problem. I like your style of presenting, scrolling down I recognized your ava and name from Twitter. Nice. :)
Harrison. You big beautiful bastard. You are the one we deserve. We got stuck with the musk, but you are a very brighter star. I thank you sir. May your journey to the future be as valiant as your effort in the past
If you are using mac OS. You can try this: fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (1280, 720)) I got 1280 by 720 by checking cap.get(3) and cap.get(4).
Great tutorial, I will start a computer vision class this Spring for a robot project, this is going to be a really solid fundamentals for me to get ready for it. Thanks!
+Sarvesh Thakur Oh, I thought linear vision was a new thing, haha, I have learnt linear algebra before. mostly I will use matlab for computer vision (class required), but I would like to know more about python.
@@adammccartney6419 i feel bad for you, ill put spaces in the text (idk if that helps) f o u r c c = c v 2 . V i d e o W r i t e r _ f o u r c c ( * ' D I V X ' ) o u t = c v 2 . V i d e o W r i t e r ( ' o u t p u t . a v i ', f o u r c c , 2 0 . 0 , ( i n t ( c a p . g e t ( 3 ) ) , i n t ( c a p . g e t ( 4 ) ) ) )
Thanks for great videos. A quick question, I have not been able to successfully save any videos. All the output file are 0 or 6kb. I am not using a webcam. I just loaded a video, it shows the video once I run the code, and after I press "q", window closes, output file appears on my pyhon path folder, but it is 0 or 6kb. I tried different fourcc and file extensions combinations all well, but no success :(
Hi bro! your videos are awesome, i have been following all your vids, actually i decided to translate all your videos to my lenguage (Spanish) and i citing you in my description. thus, the people that are interested on this kind of things but dont know english, could learn this cool topic. (Sorry for my bad english jejej). Congrats man :)
same with me here - keep pressed - then i see the actual video maybe it is a bug in "cv2.waitKey(0)" code that waits in some "weird" cases as my and yours.
hey! i'm trying to use my bebop2 drone's camera for the video analysis. Di you know how, with opencv_brighe, i can import the video stream in opencv? thanks!
I tried this code but `ret` value is always coming false. I tried both cap = cv2.VideoCapture(0) and cap = cv2.VideoCapture(1). I am using vscode in Windows with linux terminal. Any help is deeply appreciated.
Is there any particular reason while True: if if cv2.waitKey(1) & 0xFF == ord("q"): break is used instead of while cv2.waitKey(1) & 0xFF != ord("q"): The latter seems like a much more elegant solution.
An offbeat question. Does it allow IP Webcams to stream feed into imshow()? That would help a lot in the kind of project I am doing. Can't use VideoCapture(int) in this case
Hello Harrison. Thanks for uploading these great videos. I am on to Video number 2 now of this new series. I would appreciate if you could answer a question: I am able to run a video stored in my laptop using your code for like 5 seconds then it stops. It gives this error: error: (-215) size.width>0 && size.height>0 in function cv::imshow Could you explain why? and how can I correct it?
Hi sentdex. I had a question. I was creating an application in which I would append the NumPy arrays(about thousands of those) which is the frame in a database and then I would open it on another device. NOw, so my question is HOW CAN YOU CONVERT THOSE NUMPY ARRAYS INTO A VIDEO. So this is actually a way of transferring videos from 1 device to another(audio doesn't matter for now).. PLease help me do that. I would really appreciate it.
Thank you so much ..this is the best tutorial.I was planning to make project of "face recognation using openCV and python" ....I didn't study python before but I am good at c++ language..I must work on the project by my one with my supervisor (not in groups)..and I've 5 months to present it..So do you recommend me to leave this project and choose another one?
is it possible to create hand gesture oriented website using opencv with python, that can be taken as a project, if yes wat are other things should be kept in mind while taking that.
Dear Sentdex, First of all, I would like to say thank you for such a helpful video. Please make a video or suggest commands so that we can get conversion from grayscale to color space too. I am waiting for ur response. Thanks and Best Regards Dev Kumawat
Thanks sentdex! One question, I have been having trouble turning off the webcam after finishing my script. When I release and destroy all windows, all it does is freeze the frame but the webcam light is still on. Any thoughts? I'm on tkinter and python 3.6 with cv2
My MacBook Pro is not giving me the Greyscale from color conversion. Also, it is not tracking the face and eyes with the rectangles as outlined in your other video tutorial. What is wrong with the Mac CPU. Do I need a higher resolution graphics card GPU?
After I close the video and try running the following part of the code again in the python kernel : while True: ret,frame=cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord("q"): break cap.release() cv2.destroyAllWindows() I get an error. I have to run the entire code from the beginning. Why is that?
Hey, it all works fine for me, so thank you. But I still have one question left: How can I store one single image, instead of a video? Is there a special method or do I have to store a video with one frame? Thank you a lot
The video from webcame records but no file is saved anywhere on my ubuntu computer, I get the error: "GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications."
Hello..! Great Video. I just want to ask a question, how can we skip frames from videos and save only desired frames? For example, i have a 1280*720 video file with 30fps and i want to get frames after every 15 frames. I am trying in this way: import cv2 vidcap = cv2.VideoCapture('outside.mp4') success,image = vidcap.read() count = 0 success = True while success: success,image = vidcap.read() print('Read a new frame: ', success) cv2.imwrite("frame%d.jpg" % count, image) count += 1 Can you advice ?
Hi, Good Day, I just want to ask if is it possible to use multiple webcams, I mean Im using a laptop and I connected an external webcam and when I try the cv2.VideoCapture(1) I got an error
Hey, great introduction video! However, i seem to be having issues with writing the video file. For whatever reason the output.avi file is always empty (0kb) but I'm not sure why. I have copied your code identically.
Great job. I'm learning a lot with your videos. I have a question: how can I process video streaming (VNC Viewer) to my pc in OpenCV(python), from a raspberry pi connected to the same network? Thanks a lot.
Hello Sentdex, thanks for the awesome videos. How can I preserve the audio present in the source videos file in the saved output video file. Thanks in advance.
hey so i saw most of this series, and would really like to try and do some things with it on a live webcam feed - say any of the ones mentioned here: www.earthcam.com problem now is to load images/video from the internet.. any idea as to where i can start looking?
Tons of thanks for superb tutorials..one small problem with VideoCapture.. I tried using this code, the cam starts (LED) but the video capture window does not pop-up and I can't see any video.. just to mention, I am using Python 2.7 on MacSierra platform using IPython Notebook...The error arrow -------> cv2.imshow('frame', frame). error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
For those who are not getting the output window displayed... import cv2 import numpy cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() grayScale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame', grayScale) cv2.waitKey(1) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()
Hi! Great video ,just one doubt. How do i access the BGR pixels of the frames of the WEBCAM? also how can i modify them? Please help. Thanks in advance :)
Hello sir I got "Unknown C++ exception from OpenCV code" error. Please help me to solve this. When I was trying to read video file using cv2.imshow(). I got this.
Who ever is getting a black screen on running the script, use cv2.VideoCapture(-1) instead. Note that you must have a single cam attached to make this work.
hey great tutorials ...I am having one problem. I am using macbook pro and I cant reduce the size of my video camera screen window. Is it something to do with openCV library?
need help !! as far I know, imshow() command displays the image, & should not affect the recording. In my pyqt4 program, I am using Qbuttons to start & end the recording (& displaying camera feed using pyVlc). (recording code is same as showing in video) When I remove the imshow() & start to record, the programs stops responding (thus no recording) & with imshow() it records perfectly. ( causing two windows to appear : 1 from vlc & other from imshow) please help
Hey, great videos, I'm getting this error ( I'm running on a mac) On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded. QWidget: Must construct a QApplication before a QPaintDevice Abort trap: 6 Could you help me out with this ?
How can i read from a mp4 video file already present on my pc? I am using OpenCV version 3.1.0 and python 2.7 and i have placed the respective dlls in the respective folders but still i am unable to read from mp4 files. What is the solution?
Thank you for your sharing. I have successfully installed opencv 3.4.0. However when I tried loading the video from a camera like you, it's very slow. I don't know why. Could you give me some ideas? Thanks you so much.
what is the use of cv2.VideoWriter_fourcc(*'XVID) in this , i dont get it and what does the 20 do in here out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480)) thanks for the help/......
Thanks, Sentdex, You saved my 10$ on udemy, and I need not buy any course on udemy for learning OpenCV.
I also suggested this tutorial-series to my friends for their projects.
All the udemy courses on OpenCV suck. This guy does a way better job for free. I like your account avatar btw.
One of the best teachers and one of the few people whom I want to meet in person.
For the guys getting 0KB files... Use this:
import cv2
cap = cv2.VideoCapture(0)
w=int(cap.get(cv2.CAP_PROP_FRAME_WIDTH ))
h=int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT ))
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (w,h))
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
try:
out.write(frame)
except:
print 'ERROR - Not writting to file'
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
It's a problem with the codec. You can also call the videoWriter as "out = cv2.VideoWriter('output.avi',-1, 20.0, (w,h))" and it will let you pic which one of the available to use.
Thanks a lot. This really helped me!
very nice, thanks
Thanks for help man. This removed the burden.
Thanks, very helpful.
life saver, thanks
My teacher suggested your courses and i found your videos very fluent and useful.
I used a video file instead of webcam and I saved a video but new video file was just 5 kb
wowww, pretty man!! I am a Chinese Student. your tutorials are enchanting , helping me a lot in my programming , I like them!!
Thanks
People like you saved me
I born in Iran and can't afford education
Thanks Youtub and you!
Just keep it up.
I came across your video while searching for a solution to my problem. I like your style of presenting, scrolling down I recognized your ava and name from Twitter. Nice. :)
Harrison. You big beautiful bastard. You are the one we deserve. We got stuck with the musk, but you are a very brighter star. I thank you sir. May your journey to the future be as valiant as your effort in the past
Great series to kick start on OpenCV and why is there one dislike !!!!!
i have kind of phobia about programming
but now I'm loving it...
thanks to you....
Hi man, very thanks, your videos are the best in youtube for learning Opencv with python, greeting from Colombia
If you are using mac OS. You can try this:
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (1280, 720))
I got 1280 by 720 by checking cap.get(3) and cap.get(4).
I'm getting: Python[16951:5724976] mMovieWriter.status: 3. Error: Cannot Save
I can watch my video now, but it's just a still picture.
Watch to the absolute very end to find out how to load a video file instead of webcam feed
Are you the nicest cv enthusiast or what. Love your teaching style. Thanks so much for these informative videos you put out. I'm catching up.
Man, I love these videos, I find myself learning a lot and laughing my ass off. Thanks for all the hardword sentdex.
Very useful... Thanks and cheer up, Sentdex.
Dude you're so helpful when it comes to this stuff!
Great video series! It saves me tons of time. Thanks sentdex.
he mentioned xvid
Great tutorial, I will start a computer vision class this Spring for a robot project, this is going to be a really solid fundamentals for me to get ready for it. Thanks!
+Zheng Li Same here
+Zheng Li Are you looking forward to learning linear vision too?
+Sarvesh Thakur probably, I guess I will do that after I finish computer vision class
+Zheng Li I mis spelled it. I meant linear algebra.
what language are you basing to learn computer vision? python or c?
+Sarvesh Thakur Oh, I thought linear vision was a new thing, haha, I have learnt linear algebra before. mostly I will use matlab for computer vision (class required), but I would like to know more about python.
Hey I have a question, what if I want to capture an image from webcam and then save it and ocr it to speech ???
People on mac use this
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (int(cap.get(3)), int(cap.get(4))))
Thanks, you do me a big favor!
Everybody loves to mess with dyslexic people
@@adammccartney6419 i feel bad for you, ill put spaces in the text (idk if that helps)
f o u r c c = c v 2 . V i d e o W r i t e r _ f o u r c c ( * ' D I V X ' )
o u t = c v 2 . V i d e o W r i t e r ( ' o u t p u t . a v i ', f o u r c c , 2 0 . 0 , ( i n t ( c a p . g e t ( 3 ) ) , i n t ( c a p . g e t ( 4 ) ) ) )
Thank you for that simple explanation, it works!
Thanks for great videos. A quick question, I have not been able to successfully save any videos. All the output file are 0 or 6kb. I am not using a webcam. I just loaded a video, it shows the video once I run the code, and after I press "q", window closes, output file appears on my pyhon path folder, but it is 0 or 6kb. I tried different fourcc and file extensions combinations all well, but no success :(
The same thing happens to me, did you resolve it?
Unfortunately not yet. I read here and there, and they suggest try different combinations to find one that works. But this is not reliable.
Claudio up there has a solution for that
what??
eureka!!
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
while True:
ret, frame = cap.read()
out.write(frame) # add this line your code
cv2.imshow('frame', frame)
# cv2.imshow('gray', gray)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
out.release()
cv2.destroyAllWindows()
Hi bro! your videos are awesome, i have been following all your vids, actually i decided to translate all your videos to my lenguage (Spanish) and i citing you in my description. thus, the people that are interested on this kind of things but dont know english, could learn this cool topic. (Sorry for my bad english jejej). Congrats man :)
Woah, this series is really awesome, Thank you so much
Great to hear, happy to share!
your videos are the best man ......I like them
Thanks!
if уоu rеаllу wаnt hеr bасk (аnd I knоw уоu dо) уоu nеееееdtо stор еverуthing аnd gо wаtссссh this vidеео right nоw =>>> twitter.com/495df64c291501536/status/790853501416935424 Lооооаding Vidеоооо Sоurсе ОpеnCV with Руthоn fоr Imаgее аnd Vidео Аnаlуsis 2
My program is not able to read the video in the computer.
Neither i am able to save the video.
The code is completely same.
I use python 2.7
vallaha sen adamın dibisin Allah senden razı olsun :)
Thank youuuu .
I've have to table this until I can get CV2 installed and running on my 64-bit Python 3.5 installation. Can't wait!
GOT IT! Had to install "Visual C++ Redistributable for Visual Studio 2015" and it works like a charm!
I'm getting
Attribute Error: 'module' object has no attribute 'VideoCapture'
What do I do?
can you plz tell me how to record gray frames too
if I write out.write(gray) it doesn't work ...what should i do
Save in a different name. Don’t use output.avi. You might want to add another variable like out2 = cv2.VideoWriter(‘output2.avi’...........
Thank you very much for this video! It was very helpful for beginners like me :)
woww it works the first time, thanks a lot
Hey, the code shows only pics of the webcam feed and when I cancel it using mouse next pic pops up. I am not getting any video
same with me here - keep pressed - then i see the actual video
maybe it is a bug in "cv2.waitKey(0)" code that waits in some "weird" cases as my and yours.
"I am watching" , lmao , made my day
hey! i'm trying to use my bebop2 drone's camera for the video analysis. Di you know how, with opencv_brighe, i can import the video stream in opencv?
thanks!
I tried this code but `ret` value is always coming false. I tried both
cap = cv2.VideoCapture(0)
and
cap = cv2.VideoCapture(1).
I am using vscode in Windows with linux terminal.
Any help is deeply appreciated.
Thanks
But I have a problem
Please help me understand why video recorded using Opencv is so slow. It does not reflect quick movements
Great video! still works
Is there any particular reason
while True:
if if cv2.waitKey(1) & 0xFF == ord("q"):
break
is used instead of
while cv2.waitKey(1) & 0xFF != ord("q"):
The latter seems like a much more elegant solution.
brilliant
Won't it be
while !cv2.waitKey(1) & 0xFF != ord("q"):
???
hey, i got this:
error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow
excellent as always - thank you.
An offbeat question. Does it allow IP Webcams to stream feed into imshow()?
That would help a lot in the kind of project I am doing. Can't use VideoCapture(int) in this case
Why cvtColor doesn't work with YUV file even though YUV2RGB option is available? Can you help. Thank you.
Hi Sentdex, This XVID codec is not working for my Windows 10, VLC player. Do I need to do something else?
any particular reason why you include "& 0xff"? since ord("q") & 0xff == ord("q") ... runs fine both ways, just wondering
If you are getting zero byte video output files, try:
out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
great help!!
TypeError: an integer is required :(
Thanks a lot bro
what was the reason behind it?
this line is showing syntax error
hi,
How can we show 2 different feeds from 2 different IP cameras into single window but in different frame?
Hello Harrison. Thanks for uploading these great videos. I am on to Video number 2 now of this new series. I would appreciate if you could answer a question:
I am able to run a video stored in my laptop using your code for like 5 seconds then it stops. It gives this error:
error: (-215) size.width>0 && size.height>0 in function cv::imshow
Could you explain why? and how can I correct it?
+Amit Aggarwal same error with me
+Amit Aggarwal You can used to "cap = cv2.VideoCapture(0)" :d
+Dino Mark I am using a video stored in laptop and not the webcam. Actually now i found out, it happens when the video gets over. My system hangs..
for me doesn't work with the "0" and with the "1" :(
Hi sentdex. I had a question. I was creating an application in which I would append the NumPy arrays(about thousands of those) which is the frame in a database and then I would open it on another device. NOw, so my question is HOW CAN YOU CONVERT THOSE NUMPY ARRAYS INTO A VIDEO. So this is actually a way of transferring videos from 1 device to another(audio doesn't matter for now).. PLease help me do that. I would really appreciate it.
Thank you so much ..this is the best tutorial.I was planning to make project of "face recognation using openCV and python" ....I didn't study python before but I am good at c++ language..I must work on the project by my one with my supervisor (not in groups)..and I've 5 months to present it..So do you recommend me to leave this project and choose another one?
is it possible to create hand gesture oriented website using opencv with python, that can be taken as a project, if yes wat are other things should be kept in mind while taking that.
Dear Sentdex,
First of all, I would like to say thank you for such a helpful video. Please make a video or suggest commands so that we can get conversion from grayscale to color space too.
I am waiting for ur response.
Thanks and Best Regards
Dev Kumawat
I love you man. You're the best.
+Tejas Arlimatti thankyou for the kind words!
Thanks sentdex! One question, I have been having trouble turning off the webcam after finishing my script. When I release and destroy all windows, all it does is freeze the frame but the webcam light is still on. Any thoughts? I'm on tkinter and python 3.6 with cv2
Excellent Tutorial.
My MacBook Pro is not giving me the Greyscale from color conversion. Also, it is not tracking the face and eyes with the rectangles as outlined in your other video tutorial. What is wrong with the Mac CPU. Do I need a higher resolution graphics card GPU?
Hi I've problem with a 110 degree web cam. I cannot show complete field of view. Why this?
Hey Sentdex! I have a little question.....Does it's possible to use different cameras at the same time?
After I close the video and try running the following part of the code again in the python kernel :
while True:
ret,frame=cap.read()
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
I get an error. I have to run the entire code from the beginning. Why is that?
Well explained!
If i want to use gopro 5 instead of the pc camera, what should i write for the cap = cv2.VideoCapture(1) ?
Thank you...
Thank you dude, You've Helped me.
Hey, it all works fine for me, so thank you.
But I still have one question left:
How can I store one single image, instead of a video?
Is there a special method or do I have to store a video with one frame?
Thank you a lot
The video from webcame records but no file is saved anywhere on my ubuntu computer, I get the error:
"GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications."
Thank you :D your lessons is funny and good
If you want to separate the colors. I mean visualize the R B G. How can do that?
I want to track object in an already recorded video file. I followed the instructions on the OpenCV website but it didn't work. Any suggestions?
Hello..! Great Video. I just want to ask a question, how can we skip frames from videos and save only desired frames? For example, i have a 1280*720 video file with 30fps and i want to get frames after every 15 frames. I am trying in this way:
import cv2
vidcap = cv2.VideoCapture('outside.mp4')
success,image = vidcap.read()
count = 0
success = True
while success:
success,image = vidcap.read()
print('Read a new frame: ', success)
cv2.imwrite("frame%d.jpg" % count, image)
count += 1
Can you advice ?
Is it possible to save/create grayscale video with VideoWriter() and write() functions? It didn't work for me. Appreciate your help!
Hi, Good Day, I just want to ask if is it possible to use multiple webcams, I mean Im using a laptop and I connected an external webcam and when I try the cv2.VideoCapture(1) I got an error
Hey, great introduction video! However, i seem to be having issues with writing the video file. For whatever reason the output.avi file is always empty (0kb) but I'm not sure why. I have copied your code identically.
Great job. I'm learning a lot with your videos. I have a question: how can I process video streaming (VNC Viewer) to my pc in OpenCV(python), from a raspberry pi connected to the same network? Thanks a lot.
Can we connect multiple wireless webcams over wifi and use them in open cv simultaneously?
Hello! is there any way to detect whether the camera is moving and to which direction it is moving?.
i get error
the size of video is 0KB
how i can fix it ?
and thk u for helping
Hello Sentdex, thanks for the awesome videos. How can I preserve the audio present in the source videos file in the saved output video file. Thanks in advance.
hey so i saw most of this series, and would really like to try and do some things with it on a live webcam feed - say any of the ones mentioned here: www.earthcam.com
problem now is to load images/video from the internet..
any idea as to where i can start looking?
When you say "webcam" are you talking on a PC, Mac or either? Does the built in camera on a Mac count as a webcam for this purpose?
+justgivemethetruth webcam - built in or usb video recording device.
thanks for your informative video
Tons of thanks for superb tutorials..one small problem with VideoCapture.. I tried using this code, the cam starts (LED) but the video capture window does not pop-up and I can't see any video.. just to mention, I am using Python 2.7 on MacSierra platform using IPython Notebook...The error arrow -------> cv2.imshow('frame', frame).
error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
For those who are not getting the output window displayed...
import cv2
import numpy
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
grayScale = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', grayScale)
cv2.waitKey(1)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Can we use IMREAD_GRAYSCALE to convert to grayscale frame-by-frame, instead of COLOR_BGR2GRAY? What's the difference between the two?
Hi! Great video ,just one doubt. How do i access the BGR pixels of the frames of the WEBCAM? also how can i modify them? Please help. Thanks in advance :)
From video input, how to generate images from that and then images processing for particle size distribution from the video? Thank you in advance..
Hello sir I got
"Unknown C++ exception from OpenCV code" error. Please help me to solve this. When I was trying to read video file using cv2.imshow(). I got this.
Who ever is getting a black screen on running the script, use cv2.VideoCapture(-1) instead.
Note that you must have a single cam attached to make this work.
Great Video. I tried to save the gray instead of the frame but it failed. Is it possible to save the gray scale video?
hey great tutorials ...I am having one problem. I am using macbook pro and I cant reduce the size of my video camera screen window. Is it something to do with openCV library?
hii,I am not able to see my live video while recording ,even though my webcam is working fine.Please can you help?Thanks.
Thanks for the awesome tutorial! How would you capture a single window on the desktop?
need help !!
as far I know, imshow() command displays the image, & should not affect the recording.
In my pyqt4 program, I am using Qbuttons to start & end the recording (& displaying camera feed using pyVlc).
(recording code is same as showing in video)
When I remove the imshow() & start to record, the programs stops responding (thus no recording) & with imshow() it records perfectly. ( causing two windows to appear : 1 from vlc & other from imshow)
please help
Hey, great videos, I'm getting this error ( I'm running on a mac)
On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
QWidget: Must construct a QApplication before a QPaintDevice
Abort trap: 6
Could you help me out with this ?
How can i read from a mp4 video file already present on my pc?
I am using OpenCV version 3.1.0 and python 2.7 and i have placed the respective dlls in the respective folders but still i am unable to read from mp4 files. What is the solution?
Thank you for your sharing. I have successfully installed opencv 3.4.0. However when I tried loading the video from a camera like you, it's very slow. I don't know why. Could you give me some ideas? Thanks you so much.
what is the use of cv2.VideoWriter_fourcc(*'XVID) in this , i dont get it and what does the 20 do in here out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
thanks for the help/......
what determines which cam is "first" or "second" if you have a bunch of usb webcams?
what is 20.0 in out = cv2.VideoWriter('output.avi'.fourcc,20.0,(640,480))
this is awesome!thank you!
im not THAT familiar with pythonprogramming
what does the & 0xFF == mean? (I guess that 0x is needed to type the hex number FF)