Approach to apply canny edge detector on a video instead of a still image

As part of my current project, I need to perform edge detection using canny edge detector on a given video. I know how to do this on a still image. But, Iam interetsed to know if there is any other approach to do this on a video instead of simply applying canny over all the frames one after the other.

  • Iam adding the sample code for edge detector using canny on a still image.

  • I tried the same approach over a video by reading all the frames one by one and I got the output as well.

  • I am actually interested to know is this the only approach to be followed incase of a video or is there any other approach for a video

    #reading a still image
    image = cv2.imread(image_path)
    
    #converting to Grayscale
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    
    #applying gaussian low pass filter
    gauss_image = cv2.GaussianBlur(gray_image, kernel_size,sigmaX,sigmaY)
    
    #applying canny edge detector
    edges = cv2.Canny(gauss_image,lower_threshold, upper_threshold)

Hi
what’s your code with image?

Using this tutorial you can insert your own code :

# Our operations on the frame come here

gray_image= cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
#applying gaussian low pass filter
gauss_image = cv.GaussianBlur(gray_image, kernel_size,sigmaX,sigmaY)

#applying canny edge detector
edges = cv.Canny(gauss_image,lower_threshold, upper_threshold)
# Display the resulting frame

cv.imshow('frame', edges )