locked
How can I find a USB Camera without using it's name in metro app style - C#? RRS feed

  • Question

  • Hi,

    Is it possible to find the name of camera which is connected by USB port ?

    I don't want to use the integrated camera in windows tablets or computers and I want to use only the camera which is connected by USB.

    I don't have information about name of cameras .

    I get the cameras like this:

      m_deviceInfoCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

    //How can I find which camera in connected by USB ?

    Thanks 


    • Edited by Mona7170 Wednesday, December 11, 2013 5:34 AM
    Wednesday, December 11, 2013 5:33 AM

Answers

  • Here is my solution. Please let me know if you have another idea or if it's wrong.

    I check the EnclosureLocation and if it's null it means that it's an external camera.

    m_devInfoCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
    for (int i = 0; i < m_devInfoCollection.Count; i++)
    {                        
         var devInfo = m_devInfoCollection[i];   
         if (devInfo.EnclosureLocation== null)
         {				
                //it's an external webcam ! 
                //and m_devInfoCollection[i].Name is the name of my external webcam 			
         }
    }


    • Marked as answer by Mona7170 Wednesday, March 5, 2014 11:58 PM
    Wednesday, March 5, 2014 11:58 PM

All replies

  • What's the scenario here?  What if there isn't a USB camera attached?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, December 11, 2013 8:00 PM
    Moderator
  • The app shows the usb camera previewing. It shows a default image if there is no USB camera.
    Thursday, December 12, 2013 12:35 AM
  • Do you have any suggestion? 

    Thanks

    Wednesday, December 18, 2013 4:56 AM
  • Here is my solution. Please let me know if you have another idea or if it's wrong.

    I check the EnclosureLocation and if it's null it means that it's an external camera.

    m_devInfoCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
    for (int i = 0; i < m_devInfoCollection.Count; i++)
    {                        
         var devInfo = m_devInfoCollection[i];   
         if (devInfo.EnclosureLocation== null)
         {				
                //it's an external webcam ! 
                //and m_devInfoCollection[i].Name is the name of my external webcam 			
         }
    }


    • Marked as answer by Mona7170 Wednesday, March 5, 2014 11:58 PM
    Wednesday, March 5, 2014 11:58 PM