Error with camera and jweb mediapipe
I'm using windows 10 PC.
Camera is recognize but I'm getting the below error. Any idea why?

I updated windows and problem solved.. (no idea..)
I have different problem now: I opened this jweb face patch:
I try to change between 1 of my three webcams I have (all of them from the same type and name) and It won't change my source. It will stuck on 1 camera without changing

I had the same problem before. For me it was because Windows mixed up the camera IDs — even if the webcams look identical, the system gives them different indexes each time. After a Windows update it started working again.
Maybe try:
unplugging all but one camera to check which one Max sees,
making sure no other app is using the webcam,
and checking Windows privacy settings for camera access.
Sometimes just updating Windows or drivers fixes it (that’s what solved it for me).
The problem is that I need all three camera to work. I need two of them for the face recognition.
Windows is up to date. I don't understand why max give them the same name and address (as in the pic I shared). There is no option to change the camera name so Max can distinguish between the different cameras
btw - When using jit.grab I manage to select different cameras without an issue
Multiple cameras having the same name is a known issue which has been addressed in Max 9 with the new uniqueid attribute.
The following patch shows how to store and retrieve a camera by its uniqueid (which is by definition unique), but sadly it will only work in Max 9.
This said, I got plenty of results by doing a web search for windows rename camera device. Not sure if it will work in your case but worth trying if you didn't already.
The problem is that this issue happens only in the jweb mediapipe patch. When working with multiple cameras using jit.grab I have no issue to change between cameras at all
This said, I got plenty of results by doing a web search for
windows rename camera device. Not sure if it will work in your case but worth trying if you didn't already.
I have tried to change the name in the RegisteryEdit in windows (adding FriendlyName). the name of the camera is indeed changed in Device Manager but not in MaxMSP
My bad, I misunderstood your problem.
The problem you're facing doesn't lies in Max but in the js code of the webpage opened in jweb. That code populates the devices menu only with their name, which sometimes isn't enough to identify a given camera (like in your case).
Give me some time to update the code so that it handles the device id too.
Okay, you will need to replace a few things in the js code of the jweb page (I imagine face-landmarker.js but could be named differently).
First repace the block of code for getVideoDevicesForMax (the function that populates the devices menu) by the following:
const getVideoDevicesForMax = () => {
getMediaDevices()
.then((devices) => {
let mediadevices = [];
devices.forEach((device) => {
if (device.kind === "videoinput") {
mediadevices.push(device.label + ' | ' + device.deviceId);
}
});
window.max.outlet.apply(window.max, ["mediadevices"].concat(mediadevices));
})
.catch((err) => {
window.max.outlet("error",`${err.name}: ${err.message}`);
});
}This will add | a-very-long-string-of-letters-and-numbers after the name of each device. This long string is the unique id of the device as provided by the Media Stream API of the navigator (jweb). The id should be unique to a specific device running on that computer in jweb in Max.
Then add this somewhere in the code. This retrieves a given device by its Id instead of its name.
const getMediaDeviceById = async (deviceId) => {
let mediaDevices = await getMediaDevices();
return mediaDevices.filter(device => device.deviceId == deviceId);
}Then replace the block of code handling the set_mediadevice messages sent to jweb by this:
window.max.bindInlet('set_mediadevice', async function (deviceLabel) {
let deviceId = deviceLabel.split(" ").pop();
let devices = await getMediaDeviceById(deviceId);
if (!devices.length) {
window.max.outlet("error", `No video input device: "${deviceLabel}" exists.`);
return
}
const device = devices.shift();
video.srcObject = await navigator.mediaDevices.getUserMedia({video: {deviceId: device.deviceId}});
await setRunningMode("VIDEO");
});This will get the device Id at the end of the string and use getMediaDeviceById we just added to actually open the device.
Same the js file, send a reload to jweb and now check your device menu.
Then replace the block of code handling the
set_mediadevicemessages sent to jweb by this:
can't find this code part
I think I found it. Will update soon
OK it is working!!! Thank you so much!
How can I deal with two cameras in the same patch?
Right now I have clash in the data when using two cameras.
changing the s and r of face0 did not solved it
Edit: What is that I'm asking is how can I make it work with two camera in the same patch so I could get each face independently (using two cameras one for each face and not 1 camera with two faces)
EDIT2: Thank to chatgpt for solving it! (I created another js file for the second camera
The js file shouldn't be the problem here, but the fact that you are using [s _face0] and [s _face1] for both cameras, which means that any [r _face0] and [r _face1] in your patch will receive the data from both cameras.
After some weeks it was working just fine I'm suddenly getting this error again:
Any idea what could it be?

I'm using two cameras to capture the room and another two camera one for each eyetracking
So if to be as precise as I can:
I have 4 cameras with the same name.
I want to record all 4 cameras and 2 of them will also give me the eyetracking using the jweb and the above code TFL shared.
the issue I'm facing is that I can't make all cameras work in addition to the jweb eye tracker. I'm not sure what the issue is.
Edit: I manage to make all 4 cameras work and also to record their output but then I cannot pass two of the camera via the jweb media pipe section. I'm getting an error
So What I discovered:
I can either record all 4 cameras but not use the jweb (eye tracking)
or
Record 2 cameras and use the jweb eyetracker with the other 2 cameras
what I would like to do but seems not possible:
Record all 4 cameras including the jweb eye tracking processing
