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 njpatter · Jan 21, 2014 at 10:51 PM · frameratewebcamtexturewebcam

WebcamTexture not refreshing

Hey everyone,

This is an extremely frustrating issue because it is such a simple setup.

When working with a webcam I noticed that its refresh rate was much lower than the 30FPS I requested in code. Not a big surprise, but I've determined that the frame rate is somehow connected to the amount of code running in the scene.

Not like how you are thinking either... when I remove all other code from the scene and just start up a webcamtexture, like this:

 WebCamTexture curentView = new WebCamTexture(WebCamTexture.devices[0], 1280, 720, 30);
 currentView.Play();
 renderer.material.mainTexture = currentView;

I get a reasonable refresh rate on the view for about 0.5-1 seconds and then it freezes. After it freezes it sometimes updates once every 5-10 seconds and sometimes never again. As I said, this is with no other code running in the scene at all.

Now when I add the following update function:

 void Update() {
      int j = 0;
      for(int i = 0; i < 10000000; i++) {
          j += i;
      }
 }

I get between 3 and 8 FPS from the webcam (I used another piece of code added later to calculate those values from currentView.didUpdateThisFrame being true or false). This was tested with 2x an external camera (same model) and 1x the camera included above my laptop screen. I've also had this issue on more than one computer.

Any ideas on how to get a more consistent frame rate from webcams? Better yet, any ideas on how to not have your webcam freeze up when not running much code?

Thanks in advance.

Using Unity Pro 4.3.3f1

Comment
Add comment · Show 8
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 njpatter · May 05, 2014 at 06:51 PM 0
Share

This problem seemed to go away in our code, but it had only disappeared because we were doing a few things really inefficiently. Now that we've optimized things and are getting very high FPS the webcam stuff is freezing up again.

avatar image Ed unity · May 05, 2014 at 07:32 PM 0
Share

Have you tried changing the target FPS of the webcam texture to see if it effects the freezing at all?

avatar image njpatter · May 05, 2014 at 07:49 PM 0
Share

Good question. Yes I have, however it does not offer any improvement that I noticed. I'll try again later this afternoon to see if the actual delays (5-10 seconds) are the same or different... meaning I will collect actual ti$$anonymous$$g numbers for comparison.

avatar image njpatter · May 09, 2014 at 10:09 PM 0
Share

Alright, took me a few days but I put together a program that starts the camera, watches for 30 seconds and counts the number of frames where didUpdateThisFrame was true, and then divided by the capture time to get FPS. I had it run this routine 5 times for each of the following framerates (none- didn't pass the FPS argument, 1, 5, 15, 30)

These are the numbers (actual frame rates from the camera) that it found: None, didn't pass FPS argument - 7.2999 0.0331 0.0333 0 4.2105

1 FPS requested - 0 0.0333 0 0.0662 0

5 FPS requested - 0 0 0 0 0

15 FPS requested - 0.0333 0 0 0 0

30 FPS requested - 0 0.0333 0 0 0

I will also try running the same routine but include the counting for loop in each Update call to slow things down.

avatar image njpatter · May 09, 2014 at 10:29 PM 0
Share

Hah, this is funny... When I run it with the following loop in the Update routine: for(int i = 0; i < 1000000; i++) { i = i + 1 - 1; }

I get the following actual framerates:

None req, didn't pass arg - 7.465 7.397 7.398 7.365 7.364

1 FPS requested - 7.364 7.398 7.399 7.399 7.365

5 FPS requested - 7.398 7.398 7.398 7.265 7.365

15 FPS requested - 7.399 7.366 7.399 7.399 7.366

30 FPS requested - 7.498 7.366 7.365 7.399 7.398

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

19 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

Related Questions

WebCameTexture.Play() Could not connect pins - RenderStream() 5 Answers

Take photo from webcam (not grab frame from video stream) 0 Answers

Problems with webcam 1 Answer

Webcamtexture at 1080p 50fps produces black image 1 Answer

WebCamTexture.devices.Length returning 0 in Unity 2020.3.8f1 0 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