I am currently working on a project that requires me to find the focus of expansion using optical flow.
I currently have the optical flow and am using the formula from pages 13-14 this paper:
http://www.dgp.toronto.edu/~donovan/stabilization/opticalflow.pdf
I take two frames from a video and find pyramids from both using buildOpticalFlowPyramid then find the keypoints using goodFeaturesToTrack. Using these I then calculate the sparse optical flow with calcOpticalFlowPyrLK. All three of these methods are provided by OpenCV.
The problem I have hit is that I need both the flow vector for each keypoint in the image to fill the A and b matrices. Would the pixel value be just the location of the keypoint in the original image? And then the flow vector is the difference between the initial location and new point?
Yes, that is precisely so. Using the terms/variables as per the paper and the following link,
http://docs.opencv.org/modules/video/doc/motion_analysis_and_object_tracking.html#calcopticalflowpyrlk
p_i = (x,y) are the prevPts (points in the original image),
v = (u,v) are the flow vectors obtained by subtracting points in prevPts from those in nextPts.
Related
I use opencv to calculate optical flow between 2 images (frame_t and frame_t+1). Then I want to use optical flow to warp frame t to get warped_frame_t+1. The warping function is F.grid_sample (pytorch). Since the range of grid in F.grid_sample is (-1,1), I need to normalize optical flow. But How should I do the normalization? What is the range of optical flow in an image? Is it in the range of (-w+1,w-1) (-h+1,h-1)?
np.meshgrid(np.linspace(-1,1,W), np.linspace(-1,1,H))
I am currently working on a camera 3D realsense camera that detection and calculate the box or boxes dimension.
I am new in computer vision. I first worked on i just work on detection objects detection with color or without color to get a basic understanding. Using C++ and openCV, I want to managed to get the corners (and their x y z pixel coordinates) of the square using smoothing (remove noise), edge detection (canny function), lines detection (Hough transform) and lines intersection (mathematical calculation) on an simplified picture (uniform background).
Now is my question: do you have any direction/recommendation/advice/literature about dimension calculation of box. https://www.youtube.com/watch?v=l-i2E7aZY6A
i am using c++ and opencv with Intel realsens 3D camera.
thanks in advance((-_-))
Once you have the colour image pixel coordinates of the box you can obtain the real-world coordinates (also known as vertices or camera coordinates in the documentation) using methods in the projection interface, then simple pythagoras to calculate the distance between the points in mm.
If you have no experience with RealSense I'd recommend reading the documentation and looking through the sample apps included with the SDK.
With PCL (Point Cloud Library) you can find planes (or spheres and other surfaces), then refine the result with 2D image processing (eg. edge detection).
http://pointclouds.org/
https://www.youtube.com/watch?v=VD044WAHEe4
I need to read the displacement of each pixel in each stage using the Optical flow - Simple Flow tracking algorithm.
I tried the code mentioned here:
How to make Simpleflow work
The code works fine. However, I don't know what does the flow array contain because its values have a strange format, does it contain the displacement or the new position of the pixel or non of them? And is there any way to read these values in order to track the pixel?
Thanks!
After readin their paper SimpleFlow: A Non-iterative, Sublinear Optical Flow Algorithm, authors clearly state that the resulting flow matrice contains the displacement of the pixel, i.e. the pixel p1 in the Ft image is at the position (x,y), and the position of p1 in the Ft+i is (x+u, y+v), (u,v) are the values saved in the resulting flow matrice for each pixel from Ft.
Currently I am working on 3D image visualizing project using C# and emgucv.net. On that project following steps already done with 2 images of same scene(a little different in rotation and translation),
Feature detection(SURF), matching and calculate homography
calculate fundamental matrix
calculate essential matrix using above fundamental and camera intrinsic matrices
finally calculate the Rotational and translational matrices
Also I have obtain 4 possible answers for transformational matrix(3X4 [R|T]) using different combinations of R and T by changing its sign. Now I want to select the correct transformation matrix from those 4 answers. Before that I want to check either one of the answer is correct. So I have to re-project the points of second image using "Camera intrinsic matrix" and each one of "Transformation matrix". After that I can compare with resultant points with the second image points to confirm the result(translational matrix).
My question is, How to re-combine translational matrix(rotational[3X3] and translational[3X1] matrix ) and camera intrinsic matrix to project points into image points using emgucv.net?
OR any alternative method to confirm the transformational matrix that I obtain?
Thanks in advance for any help.
Problem: I'm trying to align two frames of a moving video.
I'm currently trying to use the function "cvCalcOpticalFlowLK" and the result outputs velocity vectors of x and y in the form of a "CvArr".
So I obtained the result, but i'm not sure how to use these vector arrays.
My question is this... how do i know what is the velocity of each pixel? Is it just the value of each pixel value at that particular point?
Note: I would've used the other optical flow functions such as cvCalcOpticalFlowPyrLK() as it is much easier, but i want the dense optical flow.
Apparently my original assumption was true. The "velx" and "vely" outputs from the optical flow function are the actual velocities for each pixel value. To best extract them, I accessed the pixel from the raw data and pulled the value. There are 2 ways to do this.
cvGet2D() -- this way is slower but if you only need to access 1 pixel it's okay.
or
(uchar*)(image->imageData + height*image->widthStep + width);
(image is an IplImage, width and height are just the corresponding widths and heights of the image)
If you need the motion vectors for each pixel, then you need to compute what's called 'dense optical flow'. Starting from openCV 2.1, there is a function to do exactly that: calcOpticalFlowFarneback.
See the link below:
http://opencv.itseez.com/modules/video/doc/motion_analysis_and_object_tracking.html?highlight=calcopticalflowfarneback#cv2.calcOpticalFlowFarneback
velx and vely are optical flow not the actual velocity.
The method you used is Obsolete. Use this calcOpticalFlowFarneback()