- Home /
OpenCV for unity Camera Motion Estimation via optical flow?
hi guys, im really really newbier with opencv for unity, i have 3.0.0 version and i want to do a camera motion estimation, i know how to do the optical flow estimation and i got rotation for the camera but it isn´t moving the camera and dont rotate arrown Z axis, now i dont have idea about camera reconstruction, can everyone tell me how can i calculate the movement over all points of optical flow?
i got some idea, first i need to get all prev & next points into an array, after i think that i need to calculate the motion across all points and pass te result to the transform. (rotation&position) of the camera to move it around the scene,
but how i said, i can just do the optical flow calculation but i dont have idea about how can i estimate all motion over all points
aside.
can someone translate this code from c++ to work with open CV for unity? there is in oter post:
https://docs.opencv.org/3.4/d5/dab/tutorial_sfm_trajectory_estimation.html
I would appreciate it a lot!!
thanks for take a time to read this question ;)
Answer by SunnyChow · Oct 26, 2018 at 05:50 AM
First, you shouldn't add reply unless you want to post your answer. For other people watching the main page, it looks like the question is answered.
Second, i don't think you will get a simple answer. Using just camera to calculate position/rotation is so difficult that some company's business isbased on it. SLAM is the technology you are probably searching. You can take a look on Kudan, VOID AR or EasyAR. ARKit/ARcore is in this category.
oh sorry man, ok i know that itsn't easy but can be done with open cv? or this is unuseful for my target? sorry angain for my bad english and for made these mistake answering my own question
i dont want calculate the motion via markless functions, i did mean, i dont want look over a picture with my camera to make the motion, i want to be free to move over all object infront of me
sorry, but i dont want AR apps, im working in an VR project for mobile and google cardboard oculus rift, i just want to walk around my bedroom and get some movement in my game via motion estimation over ALL trackable points infront of me, btw i wrote a code to calculate te optical flow, and to rotate the camera i get the sum of all points menus all prev points and it return a verctor2, to do rotation i've passed these vector2 to the eulerAngles of my main camera, and its work, but its just rotating over X and Y axis, so i want to do full rotation, and if its possible make motion too ;) but, i dont know how to do that via all points, i think, that i cant get the motion via: thisPoints - prevPoints, and rotation is more complex cuz i need to get the perspective between thisPoints and prevPoints, im getting this via optical flow, ImgProc.goodFeaturesToTrack() void from openCV for unity
The 3d camera position returned from SLA$$anonymous$$ IS the camera movement. Unfortunately the delay between camera signal to rendering is large thatit's uncomfortable for user (I have tried it with google cardboard and AR$$anonymous$$it)
by the way, is possible to translate / convert, the code from https://docs.opencv.org/3.4/d5/dab/tutorial_sfm_trajectory_estimation.html
to work in unity?
Your answer

Follow this Question
Related Questions
How to rotate an array of vectors over a normal vector 1 Answer
Physics without UnityEngine namespace 0 Answers
GameObject is null when assigning to non-monobehaviour public static class 1 Answer
How to add default behavior of OnDestroy function for all MonoBehavior scripts? 1 Answer
Unity3d Dragging object in 3d world 0 Answers