尝试使用PIMS进行视频分析,代码可以在MacOS上运行,但不能在Windows上运行

2024-04-20 10:22:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试在我的Windows PC上运行PIMS,它会安装,但在与任何MP4视频文件一起运行时返回错误。已安装ffmpeg。总是返回相同的错误“TypeError:'float'对象不能解释为整数”。我通过命令提示符使用PIP安装模块。同样的代码在我的Mac上运行良好。我用的是Jupyter笔记本。你知道吗

我尝试过使用不同的MP4文件,我已经重新安装了很多次PIMS。你知道吗

这是我的密码:

#Modules

%matplotlib inline
import pims
import imageio
import matplotlib.pyplot as plt

#Video import
video = pims.Video("20190228_2.mp4")

#Seeing information about video
print(video)
print(len(video))

下面是错误信息:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-7a95e8e35a9c> in <module>
      1 #Seeing data about video
----> 2 print(video)
      3 print(len(video))

c:\program files\python37\lib\site-packages\pims\base_frames.py in __repr__(self)
    174 Pixel Datatype: {dtype}""".format(w=self.frame_shape[0],
    175                                   h=self.frame_shape[1],
--> 176                                   count=len(self),
    177                                   dtype=self.pixel_type)
    178 

TypeError: 'float' object cannot be interpreted as an integer

Tags: importselflenmatplotlibasvideo错误float