To choose from orthographic/perspective camera for mapping object to a pixel position and scaling of that object #933
Unanswered
nitinrhr183
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Have you tried using a perspective camera? Orthographic cameras don't handle depth like that. Just brainstorming here, but it seems like your transform function is not changing the depth (z) position. Its always 10, so the object would always be the same scale, even with a perspective camera. Maybe try to calculate the depth based on the distance between the ear points and set that as the objects z position with a perspective camera. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my project, I am locating the ear points and the neck point and I am projecting 3d objects there dynamically....The video and canvas are of 640*480 merged as you can see in the video attached...
<Canvas
id="canvid"
orthographic
style={{
width: 640,
height: 480,
}}
pixelRatio={undefined}
camera={{ position: [0, 0, 350] }}
>
I have currently used orthographic camera(not sure that is the appropriate one though)...
So here I get the video pixel points(for ear and neck) as (videox,videoy) and i mapped to world coordinates as below..
const transform = (videox, videoy) => {
const k = videox - 640 / 2;
const l = videoy - 480 / 2;
//console.log("k,l=", k, l);
return [-k, -l, 10]; // position passed to render object
};
..
Now the problem I face is the appropriate scaling of object is I move back and forth wrt to webcam.When my face is near to webcam,the object shoulld enlarge and when i go far,the object should have less size....How could I do that and should I stick with orthographic for this app..
NB:For both ortho and persp,i am able to map object to the required pixel point using the same transform() function....Now the problem is back and forth scaling...
React.App.-.Google.Chrome.2021-01-13.00-36-27.mp4
Beta Was this translation helpful? Give feedback.
All reactions