Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by unity_EDdq8x7gw4afZg · Mar 17, 2020 at 08:09 AM · webcamtexturewebcam

Cannot request Webcam Width ,Height and start camera because of too many call? I guess.

I am using Unity Editor and trying to open Logitech webcam to take photo. But everything look so weird.

First I am call my start_webcam() method in ProMainPagePreview.cs, it should print all webcam and open webcam with my config. Here is the code:

     for (int i = 0; i < WebCamTexture.devices.Length; i++)
     {
         Debug.Log("(" + i + ")\tWebCam " + WebCamTexture.devices[i].name);
     }
     string tmpDevName = WebCamTexture.devices[getConfig().USE_WEBCAM_INDEX % WebCamTexture.devices.Length].name;
     Debug.Log("Webcam [" + getConfig().USE_WEBCAM_INDEX + "%" + WebCamTexture.devices.Length + "=" + (getConfig().USE_WEBCAM_INDEX % WebCamTexture.devices.Length) +
         "] <<" + tmpDevName + ">> resolution : (" + getConfig().webcam_resolution_width + "x" + getConfig().webcam_resolution_height + ")");

     mWebCamTexture = new WebCamTexture(
         tmpDevName,
         getConfig().webcam_resolution_width,
         getConfig().webcam_resolution_height
     );
     mWebCamTexture.Play();
     Debug.Log(mWebCamTexture.deviceName + "\twidth x height = " + mWebCamTexture.width + "X" + mWebCamTexture.height + "\tIS PLAYING = " + mWebCamTexture.isPlaying);

But the Debug Log show that the webcam cannot open with my requested resolution and not running at all. DebugLog:

 >>  (0)    WebCam Logitech HD Webcam C270
 UnityEngine.Debug:Log(Object)
 ProMainPagePreview:setup(ProController) (at Assets/_Photobooth Pro/Scripts/ProMainPagePreview.cs:194)
 ProMainPage:show() (at Assets/_Photobooth Pro/Scripts/ProMainPage.cs:113)
 ProController:setUI_MainPage() (at Assets/_Photobooth Pro/Scripts/ProController.cs:130)
 <setup>c__AnonStorey0:<>m__0() (at Assets/_Photobooth Pro/Scripts/ProFirstPage.cs:32)
 UnityEngine.EventSystems.EventSystem:Update()
 >>  (1)    WebCam Integrated Webcam
 UnityEngine.Debug:Log(Object)
 ProMainPagePreview:setup(ProController) (at Assets/_Photobooth Pro/Scripts/ProMainPagePreview.cs:194)
 ProMainPage:show() (at Assets/_Photobooth Pro/Scripts/ProMainPage.cs:113)
 ProController:setUI_MainPage() (at Assets/_Photobooth Pro/Scripts/ProController.cs:130)
 <setup>c__AnonStorey0:<>m__0() (at Assets/_Photobooth Pro/Scripts/ProFirstPage.cs:32)
 UnityEngine.EventSystems.EventSystem:Update()
 >>  (2)    WebCam Logi Capture
 UnityEngine.Debug:Log(Object)
 ProMainPagePreview:setup(ProController) (at Assets/_Photobooth Pro/Scripts/ProMainPagePreview.cs:194)
 ProMainPage:show() (at Assets/_Photobooth Pro/Scripts/ProMainPage.cs:113)
 ProController:setUI_MainPage() (at Assets/_Photobooth Pro/Scripts/ProController.cs:130)
 <setup>c__AnonStorey0:<>m__0() (at Assets/_Photobooth Pro/Scripts/ProFirstPage.cs:32)
 UnityEngine.EventSystems.EventSystem:Update()
 >>  Webcam [0%3=0] <<Logitech HD Webcam C270>> resolution : (640x480)
 UnityEngine.Debug:Log(Object)
 ProMainPagePreview:setup(ProController) (at Assets/_Photobooth Pro/Scripts/ProMainPagePreview.cs:197)
 ProMainPage:show() (at Assets/_Photobooth Pro/Scripts/ProMainPage.cs:113)
 ProController:setUI_MainPage() (at Assets/_Photobooth Pro/Scripts/ProController.cs:130)
 <setup>c__AnonStorey0:<>m__0() (at Assets/_Photobooth Pro/Scripts/ProFirstPage.cs:32)
 UnityEngine.EventSystems.EventSystem:Update()
 >>  Logitech HD Webcam C270    width x height = 16X16    IS PLAYING = False
 UnityEngine.Debug:Log(Object)
 ProMainPagePreview:setup(ProController) (at Assets/_Photobooth Pro/Scripts/ProMainPagePreview.cs:210)
 ProMainPage:show() (at Assets/_Photobooth Pro/Scripts/ProMainPage.cs:113)
 ProController:setUI_MainPage() (at Assets/_Photobooth Pro/Scripts/ProController.cs:130)
 <setup>c__AnonStorey0:<>m__0() (at Assets/_Photobooth Pro/Scripts/ProFirstPage.cs:32)
 UnityEngine.EventSystems.EventSystem:Update()
 

It show webcam texture width and height is "16X16" and isPlaying = "False". And you can see there is so many layer between the button click event to start_webcam() (`ProFirstPage` button click event will show ProMainPage and it call ProMainPagePreview.setup() to start webcam).


Then, I copied the same code to ProController.cs and run. the Debug.Log():

 >   (0)    WebCam Logitech HD Webcam C270
 UnityEngine.Debug:Log(Object)
 ProController:Start() (at Assets/_Photobooth Pro/Scripts/ProController.cs:47)
 >   (1)    WebCam Integrated Webcam
 UnityEngine.Debug:Log(Object)
 ProController:Start() (at Assets/_Photobooth Pro/Scripts/ProController.cs:47)
 >   (2)    WebCam Logi Capture
 UnityEngine.Debug:Log(Object)
 ProController:Start() (at Assets/_Photobooth Pro/Scripts/ProController.cs:47)
 >   Webcam [0%3=0] <<Logitech HD Webcam C270>> resolution : (640x480)
 UnityEngine.Debug:Log(Object)
 ProController:Start() (at Assets/_Photobooth Pro/Scripts/ProController.cs:50)
 >   Logitech HD Webcam C270    width x height = 640X480    IS PLAYING = True
 UnityEngine.Debug:Log(Object)
 ProController:Start() (at Assets/_Photobooth Pro/Scripts/ProController.cs:59)

The Code Work!!!! And I don't know why it work I guess it is because my first attempt there are too many layer between the scripts. Anyone know the correct answer?

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

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

201 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 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 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 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 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 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 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 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 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

When I run getPixel32 () in WebcamTexture, only black pixels are returned. 1 Answer

How to capture Camera disconnect in using Webcamtexture for Webgl 1 Answer

Converting Texture2D into a video 1 Answer

Two webcam not play in Linux platform 0 Answers

Stream webcam via Multiplayer networking or websocket 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