本文介绍了使用Opencv示例从Camera保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从 https://github.com/Itseez/opencv_for_ios_book_samples\"rel =nofollow noreferrer> IOS示例。并试图从相机保存图像。问题是图像被保存但是带有蓝色色调,如下所示。
I have used this code from the IOS examples. And tried to save the images from camera. The issue is that the image is getting saved but with a blue tint as below.
以下是我用来保存图片的代码。
The below is the code I used to save the image.
- (void)processImagecv::Mat&image
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
UIImage * convertedImage = [ViewController imageWithCVMat:image];
[library writeImageToSavedPhotosAlbumconvertedImage CGImage] orientationALAssetOrientation)[convertedImage imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){
if (error)
{
// TODO: error handling
}
else
{
// TODO: success handling
NSLog(@"Success";
}
}];
TS(DetectAndAnimateFaces);
faceAnimator->detectAndAnimateFaces(image);
TE(DetectAndAnimateFaces);
}
推荐答案
在给定的图像中,通道的顺序是相反的,即来自opencv默认表示BGR图像具有RGB表示,即交换红色和蓝色通道。
In a given image order of channels is reversed, ie instead from opencv default representation BGR the image has the representation RGB, namely channel red and blue are swapped.
这篇关于使用Opencv示例从Camera保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!