python - Exit code 139 when performing image subtraction -
i performing image subtraction using python. have images in form of numpy arrays. size of list carrying images 1000. each numpy array in list of 360*640 type. frame subtraction happening correct when number of frames around 300.
def find_der(frames): der = [] in range(len(frames)-1): der.append(frames[a + 1] - frames[a]) return der framesprocessing = 1000 j in range(framesprocessing): img = cv.queryframe(video) if img none: print("images not captured") else: tmp = cv.createimage(cv.getsize(img), 8, 3) saveimagescolor = 'abhiram_images/rgb/frame' + str(i) + '.png' #saving iplimages local pc cv.saveimage(saveimagescolor, img) saveimagesgray = 'abhiram_images/gray/frame' + str(i) + '.png' #saving grayscale images local pc img1 = cv2.imread(saveimagescolor) grayimg = cv2.cvtcolor(img1,cv2.color_bgr2gray) cv2.imwrite(saveimagesgray, grayimg) graynumpyimage = np.array(grayimg, dtype='int64') grayscale.append(graynumpyimage) += 1 first_der = find_der(grayscale)
when execute code frames processing 1000 getting following output:
process finished exit code 139
could me how overcome error , throw light when such kind of error
you might running out of memory: have 1000 images x 360 pixels x 640 pixels x 3 bands x 8 bits = 691 mb...
code 139 listed here "attempt access virtual address not in address space", support memory allocation error, happen if on 32-bit system low amount of ram, , other things in memory.
you might refactor code it's not necessary hold list of images in memory, instance, hold last image in memory, perform subtraction , overwrite current image.
you test replacing function with:
a = [] in range(1000): a.append(numpy.ones((360,640,3), dtype=numpy.int))
and seeing if runs without running out of memory.
Comments
Post a Comment