I am currently doing a motion detection project that records video when motion is detected. I am having an error when recording the video.
This is the following error:
error: (-215) img.cols == width && img.rows == height && channels == 3 in function cv::mjpeg::MotionJpegWriter::write
This is my code:
def takevid():
Your problem is scope of the variable frame
. You either need to declare frame outside the while loop, just globally in the file, or pass it as an argument to takevid
. Currently frame
is only available in the while loop, but that when you call takevid
only the global scope (i.e camera
) is accessible, not that of the while loop.
The error is telling you that the size of frame
is wrong, and most likely you would find the shape is (0,0)
because there is nothing in that variable.