Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

HTTP live stream from OpenCV

I am processing webcam input and modifying it with OpenCV. I would like to stream these modified frames to a web browser via HTTP.

I am currently using this basic code:

int main()
{
    cv::VideoCapture cap(0);

    while (true) {
        cv::Mat frame;
        cap.read(frame);

        if (!frame.empty()) {
            cv::imshow("Output", frame);
        }

        if (cv::waitKey(30) >= 0) {
            break;
        }
    }

    return 0;
}

But I am unsure of how to turn this into a video stream. I have looked into using ffmpeg to somehow stream it but I haven't been able to find any definitive solutions to what I'm looking for. How could I accomplish this?