如何在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