title: Canny edge output is corrupted
body: <p>I am applying Canny edge detector in a video using OpenCV. I can see the result in a window and then I am writing the video. Even though I can see the right result on the window, the result in the output file is not the same.</p>
  <p>Here is the code and what I can see in the window and in the output file. Any idea what can cause this?
  I am not sure what is the output of Canny and if I have to turn it to type of data that will fit with the rest of the video.</p>
  <pre><code>        `
  
      import cv2
      import numpy as np
  
  
      cap = cv2.VideoCapture('New_video.mp4')
      if (cap.isOpened() == False):
       print(&quot;Unable to read camera feed&quot;)
  
       frame_width = int(cap.get(3))
       frame_height = int(cap.get(4))
       fps = int(round(cap.get(5)))
       out = cv2.VideoWriter('output.mp4', cv2.VideoWriter_fourcc(*'mp4v'), fps, 
     (frame_width, frame_height))
  
      while (True):
      ret, frame = cap.read()
      if ret == False:
      break 
           if between (cap,40000,45000):
             gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
             frame = cv2.blur(gray,(5,5))
             frame = cv2.Canny(frame,20,60)   
           if between (cap,45000,50000):
            gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
            frame = cv2.blur(gray,(5,5))
            frame = cv2.Canny(frame,150,250)` 
         out.write(frame)    
         cv2.imshow('frame',frame)
  </code></pre>