From f64d0d0154d6862f995c66416136b9477a54e530 Mon Sep 17 00:00:00 2001 From: yjxiong Date: Thu, 28 Apr 2016 21:41:14 +0800 Subject: [PATCH] add tool to extract warp --- CMakeLists.txt | 3 +++ tools/extract_warp_flow_gpu.cpp | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tools/extract_warp_flow_gpu.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cb05977..ad794ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,3 +32,6 @@ target_link_libraries( extract_cpu ${OpenCV_LIBS} ${LIBZIP_LIBRARY} denseflow) add_executable( extract_gpu tools/extract_flow_gpu.cpp) target_link_libraries( extract_gpu ${OpenCV_LIBS} ${LIBZIP_LIBRARY} denseflow) + +add_executable( extract_warp_gpu tools/extract_warp_flow_gpu.cpp) +target_link_libraries( extract_warp_gpu ${OpenCV_LIBS} ${LIBZIP_LIBRARY} denseflow) diff --git a/tools/extract_warp_flow_gpu.cpp b/tools/extract_warp_flow_gpu.cpp new file mode 100644 index 0000000..d0bb92f --- /dev/null +++ b/tools/extract_warp_flow_gpu.cpp @@ -0,0 +1,47 @@ +#include "dense_flow.h" +#include "utils.h" + +INITIALIZE_EASYLOGGINGPP + +using namespace cv::gpu; + +int main(int argc, char** argv){ + // IO operation + const char* keys = + { + "{ f | vidFile | ex2.avi | filename of video }" + "{ x | xFlowFile | flow_x | filename of flow x component }" + "{ y | yFlowFile | flow_y | filename of flow x component }" + "{ b | bound | 15 | specify the maximum of optical flow}" + "{ t | type | 0 | specify the optical flow algorithm }" + "{ d | device_id | 0 | set gpu id}" + "{ s | step | 1 | specify the step for frame sampling}" + "{ o | out | zip | output style}" + }; + + CommandLineParser cmd(argc, argv, keys); + string vidFile = cmd.get("vidFile"); + string xFlowFile = cmd.get("xFlowFile"); + string yFlowFile = cmd.get("yFlowFile"); + string output_style = cmd.get("out"); + int bound = cmd.get("bound"); + int type = cmd.get("type"); + int device_id = cmd.get("device_id"); + int step = cmd.get("step"); + + vector > out_vec_x, out_vec_y; + + calcDenseWarpFlowGPU(vidFile, bound, type, step, device_id, + out_vec_x, out_vec_y); + + if (output_style == "dir") { + writeImages(out_vec_x, xFlowFile); + writeImages(out_vec_y, yFlowFile); + }else{ +// LOG(INFO)<<"Writing results to Zip archives"; + writeZipFile(out_vec_x, "x_%05d.jpg", xFlowFile+".zip"); + writeZipFile(out_vec_y, "y_%05d.jpg", yFlowFile+".zip"); + } + + return 0; +}