How to threshold a live video on OpenCV?

I am trying to threshold a live webcam video capture. I’d like to threshold it based on their intensity. I have included the full code below. When I run the code, only the CamHSV window is shown, the window for thresh isn’t shown.
sorry for the bad english

import numpy as np
import cv2 as cv

def changeRes(width, height):
    capture.set(3, width)
    capture.set(4, height)

capture = cv.VideoCapture(2)

while True:
    isTrue, frame = capture.read()
    CamHSV = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    cv.imshow('Cam', CamHSV)
    if cv.waitKey(1) &0xFF == ord('1'):
        break
lower = np.array([0,48,80])
dtype = 'uint8'
upper = np.array([18,255,255])
dtype = 'uint8'

SkinTresholdHSV = cv.inRange(CamHSV,lower,upper)
blurredHSV = cv.blur(SkinTresholdHSV,(3,3))
ret, thresh = cv.threshold(blurredHSV,0,255,cv.THRESH_BINARY)
cv.imshow('thresh', thresh)

you need another cv.waitKey(0) on the last line

and maybe, the thresholdig code should go inside the loop ?

Thanks for the reply,
But I tried using cv.WaitKey(0) at the end of the line and it doesn’t do any different.
Putting the thresholding code inside the loop just gives an error as shown below.

Traceback (most recent call last):
  File "C:\Users\USER\PycharmProjects\OpenCV\FirstTry.py", line 17, in <module>
    SkinTresholdHSV = cv.inRange(CamHSV, lower, upper)
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-1i5nllza\opencv\modules\core\src\arithm.cpp:1742: error: (-209:Sizes of input arguments do not match) The lower boundary is neither an array of the same size and same type as src, nor a scalar in function 'cv::inRange'

[ WARN:1] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-1i5nllza\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback

Process finished with exit code 1

This is how I put the thresholding code inside the loop

import numpy as np
import cv2 as cv

def changeRes(width, height):
    capture.set(3, width)
    capture.set(4, height)

capture = cv.VideoCapture(1)

while True:
    isTrue, frame = capture.read()
    CamHSV = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    lower = np.array([0, 48, 80])
    dtype = 'uint8'
    upper = np.array([18, 255, 255])
    dtype = 'uint8'
    SkinTresholdHSV = cv.inRange(CamHSV, lower, upper)
    blurredHSV = cv.blur(SkinTresholdHSV, (3, 3))
    ret, thresh = cv.threshold(blurredHSV, 0, 255, cv.THRESH_BINARY)
    cv.imshow('thresh', thresh)
    cv.imshow('Cam', CamHSV)
    if cv.waitKey(1) &0xFF == ord('1'):
        break

cv.waitKey(0)

meditate on that message.

then propose how to investigate the situation (I’d propose to check the shapes of those arguments)

also meditate on this line, it does not do what it says