Feasibility of write a webcam driver for cheap webcam

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

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.

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

1 Like

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.

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

Peter

@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.

@“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.

@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.

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

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?

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.

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

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

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

@chrisxenon noeld.com/programs.asp?cat=video

https://docs.microsoft.com/en-us/windows/win32/directshow/amcap-sample

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 said:
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.

OK I got Amcap working and, like the usual program I use it shows the same thing. The exposure control is present. I can un-tick AUTO and move the slider, but the exposure is not changed. With my old cameras, exposure changes with the slider. So the USB interface advertises manual exposure, and the UI presents it, but it doesn’t work.

The reason I need manual exposure is that my application is a spectrometer where the image I want is high contrast and mostly dark. Auto-exposure tries to compensate, over-exposing my spectrum image, making it useless. Manual gain works, but even at zero, auto-exposure has saturated the spectrum.

I guess this is the end of the line?