'Read JPEG frame from MJPEG camera without decoding in Python/OpenCV

I am writing an MJPEG video streaming application in Python on Ubuntu (headless). Depending on user inputs, I may or may not want to change anything about the frames captured from a MJPEG USB camera before streaming them to a webpage.

Currently, I'm reading the camera using OpenCV's VideoCapture() stream class. However, this wastes a lot of CPU/battery power converting the frame from JPEG to BGR array ( via VideoCapture().read() ) and back again when all I want to do is send the JPEG frame directly to the web page. Is there a way to read a frame from the camera as a JPEG without automatically decoding it? (This would also give me the chance to try TurboJPEG's JPEG decode instead of OpenCV's - its JPEG encode is a lot faster.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source