如何在iOS 7中使用蓝牙或WiFi将摄像机馈送从一台iOS设备有效传输到另一台设备。以下是获取蒸汽缓冲液的代码。如何使用多点对等连接将摄像头从一台iOS设备传输到另一台设备
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
// Create a UIImage from the sample buffer data
UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
}
// Create a UIImage from sample buffer data
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer
{
// Get a CMSampleBuffer's Core Video image buffer for the media data
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// Lock the base address of the pixel buffer
CVPixelBufferLockBaseAddress(imageBuffer, 0);
// Get the number of bytes per row for the pixel buffer
void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer);
// Get the number of bytes per row for the pixel buffer
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
// Get the pixel buffer width and height
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
// Create a device-dependent RGB color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// Create a bitmap graphics context with the sample buffer data
CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8,
bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
// Create a Quartz image from the pixel data in the bitmap graphics context
CGImageRef quartzImage = CGBitmapContextCreateImage(context);
// Unlock the pixel buffer
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
// Free up the context and color space
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
// Create an image object from the Quartz image
UIImage *image = [UIImage imageWithCGImage:quartzImage];
// Release the Quartz image
CGImageRelease(quartzImage);
return (image);
}
这里我们可以得到iOS摄像头捕获的图像。
我们可以将样品缓冲区信息直接发送到使用多个对等设备的其他设备,还是有任何有效的方法将数据传送到其他iOS设备?
谢谢。
多路连接听起来像是一个有效的选择。但是你需要检查性能。发送未压缩的图像可能需要太多带宽,因此您可能必须创建一个真正的视频流才能传输实时捕获。 – allprog 2014-09-15 11:18:56
编辑必须是6个字符,所以除非我们拿出填充,这篇文章将永远蒸汽饲料 – 2015-08-18 19:08:21
好问题Sandipbhai,Upvoted .. – NSPratik 2016-01-12 13:37:25