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 Byard · Nov 25, 2013 at 07:48 PM · c#webcam

Detect Webcam using AForge

Hi,

I'm working on a game that needs to take picture with a webcam and then do some image analysis to determine the position of tokens.

For that I made a c# dll that use AForge library to detect webcam and do the analysis. It works when I try it on a c# application, but when I integrate the DLL in my game in Unity, it won't detect any webcam.

I built my dll and each dll of AForge in framework 3.5 x86.

Here the code that should find the webcam:

  // Code update
             // enumerate video devices
             FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
 
             // create video source
             LogFile.Instance.Log("Count" + videoDevices.Count);
             _findCamera = false;
             for (int i = 0; i < videoDevices.Count; i++)
             {
                 LogFile.Instance.Log(videoDevices[i].Name.Trim());
                 if (videoDevices[i].Name.Trim() == CAM_NAME/*true*/) // Set "true" for tests with other camera.
                 {
                     _videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString);
                     _findCamera = true;
                 }
             }
             if (_findCamera == false)
             {
                 return;
             }

While running in Unity, the videoDevices.count is 0.

I found a post that says that it won’t work, but it was said in 2011. Directshow seemed not to be supported.I hope there is a way now. http://forum.unity3d.com/threads/76860-C-script

By the way, I have no error message. Just that the program can't find the webcam.

Thank you for your help.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mTigar · Dec 12, 2017 at 11:31 PM

Hi @Byard ,

Did you ever this this question answered, as I'm having the same problem?

thanks, - Michael

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 Nassr · Aug 19, 2018 at 10:19 AM

Hello, I have the same problem as well, normally the following code snippet should return the available webcams.

 FilterInfoCollection VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

However, "VideoCaptureDevices" is always 0; and I don't have any error message. Is there any solution for this problem ??

Comment
Add comment · Show 1 · 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 MrDude · Aug 02, 2019 at 01:16 AM 0
Share

August 2019 and still no solution in sight for the 2013 problem :(

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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

WebCamTexture IOS crashing? 1 Answer

Renderer on object disabled after level reload 1 Answer

Convert Java to C# 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