Skip to content

Instantly share code, notes, and snippets.

@hugs
Created December 7, 2022 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugs/66d4ea0655fe5b53c5a35b04656462b1 to your computer and use it in GitHub Desktop.
Save hugs/66d4ea0655fe5b53c5a35b04656462b1 to your computer and use it in GitHub Desktop.
arducam16.mjs
// https://github.com/qweasd1/node-uvc-control (npm uvc-control2)
// Example
// import { Control } from './arducam16.mjs'
// var control = new Control({width: this.config.width, height: this.config.height})
// control.init()
import UVCControl from 'uvc-control2'
const defaults = {
width: 3840,
height: 2160
}
export class Control {
constructor(config) {
this.config = {...defaults, ...config}
try {
console.log('Camera: connected')
this.control = new UVCControl({vid: 0xc45, pid: 0x636d, processingUnitId: 0x02})
} catch(error) {
console.log(error)
}
}
init() {
try {
this.control.set('autoFocus', 0x01).
then(sleeper(500)).
then((result) => this.control.set('autoFocus', 0x00)).
then(sleeper(500)).
then((result) => this.control.set('absoluteFocus', 288)).
then((result) => this.control.set('autoExposureMode', 0x01)).
then((result) => this.control.set('absoluteExposureTime', 500)).
then((result) => this.control.set('gain', 6)).
//then((result) => this.control.set('autoWhiteBalance', 0x01)).
//then((result) => this.control.set('whiteBalanceTemperature', 2820)).
then((result) => console.log('Camera controls set'))
} catch(error) {
console.log('Error on camera init')
console.log(error)
}
}
}
function sleeper(ms) {
return function(x) {
return new Promise(resolve => setTimeout(() => resolve(x), ms));
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment