MJPG 图像格式的网络摄像头
我正在使用 C# 和支持 YUY2 或 MJPG 图像格式的 USB 网络摄像头。到目前为止,我一直在 YUY2 模式下使用它,效果很好。最近,我尝试将格式更改为 MJPG,认为这样可以为我的程序每帧捕获提供一张 JPEG 图像。看起来几乎做到了。当我尝试显示缓冲区时,我的应用程序总是出现一个模糊的异常,但似乎表明该流无效。然后,我将其中一个缓冲区复制到一个文件中,并尝试使用 IrfanView 查看它,它告诉我没有霍夫曼表。使用二进制编辑器查看缓冲区,我发现它确实具有 SOI 和 EOF JPEG 标记(以及其他几个标记);但是,它不包含霍夫曼表标记。你知道我在这里做错了什么吗?我读过一些有关 JPEG 的内容,显然在某些情况下图像可以使用标准哈夫曼表来减小文件大小;但是,如果是这种情况,我该如何将其插入图像中(如果适用)? 顺便说一下,这是参考 Microsoft Lifecam 的。
I'm working with C# and a usb webcam that supports YUY2 or MJPG image formats. Thus far I've always had it in YUY2 mode and that works fine. Recently I tried changing the format to MJPG thinking that it would then feed my program one JPEG image per frame capture. It appears to almost do that. When I try to display the buffer, my app always takes an exception which is vague, but seems to indicate that the stream is invalid. I then copied one of the buffers to a file and tried to view it with IrfanView and it tells me that there is no huffman table. Looking at the buffer with a binary editor, I see it does have the SOI and EOF JPEG markers (and several others); however, it doesn't contain a huffman table marker. Any ideas what I'm doing wrong here? I've read a bit about JPEG and apparently there are cases where images can use a standard huffman table to reduce file size; however, if that's the case, how do I insert this into the image (if appropriate)?
This is with reference to Microsoft Lifecam by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AVI 文件的 Motion-JPEG 标准的一部分是使用固定的霍夫曼表,这样就不必将其存储在每一帧中。
Part of the Motion-JPEG standard for AVI files is that a fixed Huffman table will be used so that it doesn't have to be stored in every frame.