OpenCV: cv2.videoCapture successful, but isOpen fails right after - python

I have found some other threads but they didn't help my problem.
The lines that I'm confused about are:
print("videopath",os.path.isfile(video_path),video_path)
self.cap = cv2.VideoCapture(video_path)
print("is open?",self.cap.isOpened())
It says my file exists (the first line returns true, and prints the direct path to my .mp4), and when I put cv2.VideoCapture in a try/catch, it succeeded without an issue. However it says the video is not open and I can't pull any frames from it. I'm on Ubuntu 16.04, using OpenCV 3.3 and Python 3.5.
Any suggestions would be much appreciated, thank you.

In the end it was because I had the wheel version of OpenCV installed on top of my manual installation. DON'T use pip install opencv-python as it is not official and errors like this will occur. This was an incredible guide that made it very easy: https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
To be clear though, I had gone through this whole process once, and then tried pip just because, and it broke it, so once you install it manually, don't touch the wheel packages!

Related

Pip Fatal Error in launcher: Unable to create process when using ""

I already fixed this, but I will post the question anyways and answer it so if there are other people having this issue they may find this.
I installed blender a while ago and did some stuff using python. I can't recall what exactly I did, it was for a school project. However, when I recently tried to use pip to install something I got the following message:
Error in launcher: Unable to create process when using "path to python my blender folder"
Even if you get this answer due to another situation my solution might still help you.
This worked for me:
First I uninstalled Blender.
Then I uninstalled python and reinstalled the newest version.
I deleted every environment variable path I could find leading to an old python version.
In the Terminal I entered where pip and still got some paths leading to old python versions, I went to these locations and deleted every folder labeled with an old python version, in my case these locations were C:\Python37and C:\Users\myusername\Appdata\Roaming\Python
And that's it. After that pip worked as it should.

Setup installation Failed

I'm facing a problem during the uninstallation of Python 3.9 as you can see in the Picture that I Attached with it kidly tell me what is solution of this problem
you can easily uninstall it from programs and features that exist in control panel
Maybe your computer does not match with this version python 3.9. Try to download another version of python and set it up again.

install opencv from source windows

I am trying to install OpenCV following this link https://docs.opencv.org/master/d5/de5/tutorial_py_setup_in_windows.html
opencv-4.5.1 is the version I am building from source. I have no errors in my entire process( up to Step 16)
Step 17 which INSTALL also has no errors, but Step 18 'import cv2 as cv' will not import this module.
I have python 3.9.1. I followed all the steps with CMAKE and was able to generate with no errors.
Is there something that I am missing here?
I would recommend to use another IDE like Pycharm to create your projects. It is extremely easy to setup an OpenCV work environment :).
IDLE is great for smaller projects but I`ve seen a lot of people having issues with it.

PyCharm: Can't install opencv-contrib-python

I can't install opencv-contrib-python on PyCharm using the Setting options provided by PyCharm. I get these error everytime I tried first not using the --user option, such as in image 1:
Then I tried using the --user option, and I got what is showed in image 2
My knowledge of Python is very weak and I don't need to get it better right now. I have a script I need to run for a very close presentation (in the script there are many section with many examples of how to use SIFT, image homography, and other stuff used in image processing and artificial vision. I can't run the SIFT part, this is why I need opencv-contrib-python). I'm using opencv 3.4.3.18 and I need to make the script working for that distribution!
I haven't found anything of useful since now and I'm in quite a hurry and still without a solution.
Thank you for the help!

extract single frame from video

I am trying to write a script that will extract a single frame from a user uploaded video clip in order to create a thumbnail. It sounds like either OpenCV or ffmpeg will do what I need, but I am having trouble installing them.
I tried installing OpenCV using apt-get install libopencv-dev, and it looks like everything worked, but when running import cv2 in Python, it says there is no such module. Also tried installing using these instructions, but when I run the import, it hangs for a second or two and then says Failed to initialize libdc1394.
I then tried to install ffmpeg with pyffmpeg, but the most recent version of pyffmpeg I could find was released 3 years ago and built for Python2.6 on Ubuntu 10.10, while I am using 2.7 on Ubuntu 12.04.
Does anyone have experience installing either of these, or would recommend something else for this purpose?
If you are trying to install ffmpeg, you can do this more easily if you have homebrew and then use brew to install it. It's a lot more complicated otherwise.
If you just want to be able to complete this task, and it doesn't have to be the tool you're listing, you could try ffmpeg-python. After you have it installed, you can use the get_video_thumbnail example to get a single image. You could also probably tweak the read_frame_as_jpeg example to get a single image from a frame if you want.

Categories

Resources