gpt4 book ai didi

ios - 如何让 CvVideoCamera 不自动旋转?

转载 作者:技术小花猫 更新时间:2023-10-29 10:55:53 25 4
gpt4 key购买 nike

我的 CvVideoCamera 会自动旋转,但我不希望它这样做。 This has been raised on the bugtracker , 但是有一段时间没有事件了。

最佳答案

子类CvVideoCamera,只删除旋转代码。我希望我的方向始终是纵向的,所以这很简单:

MyCvVideoCamera.h

#import <opencv2/highgui/cap_ios.h>

@interface MyCvVideoCamera : CvVideoCamera

- (void)updateOrientation;
- (void)layoutPreviewLayer;

@property (nonatomic, retain) CALayer *customPreviewLayer;

@end

MyCvVideoCamera.m

#import "MyCvVideoCamera.h"

@implementation MyCvVideoCamera

- (void)updateOrientation;
{
// nop
}
- (void)layoutPreviewLayer;
{
if (self.parentView != nil) {
CALayer* layer = self.customPreviewLayer;
CGRect bounds = self.customPreviewLayer.bounds;
layer.position = CGPointMake(self.parentView.frame.size.width/2., self.parentView.frame.size.height/2.);
layer.bounds = bounds;
}
}
@end

关于ios - 如何让 CvVideoCamera 不自动旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14876895/

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