send video chunks from django to react

Viewed 35

I've a video comming from rstp feed, I successfully processed it using openCV python. now it is generating image frames and I want to sent these image frames directly to frontend as they are generated.

    while True:
        success, img = cap.read()
        img = cv2.resize(img, (0, 0), None, 0.5, 0.5)
        ih, iw, channels = img.shape
        blob = cv2.dnn.blobFromImage(
            img, 1 / 255, (input_size, input_size), [0, 0, 0], 1, crop=False)

        net.setInput(blob)
        layersNames = net.getLayerNames()
        outputNames = [(layersNames[i - 1])
                       for i in net.getUnconnectedOutLayers()]

        outputs = net.forward(outputNames)

        postProcess(outputs, img)


        # I want to send these frames to my react frontend 
        cv2.imshow('Output', img)
        
        if cv2.waitKey(1) == ord('q'):
            break

I've already work with API's but never encountered such situation

I'm confused how do I send these frames to my frontend. If streaming server is required, please share some references, any help will be appreciated.

0 Answers
Related