View Single Post
  #1   Spotlight this post!  
Unread 31-01-2015, 14:14
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 71
codedr will become famous soon enoughcodedr will become famous soon enough
Re: USB Camera on C++ SmartDashBoard

We are facing the same issue. I saved an image coming from the roborio and decoded the jpeg header.

The jpeg image coming from the camera is part of a mjpeg stream. According to https://www.ffmpeg.org/ffmpeg-bitstream-filters.html, the jpeg image is missing the DHT (huffman table) section.

> Unfortunately, these chunks are incomplete JPEG images, because they lack
> the DHT segment required for decoding.
> Quoting from http://www.digitalpreservation.gov/f...d000063.shtml:
>
> Avery Lee, writing in the rec.video.desktop newsgroup in 2001, commented
> that "MJPEG, or at least the MJPEG in AVIs having the MJPG fourcc, is
> restricted JPEG with a fixed – and *omitted* – Huffman table. The JPEG
> must be YCbCr colorspace, it must be 4:2:2, and it must use basic Huffman
> encoding, not arithmetic or progressive. . . . You can indeed extract the
> MJPEG frames and decode them with a regular JPEG decoder, but you have to
> prepend the DHT segment to them, or else the decoder won’t have any idea
> how to decompress the data. The exact table necessary is given in the
> OpenDML spec."
>
> This bitstream filter patches the header of frames extracted from an
> MJPEG stream (carrying the AVI1 header ID and lacking a DHT segment)
> to produce fully qualified JPEG images.
Reply With Quote