MouseLand / facemap

Framework for predicting neural activity from mouse orofacial movements tracked using a pose estimation model. Package also includes singular value decomposition (SVD) of behavioral videos.
https://facemap.readthedocs.io
GNU General Public License v3.0
154 stars 60 forks source link

trying to write a python code to use the facemap API, but openCV keeps returning 'Couldn't read video stream from file '...'. #149

Closed greg11111111 closed 2 months ago

greg11111111 commented 3 months ago

Version information:

facemap version: 1.0.6 platform: darwin python version: 3.12.4 torch version: 2.3.1 numpy version: 2.0.0

Describe the issue:

I'm trying to make a python code that can set and process the pupil ROI of every mp4 file in a directory (I'm essentially trying to make the processing stage as automatic as possible), but right now openCV is giving me the error I added in the Error message box. The version of opencv-python im using is 4.10.0.84. Any help would be appreciated!

Error message:

Processing video: /Users/phil_1/Desktop/test20/GRAB5HT_83_JL_18823_2024Apr01_165530_Blk4_Trial189_R.mp4
Video properties - Frame count: 690, FPS: 25.0, Width: 1640, Height: 1232
Read frame from video: GRAB5HT_83_JL_18823_2024Apr01_165530_Blk4_Trial189_R.mp4 with shape (1232, 1640, 3)
Saved pupil ROI to: /Users/phil_1/Desktop/test20/GRAB5HT_83_JL_18823_2024Apr01_165530_Blk4_Trial189_R_pupil_roi.png
Running FaceMap on: /Users/phil_1/Desktop/test20/GRAB5HT_83_JL_18823_2024Apr01_165530_Blk4_Trial189_R.mp4
OpenCV: Couldn't read video stream from file "/"
OpenCV: Couldn't read video stream from file "U"
OpenCV: Couldn't read video stream from file "s"
OpenCV: Couldn't read video stream from file "e"
OpenCV: Couldn't read video stream from file "r"
OpenCV: Couldn't read video stream from file "s"
OpenCV: Couldn't read video stream from file "/"
OpenCV: Couldn't read video stream from file "p"
OpenCV: Couldn't read video stream from file "h"
OpenCV: Couldn't read video stream from file "i"
OpenCV: Couldn't read video stream from file "l"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "1"
OpenCV: Couldn't read video stream from file "/"
OpenCV: Couldn't read video stream from file "D"
OpenCV: Couldn't read video stream from file "e"
OpenCV: Couldn't read video stream from file "s"
OpenCV: Couldn't read video stream from file "k"
OpenCV: Couldn't read video stream from file "t"
OpenCV: Couldn't read video stream from file "o"
OpenCV: Couldn't read video stream from file "p"
OpenCV: Couldn't read video stream from file "/"
OpenCV: Couldn't read video stream from file "t"
OpenCV: Couldn't read video stream from file "e"
OpenCV: Couldn't read video stream from file "s"
OpenCV: Couldn't read video stream from file "t"
OpenCV: Couldn't read video stream from file "2"
OpenCV: Couldn't read video stream from file "0"
OpenCV: Couldn't read video stream from file "/"
OpenCV: Couldn't read video stream from file "G"
OpenCV: Couldn't read video stream from file "R"
OpenCV: Couldn't read video stream from file "A"
OpenCV: Couldn't read video stream from file "B"
OpenCV: Couldn't read video stream from file "5"
OpenCV: Couldn't read video stream from file "H"
OpenCV: Couldn't read video stream from file "T"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "8"
OpenCV: Couldn't read video stream from file "3"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "J"
OpenCV: Couldn't read video stream from file "L"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "1"
OpenCV: Couldn't read video stream from file "8"
OpenCV: Couldn't read video stream from file "8"
OpenCV: Couldn't read video stream from file "2"
OpenCV: Couldn't read video stream from file "3"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "2"
OpenCV: Couldn't read video stream from file "0"
OpenCV: Couldn't read video stream from file "2"
OpenCV: Couldn't read video stream from file "4"
OpenCV: Couldn't read video stream from file "A"
OpenCV: Couldn't read video stream from file "p"
OpenCV: Couldn't read video stream from file "r"
OpenCV: Couldn't read video stream from file "0"
OpenCV: Couldn't read video stream from file "1"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "1"
OpenCV: Couldn't read video stream from file "6"
OpenCV: Couldn't read video stream from file "5"
OpenCV: Couldn't read video stream from file "5"
OpenCV: Couldn't read video stream from file "3"
OpenCV: Couldn't read video stream from file "0"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "B"
OpenCV: Couldn't read video stream from file "l"
OpenCV: Couldn't read video stream from file "k"
OpenCV: Couldn't read video stream from file "4"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "T"
OpenCV: Couldn't read video stream from file "r"
OpenCV: Couldn't read video stream from file "i"
OpenCV: Couldn't read video stream from file "a"
OpenCV: Couldn't read video stream from file "l"
OpenCV: Couldn't read video stream from file "1"
OpenCV: Couldn't read video stream from file "8"
OpenCV: Couldn't read video stream from file "9"
OpenCV: Couldn't read video stream from file "_"
OpenCV: Couldn't read video stream from file "R"
OpenCV: Couldn't read video stream from file "."
OpenCV: Couldn't read video stream from file "m"
OpenCV: Couldn't read video stream from file "p"
OpenCV: Couldn't read video stream from file "4"
Computing subsampled mean...
Error processing video with FaceMap: /Users/phil_1/Desktop/test20/GRAB5HT_83_JL_18823_2024Apr01_165530_Blk4_Trial189_R.mp4
cannot convert float NaN to integer
greg11111111 commented 3 months ago

As a quick update, the issue seems to be the interaction between FaceMap and openCV.

Atika-Syeda commented 2 months ago

Hi @greg11111111 can you please share the code you're running that produces the error? It looks like the video filepath input isn't right so you might not be using the filepath name in a list as required by facemap's code. You can find instructions for running facemap in a script here: https://github.com/MouseLand/facemap/blob/main/docs/notebooks/process_svd.ipynb