Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Feasibility of write a webcam driver for cheap webcam

chrisxenonchrisxenon Member Posts: 9
edited November 18 in NTDEV

Hello folks. First time here. I've read the Getting Started and the joining stuff, and I've searched for solutions without success, so I hope I'm not wasting your time.

I am embedding a webcam camera board in another product which I sell, but the board I have been using is no longer sold, so I need a replacement.
All of the boards in the new webcams I have tested do not permit manual exposure/gain control - which is essential for my application.
They use automatic control which is not suitable, as my application shows the webcam dim images and the gain-up destroys the image.
The cameras I've looked at have chips with number on them which I cannot find online, so I can't get tech specs (unless you know otherwise).
I was a software engineer for a long time, but I have no experience with Windows programming.

So - two questions, really:

  1. Is there a way to forward to identify the chips in these webcams without being able to look up the numbers?
    I guess I can look at the chip topology & pin count, and - knowing it's a microcontroller of some kind, I might be able to make assumptions.
    I could also probe for signals and gain insights that way, the the pins are tiny and very close, and this seems like a daunting prospect. Is there an easier way?

  2. This may be a dumb quesiton - but can you give me a feel for the level of effort required for someone with my background to get up and running with a driver that presents the device as a webcam with manual exposure control? Of course - if the hardware doesn't support manual control, then all bets are off.

Many thanks
Chris

Post edited by Peter_Viscarola_(OSR) on

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    I assume this conversation will be moved to the [ntdev] forum, where it belongs.

    If you want to post the make and model, and even the numbers from the chips, we can look things up. However, since the sensor chips are usually hidden underneath a lens, you may not find numbers. Even cameras with AGC usually let you shut that off. Is that really not an option? Once you turn off AGC, it's easy to do manual brightness/contrast in software.

    The vast majority of modern cameras are USB Video Class compliant, where Microsoft provides the drivers. The camera advertises its capabilities, and usbvideo.sys does the rest. If the camera does not advertise "AGC disable", then there's no way for you to request it.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,157

    Moved from the "A&A" category to NTDEV.

    can you give me a feel for the level of effort required for someone with my background to get up and running with a driver

    VERY significant. Assuming you're an accomplished C Language programmer, unless you have kernel-mode programming experience (on any OS) or want to take a seminar to learn, your ramp-up time would be considerable... the actual amount of time depending on your background and how dedicated you are to the task. Then you can begin the process of trying to write the driver for the device you chose, and -- assuming you don't have somebody to mentor you -- that becomes a long trial-and-error process on the order of months.

    You can read some comments that I wrote on this topic a few years back.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    Yes, but....

    Assuming the camera is UVC, and essentially all web cams are, there's simply no opportunity for you to do this kind of thing. There's no way for you to "get around" the UVC interface to control the sensor at a low level. If the hardware designers did not make something controllable through the UVC interface, then it cannot be controlled. It's as simple as that.

    Tim Roberts, ti[email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,157

    I humbly defer to Mr. Roberts superior knowledge of all things UVC. I claim no experience in this area whatsoever.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • chrisxenonchrisxenon Member Posts: 9

    @Tim_Roberts said:
    I assume this conversation will be moved to the [ntdev] forum, where it belongs.

    If you want to post the make and model, and even the numbers from the chips, we can look things up. However, since the sensor chips are usually hidden underneath a lens, you may not find numbers. Even cameras with AGC usually let you shut that off. Is that really not an option? Once you turn off AGC, it's easy to do manual brightness/contrast in software.

    The vast majority of modern cameras are USB Video Class compliant, where Microsoft provides the drivers. The camera advertises its capabilities, and usbvideo.sys does the rest. If the camera does not advertise "AGC disable", then there's no way for you to request it.

    Hello Tom and thanks for your comments. Apologies for putting the post in the wrong place.

    Makes and models - these cheap cameras come with many brandings that are independent of the make and model, but for the camera I am most interested in the drivers (as reported by Device Manager) are: Drivers: C:\WINDOWS\system32\drivers\ksthunk.sys, .../WdmCompanionFilter.sys, .../DRIVERS\UMDF\Secure\USBVideo.dll, and .../USBVideo.sys
    The controller chip is: JL 9or maybe JC) AC20AP22748-13B4 - I can't find that online.
    When I connect this webcam to me software the exposure controls are greyed out, which I take to mean this is not offered by the controller.
    In other models, the controls are not greyed out, and I cna move them - but they have no effect.

    I don't know if anything I've said helps you to help me more, but again - thanks fo royur help so far.

  • chrisxenonchrisxenon Member Posts: 9

    @Peter_Viscarola_(OSR) said:
    Moved from the "A&A" category to NTDEV.

    can you give me a feel for the level of effort required for someone with my background to get up and running with a driver

    VERY significant. Assuming you're an accomplished C Language programmer, unless you have kernel-mode programming experience (on any OS) or want to take a seminar to learn, your ramp-up time would be considerable... the actual amount of time depending on your background and how dedicated you are to the task. Then you can begin the process of trying to write the driver for the device you chose, and -- assuming you don't have somebody to mentor you -- that becomes a long trial-and-error process on the order of months.

    You can read some comments that I wrote on this topic a few years back.

    Peter

    Thanks Peter. "onsiderable", huh? I program in C but I'm 61 and my thinking is mushing out as the years roll on. I'm thinking now, then,, that I'm not up to it. I've tried to hire people from fiverr.com but so far - only idiots have applied.

  • chrisxenonchrisxenon Member Posts: 9

    @Tim_Roberts said:
    Yes, but....

    Assuming the camera is UVC, and essentially all web cams are, there's simply no opportunity for you to do this kind of thing. There's no way for you to "get around" the UVC interface to control the sensor at a low level. If the hardware designers did not make something controllable through the UVC interface, then it cannot be controlled. It's as simple as that.

    That hs to be true, of course. I guess this leaves trawling for a webcam that has a controller that allowsmanual control. Trouble is sellers don't know what they're selling very often. Asking them on EBay, for example, is futile. In fact, they're busy trying to pass off VGA cameras as HD. Maybe I can take up basket weaving.

  • chrisxenonchrisxenon Member Posts: 9

    I can't see a way to get notifications of updates to this thread. Is it possible?

  • chrisxenonchrisxenon Member Posts: 9

    I wonder if it's possible to watch the exchange of data via the USB interface. Presumably, in that dialogue, the hardware announcees its capabilities to the host. Alternatively, a program that just interrogates any USB device and asked it to declare its capabilities?

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    It's all in the descriptors. You can go look at the descriptors using the UVCView tool (derived from USBView). It will tell you which features of the feature units it supports. You'll need to download the USB Video Class specification from usb.org.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    I believe that's manufactured by Shenzhen Jing Cheng Digital Surveillance Co in China. You have zero chance of getting any details about the chip. If you need to have specific features, then you need to find specific cameras. You might take a look at Videology.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • chrisxenonchrisxenon Member Posts: 9

    @Tim_Roberts said:
    I believe that's manufactured by Shenzhen Jing Cheng Digital Surveillance Co in China. You have zero chance of getting any details about the chip. If you need to have specific features, then you need to find specific cameras. You might take a look at Videology.

    Tim, you'v ebeen very helpful. I'm installing the SDK, and I'll follow your other advice too. I appreciate your time and your advice - thanks.

  • chrisxenonchrisxenon Member Posts: 9

    Hmmm, USBView seems to tell me that the controller at least supports everything.
    I guess the sensor chip to which it's attached may not be able to implement all the features of the controller.
    Either way, the drivers installed don't allow manual exposure control.
    By the way, those drivers seem to be the same for every webcam I've plugged in (ksthunk.sys, CompanionFilter.sys, USBVideo.dll, USBVideo.sys).
    Given your earlier comments about the learning curve, it looks like I may have to bite the bullet and accept a 5x price hike and buy the boards which implement the features I need.

    Thanks again folks, for your time.

          ===>Interface Descriptor<===
    

    bLength: 0x09
    bDescriptorType: 0x04
    bInterfaceNumber: 0x00
    bAlternateSetting: 0x00
    bNumEndpoints: 0x01
    bInterfaceClass: 0x0E -> Video Interface Class
    bInterfaceSubClass: 0x01 -> Video Control Interface SubClass
    bInterfaceProtocol: 0x00
    iInterface: 0x06
    English (United States) "USB CAMERA"

          ===>Class-Specific Video Control Interface Header Descriptor<===
    

    bLength: 0x0D
    bDescriptorType: 0x24
    bDescriptorSubtype: 0x01
    bcdVDC: 0x0100
    wTotalLength: 0x0067 -> Validated
    dwClockFreq: 0x01C9C380 = (30000000) Hz
    bInCollection: 0x01
    baInterfaceNr[1]: 0x01
    USB Video Class device: spec version 1.0

          ===>Video Control Input Terminal Descriptor<===
    

    bLength: 0x12
    bDescriptorType: 0x24
    bDescriptorSubtype: 0x02
    bTerminalID: 0x01
    wTerminalType: 0x0201 = (ITT_CAMERA)
    bAssocTerminal: 0x00
    iTerminal: 0x00
    ===>Camera Input Terminal Data
    wObjectiveFocalLengthMin: 0x0000
    wObjectiveFocalLengthMax: 0x0000
    wOcularFocalLength: 0x0000
    bControlSize: 0x03
    bmControls : 0xFF 0xFF 0x1F
    D00 = 1 yes - Scanning Mode
    D01 = 1 yes - Auto-Exposure Mode
    D02 = 1 yes - Auto-Exposure Priority
    D03 = 1 yes - Exposure Time (Absolute)
    D04 = 1 yes - Exposure Time (Relative)
    D05 = 1 yes - Focus (Absolute)
    D06 = 1 yes - Focus (Relative)
    D07 = 1 yes - Iris (Absolute)
    D08 = 1 yes - Iris (Relative)
    D09 = 1 yes - Zoom (Absolute)
    D10 = 1 yes - Zoom (Relative)
    D11 = 1 yes - PanTilt (Absolute)
    D12 = 1 yes - PanTilt (Relative)
    D13 = 1 yes - Roll (Absolute)
    D14 = 1 yes - Roll (Relative)
    D15 = 1 yes - Reserved
    D16 = 1 yes - Reserved
    D17 = 1 yes - Focus, Auto
    D18 = 1 yes - Privacy
    D19 = 1 yes - Focus, Simple
    D20 = 1 yes - Window
    D21 = 0 no - Region of Interest
    D22 = 0 no - Reserved
    D23 = 0 no - Reserved

          ===>Video Control Processing Unit Descriptor<===
    

    bLength: 0x0B
    bDescriptorType: 0x24
    bDescriptorSubtype: 0x05
    bUnitID: 0x02
    bSourceID: 0x01
    wMaxMultiplier: 0x0000
    bControlSize: 0x02
    bmControls : 0xFF 0xFF
    D00 = 1 yes - Brightness
    D01 = 1 yes - Contrast
    D02 = 1 yes - Hue
    D03 = 1 yes - Saturation
    D04 = 1 yes - Sharpness
    D05 = 1 yes - Gamma
    D06 = 1 yes - White Balance Temperature
    D07 = 1 yes - White Balance Component
    D08 = 1 yes - Backlight Compensation
    D09 = 1 yes - Gain
    D10 = 1 yes - Power Line Frequency
    D11 = 1 yes - Hue, Auto
    D12 = 1 yes - White Balance Temperature, Auto
    D13 = 1 yes - White Balance Component, Auto
    D14 = 1 yes - Digital Multiplier
    D15 = 1 yes - Digital Multiplier Limit
    iProcessing : 0x00

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    Given that set, you ought to be able to turn off auto-exposure. If you bring up the camera properties in graphedt or amcap, do you not see a checkbox to turn off auto-exposure?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • chrisxenonchrisxenon Member Posts: 9

    @Tim_Roberts said:
    Given that set, you ought to be able to turn off auto-exposure. If you bring up the camera properties in graphedt or amcap, do you not see a checkbox to turn off auto-exposure?

    Thanks again.
    I don't have Amcap and the download places I tried all look like the kind that will stiunk up my PC, wiht several layers of "download now" each one of which tries to dupe me into downloading something which isn't Amcap.
    I installed the SDK which is how I ran usbview of course, but I don't have graphedt and it's not where the doc says it is nor anywhere else I look.
    I have several programs which use video capture but only one shows me the video input controls: "theremino spectrometer".
    That allows me to un-tick AUTO and the exposure number is then un-greyed out, but the slider won't move.
    I guess I really need one of those you mentioned. Do you know of a safe download link ofr Amcap?
    Thanks.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,692

    I'm not sure auto-exposure is really the targets. That controls the exposure time. I didn't notice if the descriptors showed auto-brightness or not.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE