Hi, is it possible to use Unitys WebcamTexture with Sentis? I tried to convert it to a Texture2D, or use the WebcamTexture directly, but I’ll always get the following errors:
- Given input shape: (1, 3, 720, 1280) has different dimension from model input shape: (1, 3, 416, 416) for input: input.1 at axis: 2
- Given input shape: (1, 3, 720, 1280) has different dimension from model input shape: (1, 3, 416, 416) for input: input.1 at axis: 3
- AssertionException: ValueError: reshaped length does not match with input length
Assertion failure. Value was False
I tried to follow the TextureToTensor samples, but
My code for converting the WebcamTexture to Texture2D looks like this:
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
// convert webcamtexture to texture2D
cameraTexture2D = Texture2D.CreateExternalTexture(webcamTexture.width, webcamTexture.height,
TextureFormat.RGB24, false, false, webcamTexture.GetNativeTexturePtr());
using TensorFloat tensorRGB = TextureConverter.ToTensor(cameraTexture2D, channels: 3);
worker.Execute(tensorRGB);
// Get the result
using TensorFloat outputTensor = worker.PeekOutput() as TensorFloat;
// Create a tensor operation to divide the output values by 255, to remap to the (0-1) color range
Ops ops = WorkerFactory.CreateOps(BackendType.GPUCompute, new TensorCachingAllocator());
TensorFloat tensorScaled = ops.Div(outputTensor, 255f);
// Copy the rescaled tensor to the screen as a texture
TextureConverter.RenderToScreen(tensorScaled);
}
br,
Max