Compressing IplImage to JPEG using libjpeg in OpenCV

落花浮王杯 提交于 2019-12-04 21:48:09

I've never used libjpeg before, but it looks like you're mixing color spaces. You load the image as a grayscale (CV_LOAD_IMAGE_GRAYSCALE), but are telling libjpeg that it's an RGB image (JCS_RGB). Have you tried changing the line

cinfo.in_color_space = JCS_RGB;

to

cinfo.in_color_space = JCS_GRAYSCALE;

?

mpenkov

Is there any reason why you're not using opencv's native JPEG support?

cvSaveImage(frame, "frame.jpeg");

The documentation is here.

EDIT

If you insist on using libjpeg, have a look at this post.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!