sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
279 stars 138 forks source link

OpenCV can't read video stream from file error when trying to get pixels/mm in video parameters #200

Open raewanyk opened 2 years ago

raewanyk commented 2 years ago

Hello! I've been trying to teach myself deeplabcut and SimBA, and would just like to start by saying I think SimBA is a great idea and really well executed! The GUI and documentation are easy to follow. I've successfully created and loaded a new project, but when I try to edit the video parameters to calculate the pixels/mm, I get an error. I know a screen with the video playing is suppose to pop up, but instead, my terminal says: OpenCV: Couldn't read video stream from file "/Users/lsbmorrisonlab/Documents/Simba/test/test4/project_folder/videos/0" as soon as I click the 'set video parameters' button. (I'm using Mac OS v 12.2.1). Then, when I try to change click the Video1 button under Getcoord, it says this:

Screen Shot 2022-07-15 at 2 57 50 PM

I think it can't change directories for some reason, but I double-checked all of my files, video paths, directories, etc and it all seems to be working. One thing I did notice was that the OpenCV error appended an extra '0' at the end of the path, which leads to nothing. Any help would be great!

Thanks!!!

sronilsson commented 2 years ago

Hello @raewanyk! Thanks for trying out SimBA. This error could happen, if the video file that SimBA is trying to open, is corrupted/not an actual video file. The '0' refers to frame number 0, the first frame, which SimBA is trying to open through the OpenCV package.

If you navigate to the project_folder/videos directory, do you see a video file in there in avi or mp4 format that is of expected size? E.g., if it is 1kb large, thats usually a good sign that something odd is going on with that video.

raewanyk commented 2 years ago

Hi! Thanks for the quick response. There are mp4 videos in the project/video folder:

Screen Shot 2022-07-15 at 3 38 32 PM

Does it have something to do with the MPEG-4 file??

sronilsson commented 2 years ago

Got it, no it should't be any issues with your videos what I can see, do you have a screengrab of your files inside the project_folder/csv/input_csv as well?

raewanyk commented 2 years ago
Screen Shot 2022-07-15 at 4 02 30 PM
sronilsson commented 2 years ago

Got it. So, for whatever reason. Your video data files are named slightly differently than your video files, SimBA should have corrected this at import. Your video, for example, is called 1014DLC.mp4, while the imported file is called 1014.csv. When you click on 1014DLC, there is a mismatch, and SimBA is most likely searching for 1014.mp4 and it breaks, because it doesn't exist.

That said, I would also avoid pure integer filenames if you can, as there may be some bugs loitering around from early days and I'm trying to find time and fix. E.g., Importing a video called Video_1014 is much better than imprting a video called 1014.

raewanyk commented 2 years ago
Screen Shot 2022-07-15 at 4 23 18 PM

So then I should just rename the csv files to match the mp4? Noted on the renaming files--thank you.

sronilsson commented 2 years ago

Yeah that should work - check if that fixes it.

raewanyk commented 2 years ago

Sadly, it did not. I still get the same opencv error and filenotfound

sronilsson commented 2 years ago

Ah, thanks for letting me know. Can you try if it is an integer error, nd rename your videos e.g., "Video_1014" and the csv files the same way "Video_1014"

raewanyk commented 2 years ago
Screen Shot 2022-07-15 at 4 57 25 PM

No, didn't work :/

sronilsson commented 2 years ago

Hmm, thanks let me see if I can replicate

sronilsson commented 2 years ago

One more question, which version of simba are you running?

raewanyk commented 2 years ago

I'm not sure, but I downloaded it maybe a week ago on my Mac. This text runs when simba is opening:

Screen Shot 2022-07-15 at 5 06 24 PM
sronilsson commented 2 years ago

you can find out by typing pip show simba-uw-tf-dev in your july-12 environment

raewanyk commented 2 years ago
Screen Shot 2022-07-15 at 5 18 14 PM

Uhhh??? It says Package not found

sronilsson commented 2 years ago

that makes more sense now, you might be running an older version that has not been maintained for some years and thats why you are seeing the errors youre seeing.

try pip unininstall simba-uw-tf and pip uninstall simba-uw-no-tf, followed by pip install simba-uw-tf-dev, then simba and see if everything looks ok with the pixels per millimeter calculations.

raewanyk commented 2 years ago

Hello! Sorry for such a late response--I didn't have access to this computer over the weekend. I tried those commands in the environment I was working in, and just to be safe, I tried them again in a new environment. Both times, I get this error:

Screen Shot 2022-07-18 at 10 00 52 AM

However, since I'm using a mac, I followed the extra instructions to download on a mac, but with pip install simba-uw-tf-dev. If I simply install the dev version by itself and then try to run it, I get the Mac OS X backend error, even though I'm using the correct tkinter and python version as mentioned on the FAQ.

Sorry for so many questions--I really appreciate your help.

sronilsson commented 2 years ago

No worries about questions :) This error has been coming up a fair bit lately for mac users, and I have not been able to replicate it myself (I'm on a Mac too). There was someone who solved it here last week: https://github.com/sgoldenlab/simba/issues/196 - would you mind trying their solution at the end of that thread?

raewanyk commented 2 years ago

Yes-- thank you so much for all of your help!