2013-06-24 49 views

回答

0

正如你所說的EncodeToPNG上的性能太慢了,你需要做的是在攝像頭源從iOS(objc)發送到Unity的WebCamTexture之前掛鉤到代碼中。

我們使用了一種類似的技術,使用一個名爲CameraCaptureKit的插件(https://www.assetstore.unity3d.com/en/#!/content/56673)來凍結髮送給Unity的圖像,同時等待Flash和防抖開啓。

在Unity生成的xcode項目中,您可以打開CameraCapture.mm並找到該函數。

- (void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection 

然後,您可以通過修改此代碼來修改發送到Unity的WebCamTexture的圖像。 UnityDidCaptureVideoFrame是您想插入的代碼。

intptr_t tex = (intptr_t)CMVideoSampling_SampleBuffer(&self->_cmVideoSampling, sampleBuffer, &self->_width, &self->_height); 
UnityDidCaptureVideoFrame(tex, self->_userData); 

乾杯

相關問題