Skip to content

Lightweight HTTP server to stream your OpenCV processing in C++

License

Notifications You must be signed in to change notification settings

desertbit/MJPEGWriter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 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()
{
    MJPEG server(7777);
    VideoCapture cap;
    bool ok = cap.open(0);
    if (!ok)
    {
        cerr << "No cam found" << endl;
        return 1;
    }
    Mat frame;
    cap >> frame;
    server.write(frame);
    frame.release();
    server.start();
    while (cap.isOpened())
    {
        cap >> frame;
        server.write(frame);
        frame.release();
        mySleep(40);
    }
    cout << "Camera shutdown" << endl;
    server.stop();
    return 0;
}

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

Compiling

Compile with C++11, OpenCV libraries and pthread:

g++ MJPEGWriter.cpp main.cpp -o MJPEG -lpthread -lopencv_core -lopencv_videoio -lopencv_imgcodecs -std=c++11

Roadmap

You can follow the development and request new features at https://trello.com/b/OZVtAu05

About

Lightweight HTTP server to stream your OpenCV processing in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%