Skip to content

HTTP server to stream your OpenCV processing in C++

Notifications You must be signed in to change notification settings

cdominguezg/MJPEGWriter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MJPEGWriter

OpenCV Video HTTP Streaming via MJPEG. Based on the code found in StackExchange - CodeReview and Answers - OpenCV

#Example main

int main()
{
    MJPEGWriter test(7777); //Creates the MJPEGWriter class to stream on the given port
    VideoCapture cap;
    bool ok = cap.open(0); //Opens webcam
    if (!ok)
    {
        printf("no cam found ;(.\n");
        pthread_exit(NULL);
    }
    Mat frame;
    cap >> frame;
    test.write(frame); //Writes a frame (Mat class from OpenCV) to the server
    frame.release();
    test.start(); //Starts the HTTP Server on the selected port
    while(cap.isOpened()){
        cap >> frame; 
        test.write(frame); 
        frame.release();
    }
    test.stop(); //Stops the HTTP Server
    exit(0);
}

Note that you have to write an image to the MJPEGWriter class before start the server.

About

HTTP server to stream your OpenCV processing in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%