Apr-22-2019, 03:24 AM
from imutils.perspective import four_point_transform import numpy as np import argparse import cv2 scaling_factorx = 0.8 scaling_factory = 0.8 cap = cv2.VideoCapture(0) fgbg = cv2.createBackgroundSubtractorMOG2() count = 0 while(1): ret, frame = cap.read() cv2.imshow('window-name', frame) cv2.imwrite("frame%d.jpg" %count, frame) count = count + 1 frame = cv2.resize(frame, None, fx = scaling_factorx, fy = scaling_factory, interpolation = cv2.INTER_AREA) fgmask = fgbg.apply(frame) cv2.imshow('frame', fgmask) gray_vid = cv2.cvtColor(frame, cv2.IMREAD_GRAYSCALE) cv2.imshow('Original', frame) edged_frame = cv2.Canny(frame,100, 200) cv2.imshow('Edges', edged_frame) k= cv2.waitKey(30); if k==27: break cap.release() cv2.destroyAllWindows()While running the code i get the error :
C:\Users\Sreeram Prakash\Desktop\Project Files>python task1.py
Traceback (most recent call last):
File "task1.py", line 17, in <module>
cv2.imshow('window-name', frame)
cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:350: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'