【问题标题】:Save image from Camera using Opencv Example使用 Opencv 示例从相机保存图像
【发布时间】:2017-09-05 08:33:42
【问题描述】:

我使用了来自IOS examplesthis code。并试图从相机中保存图像。问题是图像正在保存,但带有如下蓝色调。

下面是我用来保存图片的代码。

 - (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);
}

【问题讨论】:

  • 您发布的图像的通道是相反的,即不是RGB顺序,而是BGR,即交换绿色红色和蓝色通道。
  • @marol 感谢您的回复。这解决了这个问题。请发布它作为答案。以后会对其他人有所帮助。

标签: ios iphone objective-c opencv ios5


【解决方案1】:

在给定的图像中,通道的顺序是颠倒的,即从 opencv 默认表示 BGR 图像具有表示 RGB,即通道红色和蓝色被交换。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-19
    相关资源
    最近更新 更多