OpenCV Video Capturing Error : CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 30) MFVideoFormat_RGB24(unsupported media type)
import cv2
video = cv2.VideoCapture(0)
Error :
[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\videoio\src\cap_msmf.cpp
(682) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 30) MFVideoFormat_RGB24(unsupported media type)
Solution : Adding the "CAP_DSHOW " argument after 0 in the video capture
import cv2
video = cv2.VideoCapture(0, cv2.CAP_DSHOW)
HOW TO FIX - PIP IS NOT RECOGNIZED AS INTERNAL OR EXTERNAL COMMAND ERROR IN PYTHON || PIP ERROR
Download and Install pip:
pip can be downloaded and installed using command-line by going through the following steps:
Download the get-pip.py file and store it in the same directory as python is installed.
Change the current path of the directory in the command line to the path of the directory where the above file exists.
Run the command given below:
python get-pip.py
and wait through the installation process.
Voila! pip is now installed on your system.
Verification of the Installation process:
One can easily verify if the pip has been installed correctly by performing a version check on the same. Just go to the command line and execute the following command:
pip -V
To use Python-tesseract - requires python 2.5+ or python 3.x - first you have to install PIL and pytesseract packages through pip:
pip install Pillow
pip install pytesseract
Then you have to download and install the tesseract OCR:
2) If imutils is already installed, check the installation path.
Requirement already satisfied: imutils in /usr/local/lib/python3.5/dist-packages
3) When I ran python program, I ran into following error:
ImportError: No module named imutils.video
In my case, imutils was only installed under /usr/local/lib/python3.5/dist-packages path, once I copied this folder to /usr/local/lib/python2.7/dist-packages, it worked! Hope this is helpful.
Open Windows command prompt with administrator privileges (quick method: Press the Windows key. Type "cmd". Right-click on the suggested "Command Prompt" and select "Run as Administrator)
Navigate to the Python installation directory's Scripts folder using the "cd" (change directory) command. e.g. "cd C:\Program Files (x86)\PythonXX\Scripts"
This might be: C:\Users\\AppData\Local\Programs\Python\PythonXX\Scripts or C:\Program Files (x86)\PythonXX\Scripts (where XX represents the Python version number), depending on where it was installed. It may be easier to find the folder using Windows explorer, and then paste or type the address from the Explorer address bar into the command prompt.
Enter the following command: "pip install numpy".
You should see something similar to the following text appear as the package is downloaded and installed.
It should draw the following shape. The blue dots were drawn to show the starting and end points. They will be removed later.
We are going to draw the round corners with 90 degree arc of a circle in red color. The radius of the arc can be any number. Smaller radius generates smaller round corners. The following is the code snippet for drawing the round corner:
To finish the whole round rectangle, we just need to repeat the process one more time. The following is the complete code snippet with dots and colors removed:
turtle.up()
turtle.goto(-200,-150)
turtle.down()
for _ in range(2):
turtle.fd(400)
turtle.circle(100,90)
turtle.fd(200)
turtle.circle(100,90)
You may want to generalize this by creating a function that draws round rectangles with any corner size. The following is the complete code: