int main(
int argc,
char **argv)
{
string filename = samples::findFileOrKeep(parser.
get<
string>(
"@video"));
{
printf("ERROR: Cannot open file %s\n", filename.c_str());
return -1;
}
Mat prevgray, gray, rgb, frame;
char ret;
while(true)
{
cap >> frame;
if (frame.empty())
break;
cvtColor(frame, gray, COLOR_BGR2GRAY);
{
algorithm->calc(prevgray, gray, flow);
split(flow, flow_uv);
multiply(flow_uv[1], -1, flow_uv[1]);
cartToPolar(flow_uv[0], flow_uv[1], mag, ang, true);
normalize(mag, mag, 0, 1, NORM_MINMAX);
hsv_split[0] = ang;
hsv_split[1] = mag;
hsv_split[2] = Mat::ones(ang.
size(), ang.
type());
merge(hsv_split, 3, hsv);
cvtColor(hsv, rgb, COLOR_HSV2BGR);
imshow("flow", rgb);
imshow("orig", frame);
}
if ((ret = (char)waitKey(20)) > 0)
break;
std::swap(prevgray, gray);
}
return 0;
}
Designed for command line parsing.
Definition utility.hpp:890
T get(const String &name, bool space_delete=true) const
Access arguments by name.
Definition utility.hpp:956
void printMessage() const
Print help message.
n-dimensional dense array class
Definition mat.hpp:950
MatSize size
Definition mat.hpp:2447
bool empty() const
Returns true if the array has no elements.
int type() const
Returns the type of a matrix element.
Class for video capturing from video files, image sequences or cameras.
Definition videoio.hpp:727
virtual bool open(const String &filename, int apiPreference=CAP_ANY)
Opens a video file or a capturing device or an IP video stream for video capturing.
virtual bool isOpened() const
Returns true if video capturing has been initialized already.
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3