gpt4 book ai didi

c++ - CvVideoCamera processImage 不会改变图像

转载 作者:行者123 更新时间:2023-11-29 05:28:58 25 4
gpt4 key购买 nike

Simple example CvVideoCamera 使用情况无法按预期工作。在委托(delegate)的 processImage 中修改的图像显示没有任何更改。

ViewController.h:

#import <UIKit/UIKit.h>
#import <opencv2/videoio/cap_ios.h>

@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *btnStart;
@property (weak, nonatomic) IBOutlet UIImageView *myimg;

@end

ViewController.mm:

#import "ViewController.h"
#import <opencv2/videoio/cap_ios.h>

@interface ViewController ()<CvVideoCameraDelegate>
@property (strong, nonatomic) CvVideoCamera *videoCamera;
@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:self.myimg];
[self.videoCamera setDelegate:self];
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetHigh;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
self.videoCamera.useAVCaptureVideoPreviewLayer = YES;
}

- (IBAction)actionStart:(id)sender {
[self.videoCamera start];
}

- (void)processImage:(cv::Mat &)image;
{
cv::Mat image_copy;
cvtColor(image, image_copy, CV_BGRA2BGR);
bitwise_not(image_copy, image_copy);
cvtColor(image_copy, image, CV_BGR2BGRA);
}

一旦我按下按钮,就会呈现正常的摄像机流,没有任何干预的痕迹。我还尝试绘制形状,甚至在 processImage 内部调用 image.release() 但没有效果。

我想我在这里遗漏了一些明显的东西。 There's the example repository

This is what I'm getting on the screen

最佳答案

这一行是问题的根源:

self.videoCamera.useAVCaptureVideoPreviewLayer = YES;

一旦删除,一切都会按预期进行。

关于c++ - CvVideoCamera processImage 不会改变图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57851453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com