We are about to switch to a new forum software. Until then we have removed the registration on this forum.
im asking because i like to know how to move it like to the left, and make another one for the right "im trying to build a game (i obj arms which i plan to import using obj model)"
right now it seems that it is fixed to be in the middle but i dont see any constraints so im not sure what is telling it to start and rotate from the middle
float mx;
float my;
float easing = 0.05;
int radius = 24;
int edge = 100;
int inner = edge + radius;
strokeWeight(3);
stroke(trackColor);
float dx = mouseX - x;
float dy = mouseY - y;
float angle1 = atan2(dy, dx);
float tx = mouseX- cos(angle1) * segLength;
float ty = mouseY - sin(angle1) * segLength;
dx = tx - x2;
dy = ty - y2;
float angle2 = atan2(dy, dx);
x = x2 + cos(angle2) * segLength;
y = y2 + sin(angle2) * segLength;
segment(x, y, angle1);
segment(x2, y2, angle2);
void segment(float x, float y, float a) {
pushMatrix();
translate(x, y);
rotate(a);
line(0, 0, segLength, 0);
popMatrix();
//update(x, y);
}
Answers
Your sample doesn't show us the value of segLength, x, y , x2 or y2. Post the full code.
the code dont work no more because i was changing variables around looking to change the size and i try to ctr R and hit ctr S instead, so no full code float segLength = 180; float x, y, x2, y2;
Okay, weird because you seemed to have removed the setup and draw method, that makes no sense, you always need those.
To answer your original question, it was x2 and y2 who defined the point of origin. So somewhere in your code they must've been defined. Otherwise it would've started in the top left corner. Where did you get this code?
Anyway, this code should work. This defines a class for tracking arm, letting you easily define more than one, all with the same correct behavior.
If you don't understand it I recommend reading a couple of tutorials on objects and classes. It makes everything easier in the long run, but it takes a moment to get used to it. Good luck.
@alex_d thanks this what i was looking for though i did not think it through at first this is not really the look i was looking for, i guess this look a bit uncanny lol maybe the what would be the shoulders is a bit it high??? in my original post you can see im using the video cam as a visual point of ref "me simulating a human point of view" kinda like VR goggles? you field of view and then theirs you're arms and legs (this is what im looking to replicate) i do have a 3D obj model of this model i made in autoCAD and want to import into this sketch but not sure how to make those arms stick to the sketch you did? any ideas on that type of work flow? any examples on that?
also how can i extend the arm or segment? your arms aren't really finger tip to finger tip like the one from my 3D model
AS FOR YOUR QUESTIONS:
yes i did for posting but what i did have was based on me guessing not the original meaning the original was lost during me guessing arbitrary value and saved it rather then save a new copy.
i found it in processing examples tab, not sure which lib as this was last summer.
Well, you can change the positioning of the arms I made by looking at the constructor for the object:
TrackingArm(float xOrig, float yOrig)
Look atvoid setup()
where it saysRight now I used the
width
andheight
variables that are built into processing, that way you only have to define your sketchwindow's size insize(w,h)
I'm not sure about importing a 3D model into Processing. I've only generated and exported 3D stuff with Processing. I think Unity is a lot easier for working with existing 3D models but I don't know if you can easily use webcam feeds there..
If you do manage to import the obj correctly, I think it might be easiest to import the upper- and lower arm separately and then translating them based on these variables:
float xOrigin, yOrigin, x, y;
Currently,mouseX
andmouseY
are used to define the target of the arms. But I'm guessing you might want to track something else than your mouse? So you would need to change that variable by another one in the code and assign the correct value invoid draw()
To get a more realistic effect, I would really try to somehow do this in Unity because it has easy support for 3D models and built in Inverse Kinematics http://docs.unity3d.com/Manual/InverseKinematics.html And it might be easier for you if you're already familiar with 3D software. Just gotta check if they have cam support.
@alex_d thanks i just noticed what you pointed out in the code ill see if i can re position, NOW is their a way to have the arm travel in the z direction ? im asking since you made the class "cant wait till i know how to do what you just did"
=
(make a class from just a portion of what was left of the original code) as in now the arm are traveling on x&y so whats up with the Z?as for your rest of the unity comments/statements i will say that i stay away from unity's engines my work flow is very specific "Arduino, Processing ,Visual Studios2013, Fusion360 by AutoDesk then 3D printing" they all provide whats needed of my project.
YES i do have a actual Humanoid Android i been modeling for awhile now and is fully printable so every model is piece by piece "shells/face plates" so yes i will be importing the shoulder alone and so on for the bicep elbow forearm and hand itself. there is a lib called
objloader.*;
and i have imported one of my dual motor aircraft but im not sure how the whole moving happens tho i do see the code.this is what i hope to have it look like at the end
and yes i been working on algorithms for tracking obj and faces fingers and eyes gaze and i have had some help with pointers from this site just like you are pointing things out to me but one step at a time. as you can see by the ship image i know how to bring in obj i just dont know how to make those import be part of a already working sketch like the one you just made maybe with my new sketch i just uploaded of the Xwing emu maybe you can see how i imported and figure out how would you go about making that ship follow those coordinates or constrains you did to your class
UPDATE: dam i just try to upload the obj files just incase but theres no options to upload such
@alex_d i just noticed that altho you made a class for the arm this arms dont have individuality, so how do we go about giving a arm its own movements independent from the other ? i tried using 2 mouse on the same pc and one of the mouse is being ignored by the arm no type of control it only moves with one mouse dont matter which mouse but it will be the first one to move across the draw window
you can simulate it with mouse left
and cursor keyboard right arm
@Chrisir the whole entire point is to liberate you from the entire computer space and its Human Interface Devices
I know
lol then if i have to use the mouse and the keyboard im not really liberated, thats constrained
Yes
Do you want to use kinect?
The point is that Chrisir showed you how to change the code and make them move independently based on method argumends, in this case
drawArm(float mx, float my)
. That's why he said 'you can simulate it'.Right now, the code is simply using mouse and keyboard as a placeholder. If you want it to follow your hands on camera you need to work with Kinect or some kind of blob detection and feed that x & y data into the method's arguments.
If you want to be able to write code like this, I suggest you work on your basics first. I also tried learning by doing, but a lot of these things will only make sense when you understand the fundamentals of Java and Object Oriented Programming (OOP). I recommend you do this course: https://www.udacity.com/course/intro-to-java-programming--cs046 or something similar. It's a bit boring at times but I guarantee you will understand Java & Processing a LOT better afterwards.
I personally don't know how to translate this code to 3D space, that's why I was suggesting Unity since it does inverse kinematics for you. (ie. you give the target to the code and it will move the arm correctly to that point). So look into "inverse kinematics algorithms/theory" if you want to do it yourself in processing. Will be math heavy though. There's no reason why it isn't doable though. And if you have a kinect you can even get the x y z values from your hands etc.
Thanks for helping
If you want to use kinect you could re-post my code in the kinect section of this forum and ask for guidance there
guys im using a regular webcam thats it, and what im looking todo can be done even without a kinect "you just have to make up for what is being lacked by doing more coding" as for the comment made about IK/FK i know about this techniques and i will tell you that i have NO issues doing everything IK does without using the heavy math involved using C++ in Arduino for regular DC motors and Servos as well.
@Chrisir i see what you did so since your just doing placeholders like Alex said then how would i go about using a second mouse? as in how do input that into the sketch ? i dont think is done the same way we are calling THIS camera while making a object out of a class Video ?
with this algorithm im able to use all of this mouses with no issues and i can even use my eye to move one of these mouse while others with my hand and others with my face similar to how Alex described the whole this about placeholder.
i can tell you this code cant be adopted work in Processing unless we build classes and obj for all of this and even so i feel this mystery about Java and their lib, is like Processing hides things from the user where as in Arduino is easy to access the lib H files Cpp files and so on, enough of how i feel about Java in Processing.
as for this sketch we been talking about width and height should serve WELL with depth while X&Y will suffice for moving/panning on 2D space while W&H will be good for +/- in 3D space "i already did this with Processing and Arduino with Servos and DC motors on another application, SO that being said what im looking to do here is no diff at all, this is just a simulator if anything.
as you can see i already did the whole obj uploading using the obj lib and mapped the obj arms "4 obj model per arm" im working on the XML for hand recognition so that i can map my hands to the simulators obj's since i dont find anything in openCV for processing where someone already did the hand harrcascade files or at least a finger xml, i just need to work out the height and width of this sketch so that i can get my translation in the Z axis for the3D space
I can't help you with that
draft is not clearing after you post
@Chrisir how do i add a 3rd limb ? i would like to know what to consider when rotating or translating on Z while being able to rotate on x&y "you know' like our hands"
??
do you mean z as in 3D
@Chrisir yes sir...
Ask alex_d
Like 2 Segments on each side but in 3D?
yes, i mean they are arms so they should be able to translate in Z "closer to screen or farther away from screen" i have a code somewhere from this company named DoBOT ? i think is called and is a robotic arm like the kuka and they used processing to make the arm move about in xy and z so it is possible
@alex_d have you have any clue ?
How do you intend to capture the depth data from your hands on a regular webcam? This is not easy, just capturing the x y position of your hands alone is gonna be quite hard. That's why I'm suggesting Kinect, so you have an easy way of getting the z data.
And sorry, I don't know how to turn this code into 3D or how to add a limb, not my expertise.
And if you want to use a separate mouse, this might work: http://www.lagers.org.uk/gamecontrol/index.html
thanks Alex, maybe i can use the cross hair of the xbox control altho i will not be physically touching any remotes or mouse, BUT you asked how will i be getting Z? well doing what you said you call hard hard is not a reason to not do something now you know and the fact that you even knew about the x&y suggest you know more then what your expertise is saying lol
Because getting 2D info from a normal camera can be done with blob detection -> http://www.v3ga.net/processing/BlobDetection/ (but it needs high contrast, etc) so you can use that.
Getting depth data from a normal camera however, is not easily done, even impossible I'd say. There is no way for the camera to know which pixel is further than the other. That's why they invented 3D cameras.
When I say not my expertise, I mean my math isn't good enough for that :p
Jay, buy a kinect
well my math is good so if thats what it takes then im going to work out the algorithms for depth thanks tho
No I meant you need math to add a 3d limb..
For calculating depth from a normal camera maybe you could use some kind of photogrammetry technique
But I really don't know anything about how that works, so you're on your own there. Good luck man, prove us wrong :)
there is a lib for image recognition called opencv
lol funny Chris , but hey thanks for that link Alex.
funny? Why is it funny?
because i know about opencv and i dont see how is opencv is going to do anything easier? or work for that matter we are adding obj files here trying to translate in 3d space and track hands .
doesn't opencv allow recognition of hands maybe?
yeah its basically the same as blobdetection...
anyway look at this: https://www.reddit.com/r/Unity3D/comments/4ifaj8/leap_motion_updated_my_hand_pose_classifier_to/
@alex_d
clearly there was no point in sharing this link, tho i will say i do have a leapMotion but it will not work for me because this application is not for anyone asses to be seating next to the pc or near application and to use the leap you have to be close to a range.
i mean com'on his clearly just showing off it even says it
Show-Off
@Chrisir yes it does But no one has share or made any xml file for such hand.
can't believe no one has said "gee why don't we make a hand xml" ridiculous serious now?!
so far this is what i found so far.
i mean are you shitting me someone actually took the time to make a clock cascade ??? really lol
Are those 3D Models?
lol how should i know chris? im the one in question and as for the files, well those ext arent 3D models last time i checked, besides why would opencv have anything to do with 3D modeling obj's?
wait are you ref to the red arms in the video feed? if so yes those are obj files