MJPEGWriter
Lightweight HTTP server to stream your OpenCV processing in C++
Install / Use
/learn @JPery/MJPEGWriterREADME
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: 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_highgui -lopencv_core -std=c++11
Roadmap
You can follow the development and request new features at https://trello.com/b/OZVtAu05
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
