{"id":20804727,"url":"https://github.com/wizyoung/optical-flow-gpu-docker","last_synced_at":"2025-05-07T03:47:21.609Z","repository":{"id":108074240,"uuid":"159514158","full_name":"wizyoung/Optical-Flow-GPU-Docker","owner":"wizyoung","description":"Compute dense optical flow using TV-L1 algorithm with NVIDIA GPU acceleration.","archived":false,"fork":false,"pushed_at":"2018-11-29T07:15:41.000Z","size":5,"stargazers_count":59,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T03:47:16.922Z","etag":null,"topics":["cuda","gpu","optical-flow","tvl1"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wizyoung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-28T14:24:50.000Z","updated_at":"2024-12-19T04:00:06.000Z","dependencies_parsed_at":"2024-07-07T00:30:45.795Z","dependency_job_id":null,"html_url":"https://github.com/wizyoung/Optical-Flow-GPU-Docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizyoung%2FOptical-Flow-GPU-Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizyoung%2FOptical-Flow-GPU-Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizyoung%2FOptical-Flow-GPU-Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizyoung%2FOptical-Flow-GPU-Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wizyoung","download_url":"https://codeload.github.com/wizyoung/Optical-Flow-GPU-Docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810275,"owners_count":21807759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","gpu","optical-flow","tvl1"],"created_at":"2024-11-17T19:11:17.121Z","updated_at":"2025-05-07T03:47:21.603Z","avatar_url":"https://github.com/wizyoung.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Optical-Flow-GPU\nCalculate dense optical flow using TV-L1 algorithm with NVIDIA GPU acceleration. The CPU version is also included. [Dockerhub link](https://hub.docker.com/r/wizyoung/optical-flow-gpu/)\n\nDocker image environment: OpenCV 2.4, CUDA 8, cuDNN 5.\n\nThe dense flow C++ source code for building is from [yjxiong/dense_flow](https://github.com/yjxiong/dense_flow). The docker image is based on [willprice/opencv2-cuda8](https://hub.docker.com/r/willprice/opencv2-cuda8/). If you want to build opencv with cuda support yourself, you can refer to this [dockerfile](https://github.com/dl-container-registry/opencv2/blob/master/Dockerfile).\n\n**Requirements**: docker, nvidia-docker. If you have libseccomp2 version conflict problems when installing docker on ubuntu, you can refer to this [solution](https://stackoverflow.com/a/53481527/6631854).\n\n### Usage\n\n#### 1. Directly use the prebuilt binaries (no multi gpu support)\n\n```shell\nextract_cpu [OPTION] ...  # using cpu\nextract_gpu [OPTION] ...  # using gpu\nextract_warp_gpu [OPTION] ...  # using gpu to extract warp flow\n```\n\nAvaliable options:\n\n- `-f`: video path.\n- `-x`: filename of flow x component.\n- `-y`: filename of flow y component.\n- `-i`: filename of extracted RGB image.\n- `-b`: boundary to clip the flow value. For example, `-b 20` means clip the flow value beyond [-20, 20] and maps the [-20, 20] interval to [0, 255] in grayscale image space.\n- `-t`: flow calculation method. 0: Brox, 1: TVL1. \n- `-s`: step for frame sampling. 1 means no skipping frame in calculation.\n- `-d`: gpu id.\n- `-w`, `-h`: resize the image **before** flow calculation. w = resized_width, h = resized_height. 0 means no resize. Note: If you want to resize the image, w and h must be both specified to take effect.\n- `-o`: output format. 'dir' means saving the flow image data in directory format. 'zip' means saving the flow image data in zipped file format.\n\nExample:\n\n```shell\n# first mount the folder containing videos to /data\nnvidia-docker run -it -v path_to_mount:/data wizyoung/optical-flow-gpu bash \nmkdir /data/result\n# RGB image data is abandoned here\nextract_gpu -f /data/video.mp4 -x /data/result/flow_x -y /data/result/flow_y -i /dev/null -b 20 -t 1 -s 1 -d 0 -w 100 -h 100 -o zip\n```\n\nResult:\n\n```shell\n# path: /data/\n.\n├── result\n│   ├── flow_x.zip\n│   └── flow_y.zip\n└── video.mp4\n```\n\n#### 2. Batch processing using python script with multi gpu support\n\nI included the python wrapper script with multi gpu support in the `/src` path:\n\n```shell\nroot@eca86f630747:/src# python multi_gpu_extract.py -h\nusage: multi_gpu_extract.py [-h] [--flow_type {tvl1,warp_tvl1}]\n                            [--out_fmt {dir,zip}] [--num_gpu NUM_GPU]\n                            [--step STEP] [--keep_frames KEEP_FRAMES]\n                            [--width WIDTH] [--height HEIGHT] [--log LOG]\n                            vid_txt_path out_dir\n\nExtract optical flows with multi-gpu support.\n\npositional arguments:\n  vid_txt_path          Input txt files containing video paths.\n  out_dir               Destination directory to store flow results.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --flow_type {tvl1,warp_tvl1}\n                        Optical flow type. Default: tvl1\n  --out_fmt {dir,zip}   Output file format. Default: zip\n  --num_gpu NUM_GPU     Number of GPUs. Default: 4\n  --step STEP           Specify the step for frame sampling. Default: 1\n  --keep_frames KEEP_FRAMES\n                        Whether to save RGB frame data. Default: False\n  --width WIDTH         Resize image width. Default: 0 (no resize)\n  --height HEIGHT       Resize image height. Default: 0 (no resize)\n  --log LOG             Output log file path. Default: ./out.log\n```\n\nNOTE: \n\n(1) `vid_txt_path` should be a txt file each line containing a video path. \n\nExample:\n\n```shell\n# NOTE: /data/ is the mounting point rather than the actual path\n# vid_txt_path: /data/video_list.txt\n/data/videos/1.mp4\n/data/videos/2.mp4\n/data/videos/3.mp4\n...\n```\n\n(2) `num_gpu` means using gpus from 0 to num_gpu - 1.\n\n(3) The log file records the processing progress and error (likely corrupted videos) during processing. \n\nExample:\n\n```\npython multi_gpu_extract.py /data/video_list.txt /data/results --flow_type tvl1 --out_fmt zip --num_gpu 4 --step 1 --keep_frames True --width 100 --height 100 --log /data/log.log\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwizyoung%2Foptical-flow-gpu-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwizyoung%2Foptical-flow-gpu-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwizyoung%2Foptical-flow-gpu-docker/lists"}