# OpenGL 2D Into 3D Problem

This topic is 2681 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've drew an N*N 3D Cubes using Opengl, and they were textured by a frame from the webcam using opencv. I would like to add motion tracking for the whole frame, for only specific cubes, based on that, the affected grid of cubes should move in/out in the Z Plane. I don't know what is the best approach for achieving that effect.

##### Share on other sites
Could you please explain the situation a little more thorough, I have no idea what you mean!

##### Share on other sites
OK, Suppose you have a matrix of cubes N*N, those cubes are textured using the web cam image, which is extracted by OpenCV , so that I can see my full Image on the N*N Cubes. Now I would like to extract from one frame, which parts of the tiles had movement, for example the 1*8 Matrix, that part of cubes should move out in the Z Plane and so on for other cubes. So the problem is how do I detect part of the webcam image for movement, then translate these information into movement of the cubes.

##### Share on other sites
Whatever you do is going to involve computing an optical flow vector field. The Wikipedia article describes a number of methods; I kind of like the Horn-Schunck method, though Lucas-Kanade is faster, and maybe more widely used. In the OpenCV documentation, see the functions whose names start with "cvCalcOpticalFlow," e.g. cvCalcOpticalFlowHS for Horn-Schunck or cvCalcOpticalFlowPyrLK for a souped-up version of Lucas-Kanade. You'll get as output motion vectors; see e.g. this Youtube video.

Once you have motion vectors, then you can combine them in various ways to determine how to move your cubes. Are you trying to move your cubes in and out along the z axis in some arbitrary way just to say "this area had motion," or are you trying to sort of "reconstruct" the 3d object from the video? If it's the former, then you have lots of easy options; e.g., you can compute an average, or find the largest motion vector, etc.

##### Share on other sites
@Emergent
Yes, I'm trying to move my cubes, just to say this area had motion.

##### Share on other sites
@Emergent
Yes, I'm trying to move my cubes, just to say this area had motion.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634088
• Total Posts
3015451
×