Hi,
going back to the original question, a couple of ways for extracting a screenshot and/or the Vuforia camera image in Unity are already documented in the Knowledge Base page of the developer guide:
https://developer.vuforia.com/resources/dev-guide/unity-camera-image-access
https://developer.vuforia.com/resources/dev-guide/unity-screenshots
Concerning how to extract a specific sub-portion of the camera image (for instance the part that correspond to the image target rectangle), this can be done at application level by:
- computing the position (in world coordinates) of the 4 corners of the image target (you can do this using the Transform component of each Trackable game object)
- projecting each of the 4 corners above to screen (pixel) coordinates (this can be done using the Unity Camera API, i.e. Camera.WorldToScreenPoint: http://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html)
- use the pixel coordinates to look up into the screenshot texture and extract the relevant portion of pixels out of it and build up your own texture that contains those pixels
Please note that the technique highlithed in points 1,2,3 above relates to general Unity programming and general 2D/3D graphics programming, so, you may also want to search some Forums that discuss advanced 3D programming techniques and Unity programming techniques, as there might also be other ways of achieving this.
Concerning this suggestion:
The better way is if Vuforia created some sort of API/Library to grab the Texture of the Image Target on Runtime and allow us to use it.
The best is probably to post this suggestion in the Forum Wish List, which is periodically reviewed in order to take into consideration the most popular requests from developers:
https://developer.vuforia.com/forum/general-discussion/wish-list
I hope this helps.
hi,I'm doing the 3 steps you mentioned to get the ImageTarget in CameraImage. But after step 2, by using Camera.worldToScreenPoint() function, the corners' coordinates seem not so accurate, and I use these screen(or viewport) coordinates of corners to get the picture from CameraImage,then it's bigger than the actual ImageTarget(that means the actual ImageTarget falls in the picture that I get, just a portion of my picture). and the portion scale is affected by the distance between the camera and the trackable ImageTarget. I don't kwow why ? why ithe screen coordinates are not accurate, and why the Imagetarget portion of picture that I get is varying by the distance?
can you help me?