3
$\begingroup$

Dear citizens of Stackexchange,

I am a 3rd grade Electrical and Electronics Engineer student, who is working on an image processing project using OpenCV 3.2 and Python 2.7.

What we would like to accomplish is to build up a system which can compensate the camera using Lucas Kanade's Optical flow method.

On the sample that was presented on the OpenCV's website, one of the inputs of the function calcOpticalFlowPyrLK() was cv2.goodFeaturesToTrack.

I wanted to change that input to an output I have acquired from my another function. But the outputs of those two functions are mainly different in type.

What I would like to ask is, what type of topology is the following output format (matrix, array, etc.) that we get from cv2.goodFeaturesToTrack()?:

[[[ 582.  408.]]
 [[ 453.  373.]]
 [[ 483.  395.]]
 [[ 447.  298.]]
 [[ 589.  371.]]
 [[ 436.  358.]]
 [[ 624.  370.]]
 [[ 624.  413.]]
 [[ 470.  395.]]
 [[ 635.  378.]]
 [[ 630.  417.]]
 [[ 498.  395.]]
 [[ 427.  354.]]
 [[   6.  325.]]
 [[ 566.  381.]]
 [[  20.  323.]]
 [[ 532.  400.]]
 [[ 568.  374.]]
 [[ 457.  321.]]
 [[ 460.  413.]]
 [[ 471.  317.]]
 [[ 524.  399.]]
 [[ 586.  417.]]
 [[ 251.  184.]]
 [[ 289.  428.]]
 [[ 435.  342.]]
 [[ 635.  393.]]
 [[ 590.  387.]]
 [[ 160.   20.]]
 [[ 431.  296.]]
 [[ 449.  324.]]
 [[ 439.  371.]]
 [[ 466.  372.]]
 [[ 481.  465.]]]
$\endgroup$
1
$\begingroup$

The cv2.goodFeaturesToTrack() is mainly used for detection of corners. See THIS PAGE

If you observe the type of the value returned by cv2.goodFeaturesToTrack(), it is numpy.ndarray, which is a multi-dimensional array according to THIS DOCUMENT

So the function cv2.goodFeaturesToTrack() returns all the locations of the corners present in the gray scale image.

This is what a typical output would look like, the corners are marked in blue:

enter image description here

$\endgroup$
  • $\begingroup$ Thank you for the answer and sorry for the late response. I will go on with my research to find a way to convert the results i find from "mog2" function to the 3D array format, Cheers, $\endgroup$ – Archura Feb 6 '17 at 10:32
1
$\begingroup$

Since computing the optical flow for the whole image pixels is computationally immense, it it preferred to compute optical flow only around feature points. This method is called sparse optical flow. The first function i.e calcOpticalFlowPyrLK, computes sparse optical flow of the video around feature points you provide with the second function i.e cv2.goodFeaturesToTrack. The output type of cv2.goodFeaturesToTrack is simply a 3D array.

$\endgroup$
  • $\begingroup$ Thank you for the detailed answer which quite helpful. This will actually lead me to search for a method to convert the features i detect via "mog2" function into the 3D array format. Cheers, $\endgroup$ – Archura Feb 6 '17 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.