Ask Your Question

luluzhong's profile - activity

2019-10-11 01:31:44 -0600 received badge  Notable Question (source)
2018-01-16 16:13:11 -0600 received badge  Popular Question (source)
2015-11-17 15:09:03 -0600 received badge  Organizer (source)
2015-11-17 15:07:43 -0600 asked a question cap.read() returns false

For some reason, VideoCapture can open a video but then can't read it. cap.read() keeps returning false. When I take VideoCapture from the webcam, there is no issue. I'm using the master branch with python on a mac (El Capitan)

import numpy as np
import cv2

cap = cv2.VideoCapture('blogilates.mp4')

while(cap.isOpened()):
    ret, frame = cap.read()
    print ret

    cv2.imshow('frame', frame)
    if (cv2.waitKey(1) & 0xFF == ord('q')):
        break
cap.release()
cv2.destroyAllWindows()
2015-11-17 14:53:15 -0600 asked a question CV_CAP_PROP_FRAME_WIDTH

I'm using the master branch of opencv with python. How do I access constants like frame width and etc. Some places use cv2.cv.CV_CAP_PROP_FRAME_WIDTH, but for some reason when I when I import cv2.cv as cv, i get the following error...

import cv2.cv as cv ImportError: No module named cv

import numpy as np
import cv2
import cv2.cv as cv

cap = cv2.VideoCapture(0)

w=int(cap.get(cv.CV_CAP_PROP_FRAME_WIDTH ))
h=int(cap.get(cv.CV_CAP_PROP_FRAME_HEIGHT ))
2015-11-09 23:11:38 -0600 commented question createBackgroundSubtractor() segmentation fault

I have the opencv_contrib branch though. Do I call stuff from there differently?

2015-11-09 22:57:42 -0600 asked a question createBackgroundSubtractor() segmentation fault

I'm using Python 2.7.10 and OpenCV '3.0.0' I'm trying to run the tutorials provided here...http://docs.opencv.org/master/db/d5c/tutorial_py_bg_subtraction.html#gsc.tab=0

I'm using the exact same code but I'm getting a Segmentation fault: 11

import numpy as np
import cv2

cap = cv2.VideoCapture('tree.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()

Also when I try createBackgroundSubtractorMOG() or createBackgroundSubtractorGMG(), I get this AttributeError: 'module' object has no attribute 'createBackgroundSubtractorGMG'.....what the heck is going on?