{"action":"created","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/6250","repository_url":"https://api.github.com/repos/Itseez/opencv","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/6250/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/6250/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/6250/events","html_url":"https://github.com/Itseez/opencv/issues/6250","id":140531521,"number":6250,"title":"Failed ASSERTION createBackgroundSubtractorMOG2().apply() for pictures","user":{"login":"bw4sz","id":1208492,"avatar_url":"https://avatars.githubusercontent.com/u/1208492?v=3","gravatar_id":"","url":"https://api.github.com/users/bw4sz","html_url":"https://github.com/bw4sz","followers_url":"https://api.github.com/users/bw4sz/followers","following_url":"https://api.github.com/users/bw4sz/following{/other_user}","gists_url":"https://api.github.com/users/bw4sz/gists{/gist_id}","starred_url":"https://api.github.com/users/bw4sz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bw4sz/subscriptions","organizations_url":"https://api.github.com/users/bw4sz/orgs","repos_url":"https://api.github.com/users/bw4sz/repos","events_url":"https://api.github.com/users/bw4sz/events{/privacy}","received_events_url":"https://api.github.com/users/bw4sz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Itseez/opencv/labels/category:%20video","name":"category: video","color":"ededed"},{"url":"https://api.github.com/repos/Itseez/opencv/labels/incomplete","name":"incomplete","color":"000000"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-13T21:30:57Z","updated_at":"2016-05-27T09:28:29Z","closed_at":null,"body":"Migrated from [separate issue](https://github.com/Itseez/opencv/issues/4871#issuecomment-195961172) as requested by @alalek \r\n\r\n### Please state the information for your system\r\n- OpenCV version: 3.1.0 dev\r\n- Host OS: Windows 10\r\n- Compiler & CMake: GCC 5.3 & CMake 3.5\r\n\r\n### In which part of the OpenCV library you got the issue?\r\nExamples:\r\n- background subtraction (bgsegm)\r\n\r\n### Expected behavior\r\nApply each frame to the background\r\n### Actual behavior\r\nThrows failed memory assertion if frame size is large\r\n\r\n### Additional description\r\n\r\nHere is a simple example of trying to create a background model from pictures, not video. This only occurs when using pictures from file, not when using cv2.videocapture from a video file to read frames. It fails on the very first position in the loop. Once they are numpy arrays, what does it matter? \r\n\r\nLooking at memory, it does rise, but certainly does not spike dramatically. \r\n\r\nI've tried smaller photos (shape~ (1920,2560,3) and i get the error after 3 photos. \r\n\r\n### Code example to reproduce the issue / Steps to reproduce the issue\r\n\r\n    import cv2 \r\n    import glob\r\n    import os\r\n    import cv2.bgsegm\r\n    \r\n    \r\n    #File formats\r\n    ext=\"C:/Users/Ben/Desktop/pics2/*.jpg\"\r\n    \r\n    #Create mog\r\n    b=cv2.createBackgroundSubtractorMOG2()\r\n    \r\n    #Find photos\r\n    jpgs=[]\r\n    jpgs.extend(glob.glob(ext))\r\n    \r\n    #Read in photos and add to background\r\n    for x in jpgs:\r\n        current_image=cv2.imread(x)\r\n        print(\"Photo size is %s\" % str(current_image.shape))\r\n        b.apply(current_image)        \r\n    \r\nReturns:\r\n    \r\n    Photo size is (2992, 5152, 3)\r\n    OpenCV Error: Insufficient memory (Failed to allocate 1541478400 bytes) in OutOfMemoryError, file C:\\opencv\\source\\opencv\\modules\\core\\src\\alloc.cpp, line 52\r\n    OpenCV Error: Assertion failed (u != 0) in create, file C:\\opencv\\source\\opencv\\modules\\core\\src\\matrix.cpp, line 432\r\n"},"comment":{"url":"https://api.github.com/repos/Itseez/opencv/issues/comments/222102083","html_url":"https://github.com/Itseez/opencv/issues/6250#issuecomment-222102083","issue_url":"https://api.github.com/repos/Itseez/opencv/issues/6250","id":222102083,"user":{"login":"sturkmen72","id":12151541,"avatar_url":"https://avatars.githubusercontent.com/u/12151541?v=3","gravatar_id":"","url":"https://api.github.com/users/sturkmen72","html_url":"https://github.com/sturkmen72","followers_url":"https://api.github.com/users/sturkmen72/followers","following_url":"https://api.github.com/users/sturkmen72/following{/other_user}","gists_url":"https://api.github.com/users/sturkmen72/gists{/gist_id}","starred_url":"https://api.github.com/users/sturkmen72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sturkmen72/subscriptions","organizations_url":"https://api.github.com/users/sturkmen72/orgs","repos_url":"https://api.github.com/users/sturkmen72/repos","events_url":"https://api.github.com/users/sturkmen72/events{/privacy}","received_events_url":"https://api.github.com/users/sturkmen72/received_events","type":"User","site_admin":false},"created_at":"2016-05-27T09:28:29Z","updated_at":"2016-05-27T09:28:29Z","body":"https://github.com/Itseez/opencv/issues/6595"}}
{"actor":{"display_login":"sturkmen72"}}