Python OpenCV (cv2) VideoCapture.read() Unspecified error in NumpyAllocator::allocate -


I'm new to OpenCV and I'm using a dragon version to read the frame of the video so that I do Please do some analysis about them. I am reading MP4 video file and piping to like them via frames:

  import cv2 cv2Cap = cv2.VideoCapture (filepath) Frames = [] cnt = 0 while 1: # video rate to the next frame, frame = cv2Cap.read () cnt + = 1 print 'calculation:' + str (cnt) Get Route if not Rivet: Break # means the Writ was wrong, so loop cv2.imshow ('frames', frame) # Show the frame which was read to ensure that it is normal k = cv2.waitKey (1 ) & Amp; 0xff if k == 27: brake frame.append (frame)  

This code works most of the time, however, I have seen it break on some different video like: ", line 1, & lt; Module & gt; File "vidUtils.py", line __int_self in the frame, own FPS, self NumFrames = self.getVideoInfo ("FileView") file "vidUtils.py", line 57, getVideoInfo ret, frame = cv2Cap.read () Cv2.error: D: \ Build \ OpenCV \ OpenCV-2.4.9 \ modules // Python // src2 // cv2.cpp: 201: error r: (-2) oval array of typeinum = 2, can not be made in ndims = 3 function number pyAllocator :: allocated

I am printing the frame number which fails in code and it is not always consistent, so that I think the other thing is that I'm completely missing. It's been starring recently on 1780-1820 frames. Any help or suggestions would be greatly appreciated!

Thanks in advance!

Scrolling

Are you probably running out of memory? Allocation errors mean very much "out of memory" without knowing your video resolution, your frames are usually between 1.75 MB, and then around 2000 frames you will be seeing several gigabytes.

If you are running 32-bit Python, you can easily compete with 2GB interrupt. If you make something bigger with 64-bit python, then you are more likely to suppress swapping.

I recommend that you are doing some memory profiles. The easiest way is to look at the size of one frame ( frame.nbytes ) and multiply by number of frames. Another possibility to check the total memory usage of the Python process is to use ps or equivalent utility (depending on the OS). If you want to be serious about memory usage, then heapy (see part of the package> guppy-pe ).

In a diagnostic investigation you can do the same loop without frames.append (frame) , because then the memory footprint should be very small. If he runs in a faulty manner, then your problem is most likely that you get out of memory (unfortunately, errors in simple testing do not prove that there is no memory problem, that this frame is not in the cache Other leaks can also happen.)


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -