How to sample image into 10*10 grid and select every center pixel and store in a vector for further processing?
I want to take center pixel of 10 10 grid for finding corresponding locations of pixels between two consecutive frames. I have written code but getting error. here is the snap of selecting center pixel of grid 1010:
int width = img.cols;
int height = img.rows;
int g_size = 10;
Point2f points;
for(int i =0; i< width/g_size-1;++i){
for(int j =0; j< width/g_size-1;++j){
points.x = i* g_size + g_size/2;
points.y = j* g_size + g_size/2;
}
img_corners.push_back(points);
}
img_corners.push_back(points);
vector<uchar> features_found;
features_found.reserve(maxCorners);
vector<float> feature_errors;
feature_errors.reserve(maxCorners);
calcOpticalFlowPyrLK( img, prevImg, img_corners, prevImg_corners,
features_found, feature_errors ,Size( win_size, win_size ), 3,
cvTermCriteria( CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 10, 0.3 ), 0, k);
Can any one help please. Thanks