Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Possible to see Optical Flow output?

I hope this doesn't sound too crazy, but I want to see what the optical flow looks like to make sure I know what it is seeing in a sense. The following doesn't work because opt_flow is a 2 channel float Mat. Is opt_flow even a Mat that you can visually display?

cv::Mat opt_flow;
cv::Mat gray, prevGray;
cv::Ptr<cv::DenseOpticalFlow> tvl1 = cv::createOptFlow_DualTVL1();

cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY);
if(prevGray.empty()){
   gray.copyTo(prevGray);
}

tvl1->calc(prevGray,gray,opt_flow);
cv::imshow("Opt Flow", opt_flow);
cv::swap(prevGray, gray);