Tag: 作物

iOS:在video中裁剪video奇怪的绿线左侧和底侧

– 如何删除video上的绿线 当在此时裁剪2或3次video时,在video中显示绿色或混合绿色 – 红色闪烁线,在video中左边或底部或左右两侧。 video裁剪方法。 -(void)cropButton { CGRect cropFrame = self.cropView.croppedImageFrame; //load our movie Asset AVAsset *asset; asset = [AVAsset assetWithURL:[NSURL fileURLWithPath:[self.videoDataArr objectAtIndex:self.selectedIndex-1]]]; //create an avassetrack with our asset AVAssetTrack *clipVideoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; //create a video composition and preset some settings AVMutableVideoComposition* videoComposition = [AVMutableVideoComposition videoComposition]; videoComposition.frameDuration = CMTimeMake(1, 30); //create a […]

根据UIScrollView中的视口剪裁UIImage

我在UIScrollView里有一个UIImageView(用Aspect Fill初始化)。 用户将使用它来调整和定位一个UIImage到他的喜欢,按一个button,然后确切地说,他在屏幕上看到的将被发送到服务器,只在原来的图像坐标。 换句话说,生成的图像会比屏幕上的图像大。 以下是我的代码到目前为止的主要部分: // select the original CGFloat imageRatio = self.imageView.image.size.width / self.imageView.image.size.height; CGFloat viewRatio = self.imageView.frame.size.width / self.imageView.frame.size.height; CGFloat scale; // get the scale factor of the image being "aspect-filled" if(imageRatio < viewRatio) { scale = self.imageView.image.size.width / self.imageView.frame.size.width; } else { scale = self.imageView.image.size.height / self.imageView.frame.size.height; } // get the cropping […]

在scrollView中的ImageView中裁剪放大的图像

我已经从我的身边做了很多努力。 最后我需要帮助。 谢谢 目标:1)我如何适应ScrollView里面的imageView 2)我如何裁剪内部scrollView缩放图像。 我有一个imageView里面的滚动视图。 我想缩放后显示滚动视图边界内的裁剪图像。 我已经裁剪了图像,但它不完全一样,我想要的。 在这里,我设置backgroundColor黑色到我的scrollView。 而当我把imageView放在里面时,它不适合。 滚动视图内缩放图像后 和作物图像后 我的代码在这里: – (void)viewDidLoad { [super viewDidLoad]; CGRect frame1 = CGRectMake(50,50,200,200); CGRect frame2 = CGRectMake(50,50,200,200); imageView1=[[UIImageView alloc]initWithFrame:frame1]; imageView1.image= [UIImage imageNamed:@"back.jpeg"]; imageView1.backgroundColor=[UIColor brownColor]; imageView1.contentMode = UIViewContentModeScaleAspectFit; scroll=[[UIScrollView alloc]initWithFrame:frame2]; scroll.backgroundColor=[UIColor blackColor]; [scroll addSubview:imageView1]; scroll.delegate=self; [self.view addSubview:scroll]; [self setContentSizeForScrollView]; self.imageView1.userInteractionEnabled = YES; } 设置滚动视图contentSize -(void)setContentSizeForScrollView { // […]

iOS:从叠加的UIImagePickerController相机中截取静止图像

我是iOS的新手,在过去的一周中,我一直在抨击这个问题,在网上寻找教程,例如: 处理Exif图像 , 调整图像大小 ,以及在StackOverflow上更多的随机问题。 从这些,我认为>=iOS 4.0 ,所有从相机拍摄的图像包含基于EXIF的旋转信息。 什么是不工作的:在尝试不同的图像裁剪技术后,我最终都是在一些随机的angular落裁剪图像,而且最终的图像似乎放大:(当我使用从互联网上的png图像不包含EXIF数据),裁剪正在工作,我的意思是,随机的angular落 – 图像最终在右上angular/左上angular裁剪,放大。 我正在努力实现的是: 我正在尝试从顶部100 px和底部100 px的图像。 本质上,我使用两个覆盖条 – 顶部1和底部1与CGRect(0.0, 0.0, SCREEN_WIDTH, 100.0) [一个100.0 px高长条在顶部]和另一个CGRect(0.0, SCREEN_HEIGHT – 100, SCREEN_WIDTH, 100.0) [在底部的另一个CGRect(0.0, SCREEN_HEIGHT – 100, SCREEN_WIDTH, 100.0)高的条带]。 我需要得到这两个带之间的图像:我假设图像的高度是: SCREEN_HEIGHT – 200.0 。 用overlay显示UIImagePickerController相机: //SCREEN_HEIGHT = 480 and SCREEN_WIDTH = 320 UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] […]

iPhone以编程方式裁剪正方形图像以显示为圆形

我正在尝试使用iPhone上的相机胶卷的图像来创build自定义样式的UIButton图像。 该button具有圆形背景,并有效地显示为一个圆圈。 现在我需要一个图像在button的中间,也出现一轮。 如何在圆形区域之外切割方形UIImage以显示透明度? 如果涉及到遮罩,我需要预先渲染一个蒙版还是可以通过编程创build一个(例如:一个圆圈)? 谢谢!

iOS实时确定名片的angular落

我想要实现一个名片检测function像这个应用程序( https://scanbot.io )。 照相机应检测名片并自动拍照(仅限名片)。 我的想法是使用BradLarson's GPUImage库,检测angular落(使用哈里斯angular点检测algorithm),计算矩形的最大矩形,裁剪包含在矩形内的图像。 这是我的代码: – (void)setupFilter { videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; filter = [[GPUImageHarrisCornerDetectionFilter alloc] init]; [(GPUImageHarrisCornerDetectionFilter *)filter setThreshold:0.01f]; [(GPUImageHarrisCornerDetectionFilter *)filter setSensitivity:0.5f]; [(GPUImageHarrisCornerDetectionFilter *)filter setBlurRadiusInPixels:2.0f]; [videoCamera addTarget:filter]; videoCamera.runBenchmark = YES; GPUImageView *filterview = [[GPUImageView alloc] init]; self.view=filterview; GPUImageCrosshairGenerator *crosshairGenerator = [[GPUImageCrosshairGenerator alloc] init]; crosshairGenerator.crosshairWidth = 22.0; [crosshairGenerator forceProcessingAtSize:CGSizeMake(480.0, 640.0)]; [(GPUImageHarrisCornerDetectionFilter […]

如何在iOS中将video裁剪成圈?

我正在尝试在iOS中将已拍摄的video剪裁成圆形。 我该如何去做这件事。 我知道如何做AVCaptureSession,但我不知道作为一个AVCaptureDevice传递已经拍摄的video? 有没有办法将video剪裁成圆形。 我想叠加在另一个video的顶部,所以它也必须有一个透明的背景。 谢谢。

在Swift中裁剪UIImage的问题

我正在编写一个应用程序,它会拍摄一张图像,然后剪出除了图像中心的一个矩形之外的所有东西。 (SWIFT)我不能让裁剪function工作。 这是我现在所拥有的: func cropImageToBars(image: UIImage) -> UIImage { let crop = CGRectMake(0, 200, image.size.width, 50) let cgImage = CGImageCreateWithImageInRect(image.CGImage, crop) let result: UIImage = UIImage(CGImage: cgImage!, scale: 0, orientation: image.imageOrientation) UIImageWriteToSavedPhotosAlbum(result, self, nil, nil) return result } 我看了很多不同的指南,但没有一个似乎为我工作。 有时图像旋转了90度,我不知道为什么这样做。

Swift:裁剪和导出video

我想裁剪一个video,但我做不到。 我把这个代码转换成了swift,但是在导出video后我只能看到黑屏 var videoComposition: AVMutableVideoComposition = AVMutableVideoComposition() videoComposition.frameDuration = CMTimeMake(1, 60) videoComposition.renderSize = CGSizeMake(clipVideoTrack.naturalSize.height, clipVideoTrack.naturalSize.height) var instruction: AVMutableVideoCompositionInstruction = AVMutableVideoCompositionInstruction() instruction.timeRange = CMTimeRangeMake(kCMTimeZero, CMTimeMakeWithSeconds(60, 30)) var transformer: AVMutableVideoCompositionLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: clipVideoTrack) var t1: CGAffineTransform = CGAffineTransformMakeTranslation(clipVideoTrack.naturalSize.height, 0) var t2: CGAffineTransform = CGAffineTransformRotate(t1, CGFloat(M_PI_2)) var finalTransform: CGAffineTransform = t2 transformer.setTransform(finalTransform, atTime: kCMTimeZero) instruction.layerInstructions = NSArray(object: transformer) […]

裁剪UIImage中心广场

我得到1920×1080分辨率的图像。 我正试图将它们收割到中心广场区域(即中心的1080×1080平方米)。 决议可能会在未来改变。 这样可以裁剪图像吗? 我已经尝试了几个东西张贴在上,但我总是得到一个图像,如果我尝试裁剪然后中心是660×1080。 这是一幅描绘我想要实现的图像。 基本上红色是原始的,绿色是我想要的,而黄色只是显示mixX和midY线。 我试过的代码 func imageByCroppingImage(image: UIImage, toSize size: CGSize) -> UIImage{ let newCropWidth: CGFloat? let newCropHeight: CGFloat? if image.size.width < image.size.height { if image.size.width < size.width { newCropWidth = size.width } else { newCropWidth = image.size.width } newCropHeight = (newCropWidth! * size.height) / size.width } else { if image.size.height < […]