modified farneback sample to use T-API

This commit is contained in:
Vadim Pisarevsky 2014-08-08 22:45:07 +04:00
parent 0224a20ff6
commit 68305703bd

View File

@ -37,7 +37,8 @@ int main(int, char**)
if( !cap.isOpened() )
return -1;
Mat prevgray, gray, flow, cflow, frame;
Mat flow, cflow, frame;
UMat gray, prevgray, uflow;
namedWindow("flow", 1);
for(;;)
@ -45,10 +46,11 @@ int main(int, char**)
cap >> frame;
cvtColor(frame, gray, COLOR_BGR2GRAY);
if( prevgray.data )
if( !prevgray.empty() )
{
calcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
calcOpticalFlowFarneback(prevgray, gray, uflow, 0.5, 3, 15, 3, 5, 1.2, 0);
cvtColor(prevgray, cflow, COLOR_GRAY2BGR);
uflow.copyTo(flow);
drawOptFlowMap(flow, cflow, 16, 1.5, Scalar(0, 255, 0));
imshow("flow", cflow);
}