Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Out of memory error

I working on a video composition project using multiple user generated videos . Below is my code

df=pd.concat(user,axis=1)

print df

dfs= df.loc[:, (slice(None), ['Panning','sec'])]

video_index=0 cap=cv2.VideoCapture(videoList[0]) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps = cap.get(cv2.CAP_PROP_FPS) fra=[] fourcc = cv2.VideoWriter_fourcc(*'DIVX') out = cv2.VideoWriter("Output.avi", fourcc, fps, (width, height), True) while(cap.isOpened()): ret,frame=cap.read() fra.append(frame)

for index,row in dfs.iterrows():
     if (row[:, 'Panning'] == 'Panning').any():
         idx = row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist()
         sec = int(row.loc[(idx, 'sec')].values.tolist()[0])
         if cap.get(0)==1000*sec:
             cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
             cap.set(0, sec * 1000)
             ret, frame = cap.read()
             fra.append(frame)
     else:
        #cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
        ret,frame=cap.read()
        fra.append(frame)
        if frame is None:
            video_index += 1
            if video_index == len(videoList):
                break
            cap = cv2.VideoCapture(videoList[indices.index(long_dur())])

            cap.set(0,1000*sec)
            ret, frame = cap.read()
            fra.append(frame)

When I am trying to run I am get the following error

  OpenCV Error: Unspecified error (The numpy array of typenum=2, ndims=3 can not be created) in NumpyAllocator::allocate, file ..\..\..\modules\python\src2\cv2.cpp, line 184
OpenCV Error: Insufficient memory (Failed to allocate 6220800 bytes) in cv::OutOfMemoryError, file ..\..\..\modules\core\src\alloc.cpp, line 52
Traceback (most recent call last):
  File "C:/Users/chaitanya/PycharmProjects/Thesis/ROI.py", line 86, in <module>
    ret,frame=cap.read()
cv2.error: ..\..\..\modules\core\src\alloc.cpp:52: error: (-4) Failed to allocate 6220800 bytes in function cv::OutOfMemoryError

I am not able to solve it.need help on this error

OpenCV Out of memory error

I working on a video composition project using multiple user generated videos . Below is my code

 df=pd.concat(user,axis=1)

print df

 dfs= df.loc[:, (slice(None), ['Panning','sec'])]

['Panning','sec'])] video_index=0 cap=cv2.VideoCapture(videoList[0]) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps = cap.get(cv2.CAP_PROP_FPS) fra=[] fourcc = cv2.VideoWriter_fourcc(*'DIVX') out = cv2.VideoWriter("Output.avi", fourcc, fps, (width, height), True) while(cap.isOpened()): ret,frame=cap.read() fra.append(frame)

fra.append(frame)

    for index,row in dfs.iterrows():
      if (row[:, 'Panning'] == 'Panning').any():
          idx = row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist()
          sec = int(row.loc[(idx, 'sec')].values.tolist()[0])
          if cap.get(0)==1000*sec:
              cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
              cap.set(0, sec * 1000)
              ret, frame = cap.read()
              fra.append(frame)
      else:
        #cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
         ret,frame=cap.read()
         fra.append(frame)
         if frame is None:
             video_index += 1
             if video_index == len(videoList):
                 break
             cap = cv2.VideoCapture(videoList[indices.index(long_dur())])

             cap.set(0,1000*sec)
             ret, frame = cap.read()
             fra.append(frame)

When I am trying to run I am get getting the following error

  OpenCV Error: Unspecified error (The numpy array of typenum=2, ndims=3 can not be created) in NumpyAllocator::allocate, file ..\..\..\modules\python\src2\cv2.cpp, line 184
OpenCV Error: Insufficient memory (Failed to allocate 6220800 bytes) in cv::OutOfMemoryError, file ..\..\..\modules\core\src\alloc.cpp, line 52
Traceback (most recent call last):
  File "C:/Users/chaitanya/PycharmProjects/Thesis/ROI.py", line 86, in <module>
    ret,frame=cap.read()
cv2.error: ..\..\..\modules\core\src\alloc.cpp:52: error: (-4) Failed to allocate 6220800 bytes in function cv::OutOfMemoryError

I am not able to solve it.need help on this error

click to hide/show revision 3
No.3 Revision

updated 2016-11-21 13:43:17 -0600

berak gravatar image

OpenCV Out of memory error

I working on a video composition project using multiple user generated videos . Below is my code

 df=pd.concat(user,axis=1)

print df

#print df

      dfs= df.loc[:, (slice(None), ['Panning','sec'])]


  video_index=0
 cap=cv2.VideoCapture(videoList[0])

 fra=[]
 fourcc = cv2.VideoWriter_fourcc(*'DIVX')
 out = cv2.VideoWriter("Output.avi", fourcc, fps, (width, height), True)
 while(cap.isOpened()):
     ret,frame=cap.read()
     fra.append(frame)

     for index,row in dfs.iterrows():
           if (row[:, 'Panning'] == 'Panning').any():
                idx = row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist()
                sec = int(row.loc[(idx, 'sec')].values.tolist()[0])
               if cap.get(0)==1000*sec:
                    cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
                   cap.set(0, sec * 1000)
                   ret, frame = cap.read()
                   fra.append(frame)
           else:

               ret,frame=cap.read()
               fra.append(frame)
               if frame is None:
                   video_index += 1
                   if video_index == len(videoList):
                       break
                   cap = cv2.VideoCapture(videoList[indices.index(long_dur())])

                   cap.set(0,1000*sec)
                   ret, frame = cap.read()
                   fra.append(frame)

When I am trying to run I am getting the following error

  OpenCV Error: Unspecified error (The numpy array of typenum=2, ndims=3 can not be created) in NumpyAllocator::allocate, file ..\..\..\modules\python\src2\cv2.cpp, line 184
OpenCV Error: Insufficient memory (Failed to allocate 6220800 bytes) in cv::OutOfMemoryError, file ..\..\..\modules\core\src\alloc.cpp, line 52
Traceback (most recent call last):
  File "C:/Users/chaitanya/PycharmProjects/Thesis/ROI.py", line 86, in <module>
    ret,frame=cap.read()
cv2.error: ..\..\..\modules\core\src\alloc.cpp:52: error: (-4) Failed to allocate 6220800 bytes in function cv::OutOfMemoryError

I am not able to solve it.need help on this error

click to hide/show revision 4
No.4 Revision

updated 2016-11-21 13:46:22 -0600

berak gravatar image

OpenCV Out of memory error

I working on a video composition project using multiple user generated videos . Below is my code

df=pd.concat(user,axis=1)
#print df

 dfs= df.loc[:, (slice(None), ['Panning','sec'])]


 video_index=0
 cap=cv2.VideoCapture(videoList[0])

 fra=[]
 fourcc = cv2.VideoWriter_fourcc(*'DIVX')
 out = cv2.VideoWriter("Output.avi", fourcc, fps, (width, height), True)
 while(cap.isOpened()):
     ret,frame=cap.read()
     fra.append(frame)

     for index,row in dfs.iterrows():
           if (row[:, 'Panning'] == 'Panning').any():
                idx = row[:, 'Panning'][row[:, 'Panning'] == 'Panning'].index.tolist()
                sec = int(row.loc[(idx, 'sec')].values.tolist()[0])
               if cap.get(0)==1000*sec:
                    cap = cv2.VideoCapture(videoList[indices.index(random.choice(idx))])
                   cap.set(0, sec * 1000)
                   ret, frame = cap.read()
                   fra.append(frame)
           else:

               ret,frame=cap.read()
               fra.append(frame)
               if frame is None:
                   video_index += 1
                   if video_index == len(videoList):
                       break
                   cap = cv2.VideoCapture(videoList[indices.index(long_dur())])

                   cap.set(0,1000*sec)
                   ret, frame = cap.read()
                   fra.append(frame)

When I am trying to run I am getting the following error

  OpenCV Error: Unspecified error (The numpy array of typenum=2, ndims=3 can not be created) in NumpyAllocator::allocate, file ..\..\..\modules\python\src2\cv2.cpp, line 184
OpenCV Error: Insufficient memory (Failed to allocate 6220800 bytes) in cv::OutOfMemoryError, file ..\..\..\modules\core\src\alloc.cpp, line 52
Traceback (most recent call last):
  File "C:/Users/chaitanya/PycharmProjects/Thesis/ROI.py", line 86, in <module>
    ret,frame=cap.read()
cv2.error: ..\..\..\modules\core\src\alloc.cpp:52: error: (-4) Failed to allocate 6220800 bytes in function cv::OutOfMemoryError

I am not able to solve it.need help on this error