iOS AVFoundation/AVCaptureSession实现自定义相机界面拍照(四)拍照、自定义裁剪框、图片查看器

本文主要是介绍iOS AVFoundation/AVCaptureSession实现自定义相机界面拍照(四)拍照、自定义裁剪框、图片查看器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

----参考框架:

a122273328/Camera

https://blog.csdn.net/aa122273328/article/details/72886022

https://github.com/a122273328/Camera

从系统相册选择照片后,自定义裁剪框:

LazyDuan/LDImagePicker

https://github.com/LazyDuan/LDImagePicker

图片查看器:PYPhotoBrowser    https://github.com/ko1o/PYPhotoBrowser

MWPhotoBrowser  :https://github.com/mwaterfall/MWPhotoBrowser


-----------自定义裁剪框的步骤:-----------

1.当我们实现了UIImagePickerController的代理后,需要在 imagePickerController:didFinishPickingMediaWithInfo:

imagePickerController.allowsEditing = true; 如果为true,就不会展现我们自己的裁剪视图了,就无法自定义了

2.跳转到自定义的控制器中去,吧从相册中的获取的图片传递到控制器中;

 UIImage *originImage = info[@"UIImagePickerControllerOriginalImage"];

    ImagePickerCropViewController *vc = [[ImagePickerCropViewController alloc] init];

    vc.originImage = originImage;

    [picker pushViewController:vc animated:true];

3.在控制器中用一个Imageview显示图片,然后给imageview添加手势;实现缩放;最后保存;

************

#import "ViewController.h"
#import "ImagePickerCropViewController.h"@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];}- (IBAction)choosePhotot:(id)sender {UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//     imagePickerController.allowsEditing = true; 如果为true,就不会展现我们自己的裁剪视图了,就无法自定义了imagePickerController.delegate = self;[self presentViewController:imagePickerController animated:true completion:nil];}- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {UIImage *originImage = info[@"UIImagePickerControllerOriginalImage"];ImagePickerCropViewController *vc = [[ImagePickerCropViewController alloc] init];vc.originImage = originImage;[picker pushViewController:vc animated:true];
}- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {[picker dismissViewControllerAnimated:true completion:nil];
}@end


#import <UIKit/UIKit.h>@interface ImagePickerCropViewController : UIViewController@property (nonatomic, strong) UIImage *originImage;@end


#import "ImagePickerCropViewController.h"@interface ImagePickerCropViewController ()@property (nonatomic, strong) UIImageView *cropImageView;@end@implementation ImagePickerCropViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor = [UIColor blackColor];UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save)];self.navigationItem.rightBarButtonItem = item;CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 44);self.cropImageView = [[UIImageView alloc] initWithFrame:frame];_cropImageView.contentMode = UIViewContentModeScaleAspectFit;[_cropImageView setImage:self.originImage];_cropImageView.userInteractionEnabled = true;[self.view addSubview:_cropImageView];UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];[self.cropImageView addGestureRecognizer:pan];UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];[self.cropImageView addGestureRecognizer:pinch];UIView *maskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];maskView.center = self.view.center;maskView.backgroundColor = [UIColor clearColor];maskView.layer.borderWidth = 0.5;maskView.layer.borderColor = [UIColor whiteColor].CGColor;[self.view addSubview:maskView];}- (void)handlePinch:(UIPinchGestureRecognizer *)recognizer {CGFloat scale = recognizer.scale;recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, scale, scale); //在已缩放大小基础下进行累加变化;区别于:使用 CGAffineTransformMakeScale 方法就是在原大小基础下进行变化recognizer.scale = 1.0;
}- (void)handlePan:(UIPanGestureRecognizer *)recognizer {if (recognizer.state != UIGestureRecognizerStateEnded && recognizer.state != UIGestureRecognizerStateFailed){CGPoint translation = [recognizer translationInView:self.view];CGPoint center = self.cropImageView.center;self.cropImageView.center = CGPointMake(center.x + translation.x, center.y + translation.y);[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];}
}- (UIImage *)captureScreen {UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];CGRect rect = [keyWindow bounds];UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0);CGContextRef context = UIGraphicsGetCurrentContext();[keyWindow.layer renderInContext:context];UIImage *img = UIGraphicsGetImageFromCurrentImageContext();img = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(img.CGImage, CGRectMake((self.view.center.x-100)*2+2, (self.view.center.y-100)*2+2, 400-4, 400-4))];UIGraphicsEndImageContext();return img;
}- (void)save {UIImageWriteToSavedPhotosAlbum([self captureScreen], nil, nil, nil);
}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];
}@end

----------------------

#import "ViewController.h"

#import <AVFoundation/AVFoundation.h>

#import <AssetsLibrary/AssetsLibrary.h>//写入相册需要的


@interface ViewController ()<UIGestureRecognizerDelegate>

/**

 *  AVCaptureSession对象来执行输入设备和输出设备之间的数据传递

 */

@property (nonatomic,strong)AVCaptureSession* session;

/**

 *  输入设备

 */

@property (nonatomic,strong)AVCaptureDeviceInput* videoInput;

/**

 *  照片输出流

 */

@property (nonatomic,strong)AVCaptureStillImageOutput* stillImageOutput;//10.0以前

//@property (nonatomic, strong) AVCapturePhotoOutput* stillImageOutput;//10.0以后

/**

 *  预览图层

 */

@property (nonatomic,strong)AVCaptureVideoPreviewLayer* previewLayer;


@property (strong,nonatomicUIButton *captureBtn;//拍照按钮

@property (strong,nonatomic)UIButton *openCaptureBtn;//打开摄像头按钮

@property(nonatomic,assign)BOOL isUsingFrontFacingCamera;//切换镜头

/**

 *  记录开始的缩放比例

 */

@property(nonatomic,assign)CGFloat beginGestureScale;

/**

 *  最后的缩放比例

 */

@property(nonatomic,assign)CGFloat effectiveScale;

@end


@implementation ViewController


-(void)takeCapture{

    [selftakePhotoButtonClick:nil];//拍照


}

-(void)openCapture{



}


-(void)flashBtn{

    [selfflashButtonClick:nil];//闪光灯

}


-(void)glassBtn{

    [selfswitchCameraSegmentedControlClick:nil];//切换镜头


}

- (void)viewDidLoad {

    [superviewDidLoad];

    [selfsetUpGesture];


    UIButton *captureBtn=[[UIButtonalloc]initWithFrame:CGRectMake(30,300,60,30)];

    self.captureBtn=captureBtn;

    captureBtn.backgroundColor=[UIColorblueColor];

    captureBtn.titleLabel.textColor=[UIColorgreenColor];

    [captureBtn setTitle:@"拍照"forState:UIControlStateNormal];

    [captureBtn addTarget:self action:@selector(takeCapture)forControlEvents:UIControlEventTouchDown];

    [self.viewaddSubview:captureBtn];

    

    UIButton *openCaptureBtn=[[UIButtonalloc]initWithFrame:CGRectMake(30,380,60,30)];

    self.openCaptureBtn=openCaptureBtn;

    openCaptureBtn.backgroundColor=[UIColorblueColor];

    [openCaptureBtn setTitle:@"摄像"forState:UIControlStateNormal];

    [openCaptureBtn addTarget:selfaction:@selector(openCapture)forControlEvents:UIControlEventTouchDown];

    [self.viewaddSubview:openCaptureBtn];

    

    UIButton *flashBtn=[[UIButtonalloc]initWithFrame:CGRectMake(30,420,60,30)];


    flashBtn.backgroundColor=[UIColorblueColor];

    [flashBtn setTitle:@"闪光灯"forState:UIControlStateNormal];

    [flashBtn addTarget:selfaction:@selector(flashBtn)forControlEvents:UIControlEventTouchDown];

    [self.viewaddSubview:flashBtn];


    UIButton *glassBtn=[[UIButtonalloc]initWithFrame:CGRectMake(30,480,60,30)];

    

    glassBtn.backgroundColor=[UIColorblueColor];

    [glassBtn setTitle:@"切换摄像头"forState:UIControlStateNormal];

    [glassBtn addTarget:selfaction:@selector(glassBtn)forControlEvents:UIControlEventTouchDown];

    [self.viewaddSubview:glassBtn];

        [selfinitAVCaptureSession];

//    self.openCaptureBtn.hidden = NO;

//    self.captureBtn.hidden = YES;

}



//闪光灯的设置非常简单,只需要修改deviceflashMode属性即可,这里需要注意的是,修改device时候需要先锁住,修改完成后再解锁,否则会崩溃,设置闪光灯的时候也需要做安全判断,验证设备是否支持闪光灯,有些iOS设备是没有闪光灯的,如果不做判断还是会crash

- (void)flashButtonClick:(UIBarButtonItem *)sender {

    

    NSLog(@"flashButtonClick");

    //mediatype类型: AVMediaTypeVideo, AVMediaTypeAudio, or AVMediaTypeMuxed

    AVCaptureDevice *device = [AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo];

    

    //修改前必须先锁定

    [device lockForConfiguration:nil];

    //必须判定是否有闪光灯,否则如果没有闪光灯会崩溃

    if ([devicehasFlash]) {

        device.flashMode =AVCaptureFlashModeOn;


//        if (device.flashMode == AVCaptureFlashModeOff) {

//            device.flashMode = AVCaptureFlashModeOn;

//            

            [sender setTitle:@"flashOn"];

//        } else if (device.flashMode == AVCaptureFlashModeOn) {

//            device.flashMode = AVCaptureFlashModeAuto;

            [sender setTitle:@"flashAuto"];

//        } else if (device.flashMode == AVCaptureFlashModeAuto) {

//            device.flashMode = AVCaptureFlashModeOff;

            [sender setTitle:@"flashOff"];

//        }

        

    } else {

        

        NSLog(@"设备不支持闪光灯");

    }

    [device unlockForConfiguration];

}


#pragma 创建手势

- (void)setUpGesture{

    

    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizeralloc]initWithTarget:selfaction:@selector(handlePinchGesture:)];

    pinch.delegate =self;

    [self.viewaddGestureRecognizer:pinch];

}


#pragma mark gestureRecognizer delegate

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer

{

    if ( [gestureRecognizerisKindOfClass:[UIPinchGestureRecognizerclass]] ) {

        self.beginGestureScale =self.effectiveScale;

    }

    returnYES;

}

//缩放手势用于调整焦距

- (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer{

    

    BOOL allTouchesAreOnThePreviewLayer =YES;

    NSUInteger numTouches = [recognizernumberOfTouches], i;//几个手指

    for ( i =0; i < numTouches; ++i ) {

        CGPoint location = [recognizerlocationOfTouch:iinView:self.view];//i是指第几个手指

        CGPoint convertedLocation = [self.previewLayerconvertPoint:locationfromLayer:self.previewLayer.superlayer];//selfview上的点转换到self.previewLayer上坐标

        if ( ! [self.previewLayercontainsPoint:convertedLocation] ) {

            allTouchesAreOnThePreviewLayer = NO;//如果self.view上的转换到preview的坐标不在preview上,设置NO

            break;

        }

    }

    

    if ( allTouchesAreOnThePreviewLayer ) {

        

        

        self.effectiveScale =self.beginGestureScale * recognizer.scale;//获取当前手势的缩放比例

        if (self.effectiveScale <1.0){

            self.effectiveScale =1.0;

        }

        

        NSLog(@"%f-------------->%f------------recognizerScale%f",self.effectiveScale,self.beginGestureScale,recognizer.scale);

        

        //获取最大缩放比例

        CGFloat maxScaleAndCropFactor = [[self.stillImageOutputconnectionWithMediaType:AVMediaTypeVideo]videoMaxScaleAndCropFactor];

        

        NSLog(@"%f",maxScaleAndCropFactor);

        //超过最大,取最大

        if (self.effectiveScale > maxScaleAndCropFactor)

            self.effectiveScale = maxScaleAndCropFactor;

   

        //layer层的隐式动画

        [CATransactionbegin];

        [CATransactionsetAnimationDuration:.025];

        [self.previewLayersetAffineTransform:CGAffineTransformMakeScale(self.effectiveScale,self.effectiveScale)];//缩放

        [CATransactioncommit];//提交动画

        

    }

    

}


//切换镜头

- (void)switchCameraSegmentedControlClick:(UISegmentedControl *)sender {

    

    NSLog(@"%ld",(long)sender.selectedSegmentIndex);

    

    AVCaptureDevicePosition desiredPosition;

    if (self.isUsingFrontFacingCamera){

        desiredPosition = AVCaptureDevicePositionBack;//摄像头位置在后面

    }else{

        desiredPosition = AVCaptureDevicePositionFront;//摄像头位置在前面

    }

    

    for (AVCaptureDevice *din [AVCaptureDevicedevicesWithMediaType:AVMediaTypeVideo]) {

        if ([dposition] == desiredPosition) {

            [self.previewLayer.sessionbeginConfiguration];//开启配置

            AVCaptureDeviceInput *input = [AVCaptureDeviceInputdeviceInputWithDevice:derror:nil];

            for (AVCaptureInput *oldInputinself.previewLayer.session.inputs) {

                [[self.previewLayersession]removeInput:oldInput];//移除旧的会话

            }

            [self.previewLayer.sessionaddInput:input];//新的输入关联会话

            [self.previewLayer.sessioncommitConfiguration];//重新配置后,会话重新提交配置

            break;

        }

    }

    

    self.isUsingFrontFacingCamera = !self.isUsingFrontFacingCamera;

}



- (void)initAVCaptureSession{

    

    self.session = [[AVCaptureSessionalloc]init];

    

    NSError *error;

    

    AVCaptureDevice *device = [AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo];

    

    //更改这个设置的时候必须先锁定设备,修改完后再解锁,否则崩溃

    [device lockForConfiguration:nil];

    //设置闪光灯为自动

    [device setFlashMode:AVCaptureFlashModeAuto];

    [device unlockForConfiguration];

    

    self.videoInput = [[AVCaptureDeviceInputalloc]initWithDevice:deviceerror:&error];

    if (error) {

        NSLog(@"%@",error);

    }

    self.stillImageOutput = [[AVCaptureStillImageOutputalloc]init];

    //输出设置。AVVideoCodecJPEG  输出jpeg格式图片

    NSDictionary * outputSettings = [[NSDictionaryalloc]initWithObjectsAndKeys:AVVideoCodecJPEG,AVVideoCodecKey,nil];

    [self.stillImageOutputsetOutputSettings:outputSettings];

    

    if ([self.sessioncanAddInput:self.videoInput]) {

        [self.sessionaddInput:self.videoInput];

    }

    if ([self.sessioncanAddOutput:self.stillImageOutput]) {

        [self.sessionaddOutput:self.stillImageOutput];

    }

    

    //初始化预览图层

    self.previewLayer = [[AVCaptureVideoPreviewLayeralloc]initWithSession:self.session];

    [self.previewLayersetVideoGravity:AVLayerVideoGravityResizeAspect];

    self.previewLayer.frame =CGRectMake(0,0,375,375 - 64);

    self.view.layer.masksToBounds = YES;

    [self.view.layeraddSublayer:self.previewLayer];

}


- (void)viewWillAppear:(BOOL)animated{

    

    [superviewWillAppear:YES];

    

    if (self.session) {

        

        [self.sessionstartRunning];//开启会话

    }

}



- (void)viewDidDisappear:(BOOL)animated{

    

    [superviewDidDisappear:YES];

    

    if (self.session) {

        

        [self.sessionstopRunning];

    }

}



//拍照,输出图片

- (void)takePhotoButtonClick:(UIBarButtonItem *)sender {

    //输出图像的时候需要用到AVCaptureConnection这个类,session通过AVCaptureConnection连接AVCaptureStillImageOutput进行图片输出,

    AVCaptureConnection *stillImageConnection = [self.stillImageOutput        connectionWithMediaType:AVMediaTypeVideo];

    UIDeviceOrientation curDeviceOrientation = [[UIDevicecurrentDevice]orientation];

    AVCaptureVideoOrientation avcaptureOrientation = [selfavOrientationForDeviceOrientation:curDeviceOrientation];

    [stillImageConnection setVideoOrientation:avcaptureOrientation];

//这个方法是控制焦距用的暂时先固定为1,后边写手势缩放焦距的时候会修改这里

    [stillImageConnection setVideoScaleAndCropFactor:1];

    

    [self.stillImageOutputcaptureStillImageAsynchronouslyFromConnection:stillImageConnectioncompletionHandler:^(CMSampleBufferRef imageDataSampleBuffer,NSError *error) {

    //获得图片数据

        NSData *jpegData = [AVCaptureStillImageOutputjpegStillImageNSDataRepresentation:imageDataSampleBuffer];

        

        CFDictionaryRef attachments =CMCopyDictionaryOfAttachments(kCFAllocatorDefault,

                                                                    imageDataSampleBuffer,

                                                                   kCMAttachmentMode_ShouldPropagate);

//

        


    // 写入相册之前需要判断用户是否允许了程序访问相册,否则程序会崩溃,包括在开启相机的时候和拍摄按钮点击的时候都需要做安全验证,验证设别是否支持拍照,用户是否允许程序访问相机。

//        ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];

//        if (author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied){

//            //无权限

//            return ;

//        }

//        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

//        [library writeImageDataToSavedPhotosAlbum:jpegData metadata:(__bridge id)attachments completionBlock:^(NSURL *assetURL, NSError *error) {

//

//        }];

//        

    }];

    

     }


//设置方向,       照片写入相册之前需要进行旋转

-(AVCaptureVideoOrientation )avOrientationForDeviceOrientation:(UIDeviceOrientation)deviceOrientation

     {

         AVCaptureVideoOrientation result = (AVCaptureVideoOrientation)deviceOrientation;

         if ( deviceOrientation ==UIDeviceOrientationLandscapeLeft )

             result = AVCaptureVideoOrientationLandscapeRight;

         elseif ( deviceOrientation ==UIDeviceOrientationLandscapeRight )

             result = AVCaptureVideoOrientationLandscapeLeft;

         return result;

     }


@end





===================================================




这篇关于iOS AVFoundation/AVCaptureSession实现自定义相机界面拍照(四)拍照、自定义裁剪框、图片查看器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1017770

相关文章

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

【Prometheus】PromQL向量匹配实现不同标签的向量数据进行运算

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全栈,前后端开发,小程序开发,人工智能,js逆向,App逆向,网络系统安全,数据分析,Django,fastapi

让树莓派智能语音助手实现定时提醒功能

最初的时候是想直接在rasa 的chatbot上实现,因为rasa本身是带有remindschedule模块的。不过经过一番折腾后,忽然发现,chatbot上实现的定时,语音助手不一定会有响应。因为,我目前语音助手的代码设置了长时间无应答会结束对话,这样一来,chatbot定时提醒的触发就不会被语音助手获悉。那怎么让语音助手也具有定时提醒功能呢? 我最后选择的方法是用threading.Time

Android实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

安卓链接正常显示,ios#符被转义%23导致链接访问404

原因分析: url中含有特殊字符 中文未编码 都有可能导致URL转换失败,所以需要对url编码处理  如下: guard let allowUrl = webUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {return} 后面发现当url中有#号时,会被误伤转义为%23,导致链接无法访问

C#实战|大乐透选号器[6]:实现实时显示已选择的红蓝球数量

哈喽,你好啊,我是雷工。 关于大乐透选号器在前面已经记录了5篇笔记,这是第6篇; 接下来实现实时显示当前选中红球数量,蓝球数量; 以下为练习笔记。 01 效果演示 当选择和取消选择红球或蓝球时,在对应的位置显示实时已选择的红球、蓝球的数量; 02 标签名称 分别设置Label标签名称为:lblRedCount、lblBlueCount

Kubernetes PodSecurityPolicy:PSP能实现的5种主要安全策略

Kubernetes PodSecurityPolicy:PSP能实现的5种主要安全策略 1. 特权模式限制2. 宿主机资源隔离3. 用户和组管理4. 权限提升控制5. SELinux配置 💖The Begin💖点点关注,收藏不迷路💖 Kubernetes的PodSecurityPolicy(PSP)是一个关键的安全特性,它在Pod创建之前实施安全策略,确保P