Unityで開発しています。
教えていただきたいことは、TextureをTexture2Dに高速で変換することです。
現在の方法で毎フレーム変換していると、FPS=10程度になります。
Csharp
1 Texture2D ToTexture2D(Texture _texture){ 2 var sw = _texture.width; 3 var sh = _texture.height; 4 var format = TextureFormat.RGBA32; 5 var result = new Texture2D( sw, sh, format, false ); 6 var currentRT = RenderTexture.active; 7 var rt = new RenderTexture( sw, sh, 32 ); 8 Graphics.Blit( _texture, rt ); 9 RenderTexture.active = rt; 10 var source = new Rect( 0, 0, rt.width, rt.height ); 11 result.ReadPixels( source, 0, 0 ); 12 result.Apply(); 13 RenderTexture.active = currentRT; 14 return result; 15 }
追加
OpenCV for UnityのUtils.textureToTexture2Dを使用してもFPS=10でした。
あなたの回答
tips
プレビュー