Can't read .avi files using Python OpenCV 4.1.2-dev - python-3.x

I wanna run my opencv3.1 programs, but when i try to read a file using cv2.VideoCapture shows me the error:
error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): ./../images/walking.avi in function 'icvExtractPattern'
But, when i using the camera with cv2.VideoCapture(0) it works perfectly. I verify the file path and using the relative and the absolute path, but still not working.
I gonna wait for your answers.
Thanks a lot

Originally I used cv2.VideoWriter_fourcc(*'XVID') getting the same error
switch the (*'XVID') to (*'MJPG')
I am using a raspberry pi Gen. 4 (4GB) with image: Raspbian Buster Lite

Related

Why does my .exe file stop responding after installing using pyinstaller -w filename.py but works fine if I just use pyinstaller filename.py?

I currently have a program that takes the user's microphone input and does something with it. I use tkinter and have all aspects of my program presented on the gui so that it doesn't run in the python shell upon execution.
When I install the program using pyinstaller, the executable file opens with the command prompt and works completely fine. When I install the program using pyinstaller -w, the executable opens and then fails to respond after calling for the user's input. I'm not sure if the user input is a factor but it is around that point in which the program stops responding.
I've tried including used packages in the hidden imports section of the .spec file but this didn't work.
I ultimately want to create an executable file that opens without the command prompt and runs normally, regardless of how I build it. (i.e. doesn't matter if it uses pyinstaller or not)
I'm sorry if this is a duplicate somewhere, I've searched for hours and haven't found a solution.
Note: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) comes up each time I run the file but it doesn't seem to impact my program's execution.

opencv Code keep crashing and didn't execute afterward

I was working on a project that was running fine but now when I try to setup the whole code again for the client. my opencv code execute and crashes the first time I try to run it.afterwards the code doesn't even execute until I restart my system again.then code execute and crash again then it doesn't even execute. the terminal shows the msg(attached image) and nothing happen afterwards
os: ubuntu 18.04
python version: python3
opencv version 4
The problem seems to come from pytroch library as te error comes from torch.nn.modules.
I recommend you to check if you have the last version of Pytorch or if there are some issue within the test_2.py code in line 139 when calling:
utils.predict(model_ft, labels, transforms, test_dir, imgFile)

pydub no ffprobe found

I have an app for MacOS that is compiled with py2app. The app uses the pydub module and the latter uses ffmpeg family package.
The problem is that once I compile the app and move it to a different OS, the subprocess call from pydub fails to find any of the ffmpeg packages even though they are installed in /usr/local/bin.
If I launch the app from terminal ./Nameapp.app/Contents/MacOs/Nameapp then it runs no problem, but if I launch it with double click then pydub complains not finding the packages and the app hangs where ffmpeg/ffprobe should do the work.
I can see that pydub searches in the /usr/local/bin only if launched from terminal, otherwise no. If I add /usr/local/bin to PATH, pydub doesnt complain anymore that it doesnt find ffmpeg/ffprobe, but it still gives me an error for both ffmpeg and ffprobe: [Errno 2] No such file or directory:.
If I hardcode the path pydub.AudioSegment.converter = "/usr/local/bin/ffmpeg", the app gives me only ffprobe error [Errno 2] No such file or directory:'ffprobe': 'ffprobe'.
On some other posts i've seen pydub.AudioSegment.ffprobe = "/path/to/ffprobe" but it doesnt seem to work in my case?
So my two questions are:
How to hardcode the ffprobe path in pydub?
How to solve this without hardcoding path?
for some reason it works when changing the shell to zsh... switching back to bash no. not really happy with this solution but it's something

How to load the Sound module?

Please would you know how to sucessfully load the sound module with Julia ? At the prompt I type the following and I immediately obtain the following error :
julia> require("Sound")
ERROR: Sound not found
in require at loading.jl:39
I am using linux Mint.
First, which version of Julia are you using? Use the versioninfo() command at the REPL.
Second, have you installed the Sound.jl package using Pkg.add("Sound")?
Finally, to use the sound package, use using Sound, or import Sound - see manual for the difference.

OpenCV error: Image step is wrong

I'm going through this tutorial: http://docs.opencv.org/trunk/modules/contrib/doc/facerec/tutorial/facerec_video_recognition.html#creating-the-csv-file
Everything goes well, but running the face recognition script gives this error:
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed)
I'm using Ubuntu so I'm not exactly sure how to implement the solution found here: Getting OpenCV Error "Image step is wrong" in Fisherfaces.train() method
I rebuilt in debug mode but that had no effect.
Recently I faced the same error with this face recognition example. I got rid of the error by giving same ratio(1:1) images.
Crop the images using this script (see this as well Command line batch image cropping tool)
#!/bin/bash
width=92;
height=92;
x_offset=0;
y_offset=10;
filelist=`ls | grep '.pgm'`
for image_file in $filelist
do
convert -crop ${width}x${height}+${x_offset}+${y_offset} \
$image_file $image_file
done
this will crop the images in a folder, so u need to put this script in the same directory where your images are.
Also you should give absolute path inside the csv file.

Resources