Skip to content

Commit

Permalink
add tool to extract warp
Browse files Browse the repository at this point in the history
  • Loading branch information
yjxiong committed Apr 28, 2016
1 parent a128881 commit f64d0d0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -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)
47 changes: 47 additions & 0 deletions 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<string>("vidFile");
string xFlowFile = cmd.get<string>("xFlowFile");
string yFlowFile = cmd.get<string>("yFlowFile");
string output_style = cmd.get<string>("out");
int bound = cmd.get<int>("bound");
int type = cmd.get<int>("type");
int device_id = cmd.get<int>("device_id");
int step = cmd.get<int>("step");

vector<vector<uchar> > 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;
}

0 comments on commit f64d0d0

Please sign in to comment.