determine correct place using homography matrix (AR) - c#

I use surf in emgu cv lib to detect and recgnize my object i need to insert 3d model in the place of this object i have the homography matrix what i want to know is how to get modelview matrix of sharpgl from this homography matrix .i want steps that can result me the correct modelview matrix where i can place the 3d object
any answer will help me
thanks in advance

Take a look at AForge.net. The author of that library did something very similar using glyphs and then inserting his own 3D model in place of the glyph. The library handles the 3d pose of the glyph and applies those to the 3d model. The project can be found here
http://www.aforgenet.com/projects/gratf/
I dont know how you would do this same thing with Open CV and Emgu.

You should simply calibrate your camera using Zhang's method to get camera matrices and then use H decomposition as described in the link you found.
To sum up:
Perform Classical checkboard corner detection (emgucv code here)
Increase corner detection accuracy to subpixel level invoking FindCornerSubPix() function
Finally use CameraCalibration.CalibrateCamera() to calculate the intrinsic camera parameters
Hope this helps

Related

How do I convert a set of lines that are not intersecting into a maintainable polygon (triangle)?

I have an application I'm working on that requires a fair amount of 3D graphics programming. I have a series of lines that create both text and 3D cylindrical holes (see images).
I would like to be able to click and drag the objects in question using my mouse through the X,Y plane (Z constant). My understanding is that in order for the bounding boxes to be setup correctly, I have to have everything in using 3D polygons (triangles). I would like to be able to do collision detection without this conversion. Is this possible? If I must convert, can anyone point me to a piece of code that does this rather painlessly?
You can treat each line segment as a cylinder, and check them for collision.
Here's the math, as well as more alternatives.

about wiimote wrapper class

I'm interested in how this is working and looked at the code. The important part is the warp matrix construction done using the computeSquareToQuad and computeQuadToSquare functions, but I don't understand them. Can you do an explanation or give some references about that?
These two methods are used for translating camera space coordination and display coordinates to each other (computeSquareToQuad for translating from camera coordinates to display and computeQuadToSquare for reverse of it),
When you look at the world through a camera, the result is a flat image and everything is distorted according to perspective rules. (for example squares transform into trapezoids). this distortion can be encapsulated by a warping matrix called a planar homography.
you essentially need a 3x3 matrix for calculation (note the normally 4x4 matrix is used because it can be easily integrated in 3D pipelines)
for more information have a look at
http://www.cs.utoronto.ca/~strider/vis-notes/tutHomography04.pdf
http://www.youtube.com/watch?v=fVJeJMWZcq8

multiple matrices in c# xna phone app

I've created the beginnings of a windows phone app. It's a mix of two popular online tutorials
http://rbwhitaker.wikidot.com/simple-3d-animation
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Terrain_from_file.php
The code I've made is here
http://pastebin.com/5VusJpB0
I've added some code to catch the use of the accelerometer but it's all going a bit wrong! The code I've copied from the two examples have both declared world, view and projection matrices. One set for aircraft model in rbwhitakers code and the other set for the terrain from riemers code. I believe the matrices are the problem but I don't quite understand how they work. I only need one camera view so I need to lose a view matrix and it only needs one projection declaration right so I need to lose another projection matrix?. I'm guessing they should both share the same world but have different positions in that world. Can somebody help a noob out and see the problem?!
Thank you.
You are on the right track to solving this. Both the terrain and the model (and any other drawn item) should share the same view and projection matrices. Each item, however, should have it's own world matrix.
The world matrix represents the individual item's position and orientation relative to world space.
Think of the view matrix as the camera's position and orientation in the world. In actuality it is an inverse of that, but can be thought of as that for mind's eye conceptualizing.
The projection matrix is somewhat analogous with a lens attached to the camera (the view matrix) as it modifies the way the world is seen from the camera's perspective.
Just as when viewing a movie you are looking at many actors or props at any given moment (each with it's own position and orientation (world matrix) in the scene), you view them through a single camera at a time (shared view matrix) which is fitted with a single lens at a time(the projection matrix)

matching Kinect's Skeleton data to a .fbx model in XNA

My question is about a school project that I'm working on.
It involves mapping 3D models of clothing (like a pair of jeans) on a skeleton
that is generated by my Kinect camera.
An example can be found here: http://www.youtube.com/watch?v=p70eDrvy-uM.
I have searched on this subject and found some related threads like:
http://forums.create.msdn.com/forums/t/93396.aspx - this question demonstrates a way using brekel for motion capturing. However, I have to present it in XNA.
I believe that the answer lies in the skeleton data of the 3D model (properly exported as a .FBX file). Is there a way to align or match that skeleton with a skeleton that the Kinect camera generates?
Thanks in advance!
Edit: I am making some progress. I have been playing around with some different models, trying to move some bones upward (very simple use of CreateTranslation with a float that is calculated on the elapsed game time), and it works if I choose the rootbone, but it doesn't work on some bones (like a hand or an arm for example). If I track al the Transform properties of that bone including the X, Y, and Z properties then I can see that something is moving.. However the chosen bones stays in it's place. Anyone have any thoughts perhaps..?
If you are interested, then you'll find a demo here. It has source code for using Real-time Motion capture using the Kinect and XNA.
I have been working on this off and on for a while now. A simple solution I'm using right now is you use the points the nui skeleton tracks to match to the rotations of various joints in a .fbx model. The fbx model will most likely have many more joints then what are tracked and for those you can just iterate a rotation.
The fun part:
The Kinect tracks skeleton joint position in skeleton space -1 to 1 while your models need rotations in model space. Both of them provide child position or rotation in relation with their parent bone in the hierarchy. Also the rotations you need for a .fbx model are around an arbitrary axis.
What you will need is the change from the .fbx model in its bind pose to the pose represented by the kinect data. To get this you can do some vector math to find the rotation of a parent joint around an arbitrary axis and rotate it accordingly then move on down the skeleton chain.
Say you have a shoulder we will call point a and the elbow we can call point b on the bind pose of the fbx model. We will have a point a' and b' on the skeleton.
So for the bind model we will have a vector V from the shoulder to the elbow.
V = b - a
The skeleton model will also have a vector V'
V' = b' - a'
So the axis of rotation for the shoulder will be
Vhat = V cross-product V'
The angle of rotation for the shoulder around Vhat
Theta = ((V dot-product V') / magnitude(V) ) * magnitude(V')
To you will want to rotate the shoulder joint on the fbx model by theta around Vhat.
The model may seem to flop a bit so you may have to use some constraints or use quaternions or other things that help it not look like a dead fish.
Also I'm not sure if XNA has a built in function to rotate around an arbitrary axis. And if someone could double check my math I'd appreciate it, I'm a little rusty.
The Kinect SDK delivers only points of body parts like head postion or right hand position. Seperately you can also read the depth stream from the Kinect sensor.
But currently the Kinect doesn't generate a 3D Model of the body. You would have to do that by yourself.
I eventually settled for the Digital Runes option (with Kinect demo), which was almost perfect apart from a few problems that I wasn't able to solve.
But because I had to hurry for school, we decided to turn the project around completely and our new solution did not involve the Kinect. The Digital Runes examples did help a lot though.

How do you transform a Skinned Mesh during mesh loading and processing?

I created my own skinned mesh loader. It's working fine, but my problem is I don't know how to transform (scale & rotate) the skinned mesh so that the transformations are "baked" onto the vertices. If it were just a geometry, transforming the vertices are a piece of cake, but now that skinning info is involved, if I do a scale for example, my mesh gets all stretched. I know I need to transform my skinning data too, but which parts? All the Bind Pose matrices? The Inverse Bind Pose Matrices? I can't seem to understand how to go about this.
My implementation is in C# & OpenTK and I am specifically loading Skinned Collada files exported from Blender 2.6.
Thanks in advance.
I don't know C# and OpenTK, but I try to help on the theoretical side. Vertices are transformed by weighted global transform matrix. To form a global transform, you need to concatenate local transform of each joints. To create a local transform, you need to concatenate the local translate, rotate and scale. The weight would come from the joint. So I think you need to get joint local rotation/translation/scaling of your bind pose, then manipulate those local matrix and form them to global matrix. After that, you apply weights to the global transformation then transform the vertices.
The following link may be similar to your question.
COLLADA: Inverse bind pose in the wrong space?
I created this collada file player, but use C++.
http://www.youtube.com/watch?v=bXBfVl-msYw

Categories

Resources