-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createCapture flipped property in WEBGL fixed #7301
Conversation
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page! |
lib/empty-example/sketch.js
Outdated
let video; | ||
function setup() { | ||
// put setup code here | ||
createCanvas(640, 480, WEBGL); | ||
video = createCapture(VIDEO, { flipped: true }); | ||
video.hide(); | ||
} | ||
|
||
function draw() { | ||
// put drawing code here | ||
translate(-width / 2, -height / 2); | ||
scale(-1, 1); //added scale for horizontal flip | ||
image(video, -width, 0); //here used -width that shifts the video back into view from the opposite side | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm...You may need to make some adjustments to the actual code. For instance, when you write the same code in sketch.js:
let video;
function setup() {
createCanvas(640, 480, WEBGL);
video = createCapture(VIDEO, { flipped: true });
video.hide();
}
function draw() {
translate(-width / 2, -height / 2);
image(video, 0, 0);
}
The aim is to keep the code unchanged, but ensure the output is as expected. To achieve this, it might be necessary to modify the codebase.
I have a strong feeling the createCapture
function may not be handling the flipping correctly in WEBGL
, so it’s worth investigating. Please feel free to reach out if I could help you with any other way for this issue! You don't need to update the sketch.js
but probably the function used in sketch.js is needed to be changed so that with the same code above we could achieve the output.
Here's the createCapture
function which could be worth looking at:
Line 2401 in 7d393ec
p5.prototype.createCapture = function(...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, If i am not wrong it will be how webgl is applying texture for video we need to handle that for flipped videos.
I suspect the issue might be happening here: Lines 122 to 129 in 7d393ec
So So maybe to handle the case where we have a canvas, we can set |
@davepagurek This is working great. |
Hey on further check this is not flipping. |
It looks like in addition to it not using the correct texture source, it also isn't calling |
Resolves #7300
(createCapture flipped property in WEBGL)
Changes:
These changes ensure that the webcam feed behaves like a mirror, with correct left-right orientation when interacting with it.