ZED Mini Texture2D retrieval issue
Huang0504 opened this issue · 2 comments
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues.
- This issue is not a question, bug report, or anything other than a feature request directly related to this project.
Proposal
Hi,I has a serval question for ZED unity SDK,I want to retrieve the Texture2D of camera,so I check ZEDRenderingPlane.cs and use the TextureEye attribute ,but when I use the getpixel() to read camtexture to other texture2d , it doesnt work,the new texture can not see anything, here is part of code I wrote,when I press space and tmp is correct camera texture but the texture is whole gray texture.
public Texture2D texture;
public Texture2D tmp;
public GameObject frame;//gameobject of ZED Rendering Plane
private void LateUpdate()
{
if (Input.GetKeyDown(KeyCode.Space))
{
tmp = frame.GetComponent<ZEDRenderingPlane>().TextureEye;
texture=ChangeFormat(tmp, TextureFormat.RGBA32);
}
}
public Texture2D ChangeFormat(Texture2D oldTexture, TextureFormat newFormat)
{
//Create new empty Texture
Texture2D newTex = new Texture2D(oldTexture.width,oldTexture.height, newFormat, false);
//Copy old texture pixels into new one
newTex.SetPixels(oldTexture.GetPixels());
//Apply
newTex.Apply();
return newTex;
}
Use-Case
No response
Anything else?
No response
Hi,
I think the issue is coming from the way you are copying the texture to the new one, as you said the "tmp" texture is correct.
You should try using functions like Graphics.CopyTexture() or Graphics.ConvertTexture() instead.
Best,
Benjamin Vallon
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days