'webcam is continuously active and running , how to close webcam?

import cv2 as cv
import numpy as np
camera=cv.VideoCapture(0)

while True:

    _, frame=camera.read()
    
    cv.imshow('original',frame)
    
    laplacian=cv.Laplacian(frame,cv.CV_64F)
    laplacian=np.uint8(laplacian)
    cv.imshow('laplacian',laplacian)
    
    
    edges=cv.Canny(frame,150,100)
    
    cv.imshow('edged',edges)
    
    if cv.waitKey(1) ==ord('x'):
        break
    
camera.release()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source