[Solved] What is this bit of code doing?


self.tracks seems to be an (n,2) list. The outer loop takes each of these values, turns them two by two into integers x and y, then performs a function/method cv2.circle with an object mask and several other parameters. container[-1] indicates that you want the value of the last index of container.

The values of the function/method goodFeaturesToTrack are assigned to p(which seem to be an array or None). ** indicates that feature_params is a dictionary of parameters(if a function is defined as myfunc(a,b=2,c=3,d=5) you could change some of these values for that
function call by calling myfunc("value of a",**mydict) with mydict being a dictionary containing zero or more of the optional variables a, b and c (eg mydict={'b':8,d:0} would change b and d from their default values to 8 and 0 respectively.

a new (float-valued) x and y are then extracted from a reshape of p and appended back to the list self.tracks as a pair.

The -1 in the reshape indicate that you dont care about how long the given axis as long as the other axis has the right shape. eg. an array of 10 values would be reshaped to (5,2) a (4,4) would be reshaped to (8,2) etc. This could have been found by searching for numpy.reshape:

newshape : int or tuple of ints

The new shape should be compatible with the original shape. If an >integer, then the result will be a 1-D array of that length. One shape >dimension can be -1. In this case, the value is inferred from the length of >the array and remaining dimensions.

solved What is this bit of code doing?