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
2
Question by ferretnt · Apr 04, 2012 at 06:46 PM · iphonewebcamunity3.5

Unity 3.5 WebCamTexture extremely slow to access from CPU

Like it seems almost everyone else, I'm doing some CPU-side computer vision on the video feed from the iPad's front camera. Unfortunately, it seems that passing the pixelData from a Unity3.5 webCamTexture to a C++ plugin is unusably slow. On my iPad2, a simple main loop, which calls this:

 unityWebcamImageData = webcamTexture.GetPixels32();

where unityWebcamImageData[] is a pre-allocated array of the correct size, and then passes a pointer to that array to a C++ function that does nothing only gets around 6fps. (webCamTexture is 640x480 in this test.)

Now, getting CPU-side access to the video feed via AVFoundation (and indeed, also giving that data back to Unity via a GL texture) isn't that much code, so my question is simple - is Unity's WebCamTexture internally structured such that what I'm doing should work more efficiently? Or is there an alternative API I can use other than GetPixels32(), or is the WebCamTexture only useful if you're doing pure GPU-side processing (grab image, use as texture during GPU render) and I should use AVFoundation if requiring CPU-side access?

As a side note, I'm also getting some bizarre image sizes back from various Mac Webcams - e.g. requesting 640x480 video from my built-in iSight returns a 640x480 texture, but requesting the same thing of my Logitech C910 returns a 640x640 texture, even though AVFoundation reports that camera as capable of 640x480, and it seems strange to pad the texture to a square nonpow-2 size.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ferretnt · Jun 05, 2012 at 11:20 PM

I'm afraid I dropped WebcamTexture when nobody responded to this question and handled the camera directly from a C++ plugin.,Yes, I used a C++ plugin and handled the camera myself rather than using WebcamTexture at all.

I keep a reference build of the code using WebcamTexture, which is sort of my default build when cross-compiling to a new platform.

I haven't checked if performance has improved, but in practice there were a bunch of other things I wanted from the camera, like getting the raw luma-chroma video feed that WebcamTexture isn't really set up for anyway.

Comment
Add comment · Show 3 · 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 Berenger · Jun 05, 2012 at 11:21 PM 0
Share

People with less than 15 karma must have their question and answer approved by people with more karma before being published. That's why you didn't see it right away.

avatar image jranks123 · Dec 04, 2013 at 12:18 PM 0
Share

how did you use the C++ plugin? Do you have unity Pro or did you find a work around?

avatar image Timberoth · Jun 20, 2014 at 03:29 AM 0
Share

I'd be interested in licensing your raw camera feed Unity plugin because we're running into slow Android device performance in our project.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

WebCamTexture and VSync (iPhone 4) 3 Answers

How Can I Get the Device Camera Aspect Ratio? 3 Answers

Trying to get iPhone 5 rendering at the same aspect ratio as an iPhone 4. 0 Answers

Is it possible to render Unity graphics elements on top of iPhone / Android video feed? 2 Answers

Get a portion of a Texture2D to another Texture2D 1 Answer


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