Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教opencv滤镜问题 #3

Open
qweasdzxc110 opened this issue Aug 1, 2018 · 2 comments
Open

请教opencv滤镜问题 #3

qweasdzxc110 opened this issue Aug 1, 2018 · 2 comments

Comments

@qweasdzxc110
Copy link

很感谢你的代码,我想问问为什么在使用opencv滤镜时原图看起来偏蓝???这个是什么导致的呢

@muzipiao
Copy link
Owner

muzipiao commented Aug 2, 2018

OpenCV中Mat矩阵颜色是按照BGR来储存的,转成UIImage之后,是按照RGB来的。
所以在转换为UIImage之前,需要将Mat中的BGR转换为RGB;

cvtColor( InputArray src, OutputArray dst, CV_BGR2RGB );

在Demo中我将视频输出CMSampleBufferRef直接转为了Mat矩阵cv::Mat
imgMat;,然后用MatToUIImage(imgMat)转换为UIImage,所以看起来偏蓝;

想保持原样这样写即可:
cv::Mat rgbImgMat;
cv::cvtColor(imgMat, rgbImgMat, CV_BGR2RGB);
UIImage *outImg = MatToUIImage(rgbImgMat);

Tips: 视频图像处理计算量很大,大部分需求都不需要RGBA的4通道彩色图像,一般都是转换为单通道的灰色图像处理,计算速度倍升;例如图像识别,图像标识,识别后与原图像叠加即可。

@qweasdzxc110
Copy link
Author

非常感谢回复,也谢谢你的程序,对于我这种初学者帮助很大!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants