I'm just following the second example from this tutorial and using a different video. Can anyone help solve the problem of why it crashes? I thought it would be my cheap Windows 7 running on 2 GB RAM, but it's not even using up the RAM when it crashes.
import numpy as np
import cv2
cap = cv2.VideoCapture("F:\\OpenCV\\Cam1_Indoor.avi")
fgbg = cv2.createBackgroundSubtractorMOG2()
while(1):
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame',fgmask)
k = cv2.waitKey(30) & 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
UPDATE 1: I still can't get this working, but I have tried to debug it some more. I found that regardless of the video file name I give it (even if it's totally bogus), the same crash happens.
UPDATE 2: I found that the code below works on images, so my problem may have to do with video capture.
im_in = cv2.imread("F:\\OpenCV\\nickel.jpg", cv2.IMREAD_GRAYSCALE);
fgbg = cv2.createBackgroundSubtractorMOG2()
fgmask = fgbg.apply(im_in)
cv2.imshow('frame',fgmask)
cv2.waitKey(0)