0

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():
2
  • in your code, where is frame defined? Commented Jul 10, 2017 at 8:47
  • @chris i have changed the question to my code Commented Jul 10, 2017 at 9:21

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

i will give it a try. Thanks a lot :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.