【发布时间】:2014-02-13 20:34:42
【问题描述】:
我正在使用 AVCaptureSession 捕获图像,然后将其发送到我的服务器。
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
if (imageSampleBuffer != NULL) {
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
self.videoImageData = [imageData copy];
[self processImage:[UIImage imageWithData:imageData]];
NSString* response=[self uploadImage];
[activityIndicator removeFromSuperview];
self.takePictureBtn.enabled = YES;
[self setUserMessage:response];
}
}];
- (void) processImage:(UIImage *)image
{
...
[UIView beginAnimations:@"rotate" context:nil];
[UIView setAnimationDuration:0.5];
int degrees = [self rotationDegrees];
CGFloat radians =degrees * M_PI / 180.0;
self.captureImageView.transform = CGAffineTransformMakeRotation(radians);
[UIView commitAnimations];
[self.captureImageView setNeedsDisplay];
}
- (NSString*)uploadImage将照片发送到服务器
我期望的行为是在 processImage 终止后,图像将显示在 UIImageView captureImageView 上,活动指示器旋转,但我得到一个白色的白色视图,指示器旋转,并且仅在服务器发布请求之后终止captureImageView 显示图像
如何实现我想要的行为?
另一个问题我面临的问题是我的 imageSampleBuffer 返回了所拍摄图像的镜像(左侧的对象出现在右侧)
【问题讨论】: