Start a new topic

Get target image from camera in Unity

Get target image from camera in Unity

1 person has this problem

My mistake. 

I updated the previous post.


Best regards,

Alexandru


Hi, in Unity I want to get camera's feed from target and then process it. What I need is to be able to recognize when the predefined target is in camera's field of view and then crop and distort the part of the feed where the target is and then process the target image for a project I'm working on.
I'll appreciate if you can help with this.

Thanks

Thanks Christiaan. So we have our problem at step 1. I havne't tested this in action with Wikitude, though I have implemented a sample of this in Vuforia using the RegionCapture script. It would be great if we could do this in Wikitude too.
Thanks again very much
Best Regards

Hi, 

The CanvasCameraImage GameObject has a RawImage component that during runtime will reference a texture that contains the camera feed. You should be able to use that. Keep in mind that this behaviour will change in the future, but we will make sure that there will still be a way to access the camera frame.

Best regards,
Alexandru

Hi Alexandru
What I'm trying to achieve here is to do a sample of Coloring book where you capture the target image and then wrap it as a texture to the augmented model.
Do you have any suggestions on how to achieve that with Wikitude?

Thanks

Thanks very much Alexandru
Is there any way to extract and crop the target pixels from this feed ?  What I'm trying to do is 1-get camera feed 2-know when the target is in the field of view of the camera 3-extract and crop the target pixels from that feed 4-de-warp the pixels of the target
I wanted to ask if there are any ways to do this in Wikitude
Thanks very much

Best Regards

Hi, 


Could you please describe what your use case is and how exactly you're trying to achieve that. Perhaps we can find a different solution or workaround.


Thank you,

Alexandru

Hi,


We are using Aruco codes to spawn objects in our scene while the Wikitude tracking is happening. Our first approach after seeing that the wikitudeCamera.CameraTexture wasn't working was to use the WebCamTexture, but that made Wikitude to stop working at all. Then we discovered that the Enable Camera Rendering needed to be enabled and that a Camera had to be attached to the MiraARCamera object for the wikitudeCamera.CameraTexture to work. After doing that, we saw that the format of the Texture2D being recorded by the wikitudeCamera.CameraTexture wasn't allowing us to use Texture2D.GetPixels32() so we used the code from the top of this page posted by Alexandru to get the right format and that made it possible for everything to work together. The only thing that some other people have mentioned on this thread and that I mentioned in my previous post is that the Background Camera is constantly rendering, causing unnecessary workload. My question is if there would be any other way of accessing the camera feed other than the one mentioned or if not, if there would be a way of enabling/disabling the Wikitude tracking altogether so that users choose when to scan Aruco codes and while that is happening, tracking is disabled to lower the workload.


Thank you,

Aniol


Hi,

In the latest version of the Unity Plugin, you can access the camera feed from WikitudeCamera.CameraTexture as a Texture2D. This texture is updated every frame, so if you want a snapshot of it, you will probably want to clone it by using GetPixels32() and then SetPixels32(). If you want to apply any cropping and warping, this would be the place to do it. You can then apply this clone to the Material that the augmented model is using.

Hope this helps, but if you can provide more information about the app, I'll try to provide more info.

Best regards,
Alexandru
Login or Signup to post a comment