add camera startup diag messages

pull/280/head
Vladimir Mandic 2021-05-26 07:57:51 -04:00
parent 4ab5bbb6e6
commit da7721d580
3 changed files with 25 additions and 4 deletions

View File

@ -9,8 +9,9 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
## Changelog
### **HEAD -> main** 2021/05/24 mandic00@live.com
### **HEAD -> main** 2021/05/25 mandic00@live.com
- implemented unified result.persons that combines face, body and hands for each person
- added experimental results interpolation for smooth draw operations
### **1.9.3** 2021/05/23 mandic00@live.com

View File

@ -304,10 +304,19 @@ async function setupCamera() {
ui.busy = false;
return msg;
}
// enumerate devices for diag purposes
const devices = await navigator.mediaDevices.enumerateDevices();
log('enumerated devices:');
for (const device of devices) log(` kind:${device.kind} label:${device.label} id:${device.deviceId}`);
let stream;
const constraints = {
audio: false,
video: { facingMode: ui.facing ? 'user' : 'environment', resizeMode: ui.crop ? 'crop-and-scale' : 'none' },
video: {
facingMode: ui.facing ? 'user' : 'environment',
resizeMode: ui.crop ? 'crop-and-scale' : 'none',
// deviceId: 'xxxx' // if you have multiple webcams, specify one to use explicitly
},
};
if (window.innerWidth > window.innerHeight) constraints.video.width = { ideal: window.innerWidth };
else constraints.video.height = { ideal: (window.innerHeight - document.getElementById('menubar').offsetHeight) };
@ -328,8 +337,19 @@ async function setupCamera() {
ui.busy = false;
return 'camera stream empty';
}
const tracks = stream.getVideoTracks();
if (tracks && tracks.length >= 1) {
if (tracks.length >= 1) {
log('enumerated viable tracks:', tracks.length);
for (const t of tracks) log(` ${t.kind}: ${t.label}`);
}
} else {
ui.busy = false;
return 'no camera track';
}
const track = stream.getVideoTracks()[0];
const settings = track.getSettings();
log('selected camera:', track.label, 'id:', settings.deviceId);
// log('camera constraints:', constraints, 'window:', { width: window.innerWidth, height: window.innerHeight }, 'settings:', settings, 'track:', track);
ui.camera = { name: track.label.toLowerCase(), width: settings.width, height: settings.height, facing: settings.facingMode === 'user' ? 'front' : 'back' };
return new Promise((resolve) => {

View File

@ -67,8 +67,8 @@
"@vladmandic/pilogger": "^0.2.17",
"canvas": "^2.8.0",
"chokidar": "^3.5.1",
"dayjs": "^1.10.4",
"esbuild": "^0.12.2",
"dayjs": "^1.10.5",
"esbuild": "^0.12.3",
"eslint": "^7.27.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.3",