Log in or register to post comments

Region Capture

June 22, 2015 - 4:36pm #1
Developers often ask - how to extract the marker from video, how to make an application to be able to paint on the model.. and so on.
– I made a simple script that cut out the region of the marker from the video-background and eliminates perspective distortion.
So you get a rectangular image of marker from any angle.
 
All scripts are packed into the unitypackage.
AttachmentSize
Binary Data bytes

Region Capture

October 9, 2019 - 1:09pm #367

Hello everyone. New version 2.2.0 (beta) on GitHub

Regards, Maxim Rouf

Region Capture

October 4, 2019 - 5:33am #366

nadzim96 wrote:

klelvin wrote:

Hi All, 

Been following this thread for the last couple of weeks, but I'm a bit confused on which issues have been resolved.

The only issue I'm having (after some work) is that the region that is captured is displaying offset on the model - only on Android.  Works fine in the game editor window and on iOS.

- Unity 2019 - Vuforia 8.3.8.

If this has been resolved, could someone please let me know - as I can't seem to find it in this thread for certain, if it hasn't that's OK but I just need to know for sure before I report back to the people who built us an app using older versions about why we can't upgrade.

Thanks

Owen

 

Hello all, 

Same with klelvin, im also facing the same problem. Could someone please let me know whether there is any update on how to fix this problem. Here is the image on this issue.

 

Thank you

 

I have same issue. can someone help now?

Region Capture - Fix?

September 24, 2019 - 8:09pm #365

Hi there, we are running into the same issue and I was wondering if you ever found a fix or work around? If so, I would really appreciate some support. If it is a bigger undertaking, I'd be happy to pay you for your time. 

 

Thanks!

Region Capture

August 8, 2019 - 6:50am #364

We had the same issue and had to use an older version of vuforia, however, due to new requirements from Google for 64 bit builds, we had to update Vuforia and the coloring plugin stopped working on the new Vuforia. We haven't figured it out as to why it only effects Android in the new version of Vuforia and we've been picking away at it to figure out the difference. Unfortunately, the plugin is not officially support by Vuforia and the guy who made it did so in his free time, so we may never see an update from him again on it. 

Region Capture

August 7, 2019 - 7:24pm #363

klelvin wrote:

Hi All, 

Been following this thread for the last couple of weeks, but I'm a bit confused on which issues have been resolved.

The only issue I'm having (after some work) is that the region that is captured is displaying offset on the model - only on Android.  Works fine in the game editor window and on iOS.

- Unity 2019 - Vuforia 8.3.8.

If this has been resolved, could someone please let me know - as I can't seem to find it in this thread for certain, if it hasn't that's OK but I just need to know for sure before I report back to the people who built us an app using older versions about why we can't upgrade.

Thanks

Owen

 

Hello all, 

Same with klelvin, im also facing the same problem. Could someone please let me know whether there is any update on how to fix this problem. Here is the image on this issue.

 

Thank you

Region Capture

July 22, 2019 - 4:02am #362

Hi All, 

Been following this thread for the last couple of weeks, but I'm a bit confused on which issues have been resolved.

The only issue I'm having (after some work) is that the region that is captured is displaying offset on the model - only on Android.  Works fine in the game editor window and on iOS.

- Unity 2019 - Vuforia 8.3.8.

If this has been resolved, could someone please let me know - as I can't seem to find it in this thread for certain, if it hasn't that's OK but I just need to know for sure before I report back to the people who built us an app using older versions about why we can't upgrade.

Thanks

Owen

Region Capture

July 12, 2019 - 6:21am #361

kpprt wrote:

There's another bug on Android caused by the VideoBackgroundTexure reference in Region_Capture.

To reproduce: on Android do the following:

  1. Start your App, initialize Vuforia
  2. Scan one of your image targets with Region_Capture
  3. Pause the App, e.g. by clicking the app overview button
  4. Resume the App by clicking on it in the app overview

Result: the background video texture freezes

Expected: the background video texture doesn't freeze and continues to show the camera image

Solution/Workaround:

Since we don't need the VideoBackgroundTexure reference any more when using the SharedMaterial directly (like described in the previous posts), make sure to comment out all occurences of VideoBackgroundTexure in RegionCapture.cs and RegionCaptureEditor.cs.

Cheers,

Chris

Hello,

Your approach didn`t work for me. I use Unity 2018.4.3 Vuforia 8.1.10

I delete all reference VideoBackgroundTexure. Do you know any solutions?

Region Capture

July 11, 2019 - 3:07pm #360

There's another bug on Android caused by the VideoBackgroundTexure reference in Region_Capture.

To reproduce: on Android do the following:

  1. Start your App, initialize Vuforia
  2. Scan one of your image targets with Region_Capture
  3. Pause the App, e.g. by clicking the app overview button
  4. Resume the App by clicking on it in the app overview

Result: the background video texture freezes

Expected: the background video texture doesn't freeze and continues to show the camera image

Solution/Workaround:

Since we don't need the VideoBackgroundTexure reference any more when using the SharedMaterial directly (like described in the previous posts), make sure to comment out all occurences of VideoBackgroundTexure in RegionCapture.cs and RegionCaptureEditor.cs.

Cheers,

Chris

Region Capture

June 11, 2019 - 7:25pm #359

I hope they update or fix all bug on region capture for vuforia 8.1 

Region Capture

June 7, 2019 - 2:58am #358

Hi guys.

1. Thank you all for your help.

2. For the new Vuforia 8. * you need to use: a) VideoBackground material instead of texture, as in the response of Rilissimo. b) use Renderer.sharedMaterial instead of Renderer.material to fix the problem with backgroundImage hanging on Android.

3. I refactored the source Region Capture plugin, but basically, everything is fine.

Region Capture

June 6, 2019 - 6:19am #357

Quote:

This is done with Shader.EnableKeyword to set the keyword globally for the whole shader and with Material.EnableKeyword to set the keyword for the material only. The hard part is to find out what keywords to use. I couldn't find any function in the Vuforia API to obtain that information, but you could use Material.shaderKeywords on the VideoBackground Material to get the right shader keywords.





Do not do this if you plan on starting/stopping vuforia

https://developer.vuforia.com/forum/unity/bug-accessing-background-plane-texture-bug

 

And workaround

https://developer.vuforia.com/forum/unity/suggested-workaround-when-accessing-unity-materials-interferes-background-texture-updates



There is a way to get the PIXEL_FORMAT but I can't remember how I did it (and have since scrapped that solution because of the bug above so I can't find it now)

It should have something to do with how you setup the camera, but I could be wrong.



Edit: for search purposes PIXEL_FORMAT is an enum found in the Vuforia.Image class, the first thing that comes up in a web search is here

https://library.vuforia.com/content/vuforia-library/en/articles/Solution/How-To-Migrate-a-Unity-Project.html



Search for pixel_format in there, it might give you a clue

Region Capture

June 6, 2019 - 1:57am #356

Rilissimo wrote:

you can actually use the same shader that is used for the video background from vuforia, you just need to set the keywords for the shader from code based on an enumeration from vuforia that tells you which texture format is being used.

Thanks Rilissimo, that info finally helped me to understand the issue and find a solution!

For all others, I will try to explain it a little more in depth:

What changed in the new Vuforia versions is that the camera feed can have diferrent Pixel Formats. I think before it was RGB only and now it could also be YUV in different variations on some devices. I experienced YUV being used on most Android devices and RGB being used on iOS and on my Mac Editor (maybe due to Metal?). So I had the Red Texture Problem only on Android devices.

YUV stores luminance information in the Y channel and chrominance information in the U and V channels. As Rilissimo stated we can have a look at the Vuforia VideoBackground Shader to see how this is implemented.

The first big change is that the Shader is using two Textures now: _MainTex and _UVTex.

[NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
[NoScaleOffset] _UVTex("UV Texture", 2D) = "white" {}

_MainTex will contain the RGB information when the RGB Pixel Format is used. When the YUV Pixel Format is used, the _MainTex will contain only the Y channel and the second Texure _UVTex will contain the chrominance UV channels.

half2 uv = tex2D(_UVTex, i.uv2).rg;
float y = tex2D(_MainTex, i.uv).r;

As you can see the data is always stored in the first channels: Y in the red channel of _MainTex and UV in red and green in the _UVTex. This is also the explanation for the Red Texture Problem. Since Region_Capture is not updated yet it is only using one RGB texture in the RC_Simple_Color Shader. By default Region_Capture copies the color information from the BackgroundPlane, but when YUV is in use, the VideoBackground Shader will only store the luminance information in the red channel of the _MainTex. So only the luminance in the red channel is being copied to Region_Capture causing the Red Texture Problem.

The easiest solution is to skip the RC_Simple_Color Shader, which doesn't support the second UV Texture, yet. I don't see any reason why there is a need for a separate shader when we already have the VideoBackground Shader doing the color conversion work for us. We can simply take the VideoBackground Material and assign that to Region_Capture as Rilissimo already noted. You will find that solution in the TL;DR section below.

If you would want to keep the old RC_Simple_Color Shader and adjust it to support YUV, you would need to add the second _UVTex Texture as well as the different color conversion versions for YUV. Also, when using the adjusted shader, you would need to set the right ShaderKeywords to tell the shader / material which color conversion to use. Rilissimo already noted that as well. This is done with Shader.EnableKeyword to set the keyword globally for the whole shader and with Material.EnableKeyword to set the keyword for the material only. The hard part is to find out what keywords to use. I couldn't find any function in the Vuforia API to obtain that information, but you could use Material.shaderKeywords on the VideoBackground Material to get the right shader keywords.

TL;DR

In RegionCapture.cs replace line 83:

GetComponent<MeshRenderer>().material.mainTexture = VideoBackgroundTexure;

with:

GetComponent<MeshRenderer>().material = BackgroundPlane.GetComponent<MeshRenderer>().material;

I hope this helps some of you guys. Let me know if there are any issues with this solution. I won't promise to fix anything, but I'd like to know of course. ;)

And thanks again to Rilissimo!

Cheers,

Chris

AttachmentSize
Image icon Screenshot 2019-06-05 at 18.42.42.png177.15 KB

Region Capture

June 3, 2019 - 1:01am #355

you can actually use the same shader that is used for the video background from vuforia, you just need to set the keywords for the shader from code based on an enumeration from vuforia that tells you which texture format is being used.



I don't remember how to do it because I rolled back to a previous vuforia version, and now that we upgraded again I opted for another less optimized solution, basically rerendering the background plane on a different camera since accessing the real background plane properties will bug vuforia.

 

 

Region Capture

June 3, 2019 - 12:56am #354

Well then those developers need to adapt or perish, if you want someone else to do your work for free look somewhere else.

I have already said enough on how to fix the issue, the rest is up to you all.

Region Capture

June 2, 2019 - 6:23pm #353

Rilissimo wrote:

Guys please read the answers below, I have already answered this, the textures are red  because RegionCapture assumes the texture is in RGB format, and this was true for the video background before vuforia 8, now you have to convert from YUV to RGB in the region capture shaders, use the VideoBackground shader from vuforia as an example on how to convert the values.

 

what name of shaders in the region capture ? 

because there is 4 shaders in Region_Capture folder

RC_ImageTarget_Dept_Sort, RC_MipMap_Blurred, RC_Simple_Color and RC_Transparent_Outer_Bounds

 

Region Capture

May 31, 2019 - 11:28pm #352

And yet, your answer is useless as most developers aren't familiar with shaders and how stuff converts there.

Region Capture

May 31, 2019 - 12:43am #351

Guys please read the answers below, I have already answered this, the textures are red  because RegionCapture assumes the texture is in RGB format, and this was true for the video background before vuforia 8, now you have to convert from YUV to RGB in the region capture shaders, use the VideoBackground shader from vuforia as an example on how to convert the values.

Region Capture

May 29, 2019 - 8:44am #350

I'm still having the same issue. Red Textures on Android with Vuforia 8.1.11 and Unity 2018.4.0.

It might have something to do with the OpenGL rendering on Android and textures being treated differently, but I couldn't figure out a solution yet.

I tried to access the background texture directly via VuforiaRenderer.VideoBackgroundTexture and give it to RegionCapture, but could net get it to work.

Does anyone have a clue or example how to obtain that Texture? I assume this will also be a red texture and therefore it would definitely be a Vuforia bug.

Region Capture

May 22, 2019 - 11:45pm #349

HI

i have some problem, i get textures from RenderTextureCamera are rendered "reddish", anyone know how to fixed this issue?

in this case i using vuforia 8.1.10 and unity 2018.3.14 for android platform.

here the step :

- After add ARcamera and import vuforia,

- setting xr for vuforia,

- add Capture_Region layer,

- swith to android,

- and import capture region package, and then try sample(get texture) and build to apk file



here the result (attach)...i get textures  rendered "reddish" from RenderTextureCamera. 

note: why video videobackground is small , because  videobackground in ARcamera is disable

AttachmentSize
Image icon sample.png595.27 KB

Region Capture

May 6, 2019 - 2:50pm #348

I'm using 8.1.10 and the issue was in that version.

Region Capture

May 5, 2019 - 11:50pm #347

What you are describing happens only in 8.0.10, then fixed in 8.1.7



But something else broke in 8.1.7 (https://developer.vuforia.com/forum/unity/bug-accessing-background-plane-texture-bug)



My advice is to just stick with 7.5.26 until we get a more stable release

Region Capture

May 2, 2019 - 5:14pm #346

So I'm dealing with the same issue and it seems from examining the BackgroundPlane video texture and the material on the Region_Capture that the video texture is inset with large areas of black on the top and on the right. As a temporary measure I set up a secondary Region Capture that takes the un-uv mapped texture and renders that to a texture, and then crop the resulting texture excluding the, what seems to me, consistent black areas, and then rather than having the video texture applied to the main region capture I'm applying the cropped texture to that mesh. I'm sure there's a better way to do this to figure out why Android is adding black areas to the video texture when applied to a mesh but I haven't been able to figure it out. Unity 2019/Vuforia8.10/Region Capture latest.

Incorrect texture position on Android

April 27, 2019 - 8:29am #345

Thanks maximrouf for a great plugin.  Are there any planned fixes for the Android shift in the latest version?

  • .2.0a13
  • Vuforia 8.0.10
  • RegionCapture - latest

Region Capture

April 25, 2019 - 3:38am #344

Doesn't anyone try vuforia version 8.0.10? I just try it and region capture still not working in android

Doesn't anyone find out how to fix region capture yet? i really need this to finish my project, please help!!!

Region Capture

April 23, 2019 - 12:39am #343

Ok enough people asked me in messages to post the solution here so now I feel bad for not sharing, damn you all.

 

Short story, you need to convert the background plane texture format to the appropriate one based on the platform it is running on.

 

Easiest way is to use the background plane shader to render the region capture mesh (or you can use the conversion maths in there to edit your currently used shaders)

after this you'll still have to set the correct shader keywords, https://docs.unity3d.com/ScriptReference/Shader.EnableKeyword.html



in the latest vuforia version notes it tells you how to check what texture format vuforia is currently using.

 

After this you should all be set, hoping i didn't miss anything since I don't have the solution at hand right now, I had to revert the whole project to the previous version of unity and vuforia because they totally messed up the background plane texture acquisition. it works fine if you access it once in the whole lifetime of your app, but if you start and stop vuforia after accessing it it won't work anymore.

Region Capture

April 12, 2019 - 5:20am #342

I found a fix

And I was writing about my journey to fix this.

But someone deleted my post, so good luck all.

Region Capture

April 10, 2019 - 3:39am #341

michalSBIT wrote:

Hello,

 

after upgrade to Unity 2018.3 and Vuforia 8.1.7 RC textures from RenderTextureCamera are rendered "reddish". Screenshot attached. It's standard white paper with black ink print on it.

It occurs only on mobile devices (both Android and iOS), no problem when trying out in Untiy Editor. Had no troubles using older vuforia and Unity 2017.

 

Anyone facing similar problems?

Hello,

I am having the same issues with a red texture on Android (LG G4), but not on iOS (iPhone 6) and not in the Editor.

What I found out so far is that the following line is where the 'magic' happens:

Line 71 RegionCapture.cs:

VideoBackgroundTexure = BackgroundPlane.GetComponent<MeshRenderer>().material.mainTexture;

The Texture of the BackgroundPlane (containing the video feed) is shown correctly as background video, but when assigned / referenced to another Material it turns red. Does anyone have a clue why this might happen? An unsupported color format of the texture maybe? And if so, can it be converted?

The only possible solution I can imagine right now is not to use the BackgroundPlane texture in the RegionCapture script and instead reference our own WebCamTexture, but I have not tested that yet.

Also, even when the Video Background in the VuforiaConfiguration is disabled, a BackgroundPlane with the camera feed is attached to the ARCamera (just not fullscreen in the Editor) and the Video Background is still visible. Seems like a bug to me.

Region Capture

April 10, 2019 - 1:44am #340

I apologize. I only asked because I saw some relevant references on older posts.

Anyway, on a Vuforia question, does the "freeze" feature works well on everyone? Changing the bool value on the "Freeze Enable" variable doesn't seem to make any difference on Unity 2018 with the latest Vuforia version.

Region Capture

April 5, 2019 - 9:02am #339

Hello @vufer1980,

A friendly reminder that this is a support community for the Vuforia Engine SDK, Unity Extension, associated tools and sample applications.

I suggest you refer your experiences and questions for EasyAR to their forum: https://forum.easyar.com/portal.php?mod=list&catid=1

Thanks,

Vuforia Engine Support

Region Capture

April 3, 2019 - 6:44am #338

Did anyone manage to get this to work with EasyAR in android?

I've tried using the "modified" unitypackage especially for EasyAR and put the RenderCamera with the RealityPlane in the appropriate slots but as soon as I compile and run to my android device I get a black background (not the camera feed) and the AR object appears without the camera capture material, just the material I have applied inside the Unity Editor.

I used Unity 2018.2.15.f1 and RegionCapture2.0.6_EasyAR.

 

For what it's worth it works kinda ok in the Editor since I understood I had to modify the marked parts in the RegionCapture.cs

Region Capture

April 2, 2019 - 5:31am #337

I also have similar problem in unity 2018.3 .. :(



maybe anyone have solution?

 

Region Capture

March 27, 2019 - 4:24am #336

Hello,

 

after upgrade to Unity 2018.3 and Vuforia 8.1.7 RC textures from RenderTextureCamera are rendered "reddish". Screenshot attached. It's standard white paper with black ink print on it.

It occurs only on mobile devices (both Android and iOS), no problem when trying out in Untiy Editor. Had no troubles using older vuforia and Unity 2017.

 

Anyone facing similar problems?

AttachmentSize
Image icon Screenshot_20190327-122032.jpg48.74 KB

Region Capture

March 7, 2019 - 11:38am #335

Hello @pmullins3,

Can you confirm that you're issue is similar to this one?: https://developer.vuforia.com/forum/issues-and-bugs/vuforia-upgrade-installer-breaks-support-users

Thanks,

Vuforia Engine Support

Region Capture

March 7, 2019 - 4:02am #334

Hi,

I'm having trouble updating unity to version 8.0.10 - the installer just seems to remove all reference of Vuforia from the editor.

Anyone had the same problem? I'm using unity 2018.2.21f1 via unity hub.

 

Any help would be much appreciated!

 

Thanks.

Region Capture

March 7, 2019 - 3:09am #333

Same issue here..! Does someone fixed this??

Unity 2018.3.6f1 / Vuforia 8.0.10 / Region Capture 2.0.9

Region Capture

March 2, 2019 - 9:27pm #332

How did you manage to implement it in ARToolKit? Any instructions or source code perhaps? Thanks!

Region Capture

February 26, 2019 - 10:27pm #331

Same issue. RegionCapture is not wrapping on 3D objects properly

Unity 2018.3.6f1, Vuforia 8.0.10, Region Capture 2.0.9

But wraps properly on Unity 2018.2.20f1, Vuforia 6.2-10, Region Capture 1.8.0

AttachmentSize
Image icon Untitled.png324.03 KB

Region Capture

February 17, 2019 - 9:05pm #330

This android problem is really frustrating :( 



Hope someone psots a fix for it here soon. Still not working.

Region Capture

February 13, 2019 - 11:07am #329

Same issue here, working in editor but not in android device, any workaround?

Region Capture

February 13, 2019 - 7:00am #328

Same issue with region capture not working with Android.

Unity 2018.2.5f1, Vuforia 8.0.10, Region Capture 2.0.9



Works on iOS and in Unity Editor, just not on Android devices.

Region capture no longer wrapping on 3D object correctly. (worked fine in earlier version of Unity and Vuforia)

Region Capture

February 12, 2019 - 11:06pm #327

Please fix this bug : " Vuforia "8.0.10". The AR coloring (REGION CAPTURE, GET-TEXTURE) works in editor but not in android.

Region Capture

February 12, 2019 - 2:19am #326

I have same issue :(

Region Capture

January 19, 2019 - 10:45pm #325

Hi Maximrouf,



I adopted "Region_Capture" before and it works great.

https://github.com/maximrouf/RegionCapture.

But after i update my unity "2018.3.1" and vuforia "8.0.10". The AR coloring now works in editor but not in android. 

Could you please suggest how to solve it. Many many thanks. I am in urgent.

Region Capture

December 10, 2018 - 9:06am #324

Hi maximrouf,

First of all, I would like to thank you for this amazing plugin !

BTW, I'm currently working on porting an app on Universal Windows Platform. Everything works find in Unity Editor, but not when I build as an appx, RegionCapture seems to return an empty texture.

 

Here is my configuration :

Unity version : 2018.2.6f1 (64bit)

Vuforia version : 7.2.23

RegionCapture version : 

Device name : MSI GS65

Device OS version : Windows 10 Pro

Orientation of the device : Landscape

 

Thanks !

Region Capture

December 3, 2018 - 3:49am #323

Hello all,

I can run Region Capture, but the problem is Live Texuturing is not working properly. If I try to color the 3d model at bottom it colors slightly up from there. And also if I try to color at the top it colors bottom of the 3d model.

 

Please help as soon as possible. As I'm trying since so many days still not getting any solution.

 

Thanks in advance.

Region Capture

November 23, 2018 - 3:06am #322

Hello maximrouf,

Your plugin is great as it looks.

But unfortunately live coloring is not working for me.

I'm using Unity 2018.2.1f1, Vuforia 7.5.20 and Region Capture 2.0.9.

I'm running it on iPhone 7 and iOS 12.1.

 

Want a help on this...

 

Thanks in advance if anyone could help.

Region Capture

November 18, 2018 - 11:17pm #321

Hi! Does this work with multiple image targets including ones that don't need region capture? It seems camera world center mode is defined by the first image... 

How to auto stop capturing on first tracking Found

October 13, 2018 - 3:13pm #320

Hi @maximrouf,

 

I tried to edit the script for auto stop capturing after first tracking found,

I want to disable "Stop Capturing" button and change the trigger to script but it doesn't success.

Any example for that?

 

Thanks 

AttachmentSize
Image icon Screen Shot 2018-10-14 at 05.02.08.png303.82 KB

Region Capture

October 9, 2018 - 8:23am #319

I fixed the issue by updating Unity and Vuforia.

Unity 2018.211f1 with Region Capture v2.0.9 and Vuforia V7.2.23

Best regards

 

Region Capture

October 3, 2018 - 12:34am #318

Hi @maximrouf,

 

I'm using Unity 2018.2.2f with Region Capture v2.0.9 and Vuforia V7.1.35

I encountered an issue on iOS where the render camera seems to stop capturing after flipping the camera via Vuforia API:

        CameraDevice.Instance.Stop();

        CameraDevice.Instance.Deinit();

        bool result = CameraDevice.Instance.Init(newDirection);

        CameraDevice.Instance.Start();

        Debug.Log((result) ? "Successfully changed" : "Failed to change cam");

        VuforiaUnity.OnPause();

        VuforiaUnity.OnResume();

        return result;

Here are the steps:

1. Start camera (Default = back camera)

2. Scan image target, model appears with the region mapped as texture correctly.

3. Flip the camera (now = front camera)

4. Flip the camera again (now = back camera)

5. Scan image target, notice that the model appears to have a distorted texture.

 

In step 6, the texture that seems to be mapped is the last camera frame captured before the first camera flip happens. 

Any help will be appreciated.

 

Thanks.

Log in or register to post comments