【发布时间】:2020-05-12 00:42:17
【问题描述】:
我试图从 NumPy 数组创建视频,但我一直收到此错误:
cv2.error: OpenCV(4.2.0) c:\projects\opencv-python\opencv\modules\imgproc\src\color.simd_helpers.hpp:94: error: (-2:Unspecified error) in function '__thiscall cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Unsupported depth of input image:
> 'VDepth::contains(depth)'
> where
> 'depth' is 4 (CV_32S)
链接到完整代码 - https://drive.google.com/file/d/1qqat43eJw0Ql46TlFRiGMjqROs2QjCFj/view?usp=sharing
代码结构如下:
import cv2 , time , numpy
frame = numpy.asarray(the long list of NumPy array, if you want, it is in the link above)
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('output.mp4v' , fourcc , 20.0 , (640 , 480))
out.write(frame)
out.release()
如果我在它之前添加了一个 frame = frame.astype(numpy.uint8),则会创建一个视频,但它实际上是一个只有第一帧的一张照片的视频!!!!
请帮我解决这个问题。这真的意味着很多。
【问题讨论】: