Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by hellei92 · Oct 10, 2014 at 11:57 AM · rendertextureandroidpluginnative pluginwebcam

Reading Native Surface Texture into Streaming Unity Texture [Android]?

I am trying to retrieve the camera preview image on Android and show it on a plane in Unity. In my native code I created the following function:

 SurfaceTexture surfaceTex;
 
 public void setUpVideoTexture(int texturePtr){
     surfaceTex = new SurfaceTexture(texturePtr);
     surfaceTex.setOnFrameAvailableListener(this);
 
     Camera cam = Camera.open();//Alternatively I call this function on startup
     try {
         cam.setPreviewTexture(surfaceTex);
         cam.setPreviewCallback(this);
         cam.startPreview();
         Log.d("Unity","Preview texture set up");
     } catch (IOException e) {
         e.printStackTrace();
     }
 }

In Unity I call this function and pass the native texture pointer of the Unity texture:

 jo.Call("setUpVideoTexture", (int)renderer.material.mainTexture.GetNativeTexturePtr());

So now the camera preview image should be written into the Unity texture on every update.

However, on updating the surface texture, I get the error message "Error binding external texture image". I also tried using a RenderTexture but although I don't get an error the texture stays black. Why doesn't this work? Is it not possible to use the streaming texture in combination with a native surface texture?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rockin_Zombie · Dec 19, 2014 at 12:51 AM 0
Share

Sorry for bumping this old thread. I am having the same issue. Were you able to solve this by any chance?

avatar image sh3rifme · Jun 03, 2015 at 03:27 PM 0
Share

I'm attempting something similar, have you had any luck? I'm having a similar issue, in that it appears the texture is never properly assigned within the plugin.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Quaker_SDR · Jun 06, 2016 at 11:30 AM

anyone got it working?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by MrPhysics · Jul 28, 2016 at 01:25 PM

Anybody have an idea?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rockin_Zombie · Jul 28, 2016 at 01:33 PM 0
Share

This is not as simple. You have to go through a layer of C++ and write OpenGL code. See here:

https://docs.unity3d.com/$$anonymous$$anual/NativePluginInterface.html

avatar image MrPhysics Rockin_Zombie · Jul 28, 2016 at 02:01 PM 0
Share

Thanks, i already know that but some people seem to solved this case without help of C++.

avatar image
0

Answer by LoungeKatt · May 21, 2017 at 12:14 AM

Have you considered WebcamTexture?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

DllNotFound when unmanaged c++ plugin library links to another unmanaged c++ library 1 Answer

pass texture2d or image to native android 0 Answers

EntryPointNotFound exception when integrating Picovoice Porcupine 0 Answers

How do you determine the Android Architecture during runtime? 1 Answer

Exception: Unkown CPU architecture for Android static library as Plugin 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges