Как захватить определенный видеокадр и обработать его? - PullRequest
0 голосов
/ 22 октября 2019

Я использую OpenCV и транслирую потоковое видео с камеры, и я хочу захватить кадр при нажатии определенной клавиши и обработать этот кадр с помощью приведенного ниже кода. Как прервать захват видео в реальном времени и сохранить кадр для его обработки? Вот код того, что я делаю сейчас:

while cv.waitKey(1):
# get frame from the video
hasFrame, frame = cap.read()
# Need to capture a frame on pressing 'c' and then process it with code below.


if hasFrame:
    # Create a 4D blob from a frame.
    blob = cv.dnn.blobFromImage(frame, 1 / 255, (inpWidth, inpHeight), [0, 0, 0], 1, crop=False)

    # Sets the input to the network
    net.setInput(blob)

   # Runs the forward pass to get output of the output layers
    outs = net.forward(getOutputsNames(net))

    # Remove the bounding boxes with low confidence
    postprocess(frame, outs)
...