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
0
Question by cecarlsen · Mar 17, 2014 at 09:43 AM · webcamtexturewebcam

WebCamTexture, when are you updated?

I want to grab pixels from a webcam texture just as they arrive, but the pixels I receive using GetPixels32 (when didUpdateThisFrame is true) seem to be one frame behind when I compare to the original texture (displayed by GUI.DrawTexture). I've tried to grab the pixels on Update and LateUpdate.

When exactly is the texture updated?

UPDATE#1: When using OnPreCull, OnPreRender or OnPostRender then pixels and texture seem to be in sync. I still get some random time offsets, perhaps because I'm only grabbing pixels when didUpdateThisFrame is true =/

UPDATE#2: Using WatForEndOfFrame in a coroutine does not seem to fix the issue either.

Carl Emil

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 Benproductions1 · Mar 17, 2014 at 10:04 AM 0
Share

@CarlEmail Please add further information into the question rather than as an additional comment :)

avatar image cecarlsen · Mar 17, 2014 at 12:12 PM 0
Share

@Benproductions1 done.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Mar 17, 2014 at 10:05 AM

You want to grab them inside a coroutine that waits for the end of the frame:

    IEnumerator Grab() {
        yield return new WaitForEndOfFrame();
        //Grab pixels here
    }

Then when it changes

   StartCoroutine(Grab());
Comment
Add comment · Show 6 · 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 cecarlsen · Mar 17, 2014 at 10:16 AM 0
Share

Thanks for the proposal. That doesn't seem to help either. I'm still a frame behind =/

avatar image cecarlsen · Mar 17, 2014 at 10:18 AM 0
Share

I also tried to set the script execution order to execute the script first and last, without any improvement.

avatar image whydoidoit · Mar 17, 2014 at 10:35 AM 0
Share

Well WaitForEndOfFrame happens after OnPreCull etc.

avatar image cecarlsen · Mar 17, 2014 at 10:37 AM 0
Share

Strange =/

avatar image whydoidoit · Mar 17, 2014 at 10:41 AM 0
Share

Perhaps try a yield return null then yield return new WaitForEndOfFrame?

Show more comments
avatar image
0

Answer by Lanre · Mar 17, 2016 at 06:30 PM

If you are going to be running your application on iOS or Android, use NatCam. It provides access to the raw pixel data of the camera, the native buffer (for use with native plugins), and will soon have video recording support. It's worth a gaze and it's blazing fast.

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

23 People are following this question.

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

Related Questions

Web Cam Texture on UI Panel 0 Answers

how to track object motion with webcam 0 Answers

wrong Webcam resolution microsoft surface 2 0 Answers

Webcam GetPixels is only returning black 1 Answer

Show a WebCamTexture with alpha 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