opencv - Mapping frames based on motion -
i need create 3 intermediate frames between 2 frames (previmg, nextimg), have found out motion of each pixel using calcopticalflowfarneback()
function in opencv
calcopticalflowfarneback(gray1, gray2, flow, pyrscale, pyrlevel, winsize, iter, polyn, sigma, method);
then have created 3 intermediate frames calling function createnewframe(), following shift (func. argument) values 0.25, 0.5, 0.75
void createnewframe(mat & frame, const mat & flow, float shift, int & c, mat & prev, mat &next) { (int y = 0; y < mapx.rows; y++) { (int x = 0; x < mapx.cols; x++) { point2f f = flow.at<point2f>(y, x); mapx.at<float>(y, x) = x + f.x/shift; mapy.at<float>(y, x) = y + f.y/shift; } } remap(frame, newframe, mapx, mapy, inter_linear); }
but not getting proper intermediate frames.. transition 1 frame other non smooth (flickering). problem in code ? need proper intermediate frames ? ?
i think should multiplying variable shift
, not dividing it.
try replacing double loop in function createnewframe
following one:
(int y = 0; y < mapx.rows; y++) { (int x = 0; x < mapx.cols; x++) { point2f f = flow.at<point2f>(y, x); mapx.at<float>(y, x) = x + f.x*shift; mapy.at<float>(y, x) = y + f.y*shift; } }
Comments
Post a Comment