{"id":19066707,"url":"https://github.com/skp-1997/videostabilizationopencv","last_synced_at":"2026-05-13T20:31:49.939Z","repository":{"id":223062340,"uuid":"759219611","full_name":"skp-1997/videoStabilizationOpenCV","owner":"skp-1997","description":"The code is primitive attempt to achieve video stabilization using OpenCV and without Deep Learning approach. It uses foundational computer vision techniques like feature detections, optical flow, transformation and warping. ","archived":false,"fork":false,"pushed_at":"2024-02-18T20:32:20.000Z","size":28604,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T03:17:32.492Z","etag":null,"topics":["computer-vision","feature-detection","image-transformations","opencv","optical-flow","video-stabilization"],"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/skp-1997.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":"2024-02-18T01:11:53.000Z","updated_at":"2024-09-26T21:00:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"a1e10539-970d-4ab4-9c0e-68fae1bf54cf","html_url":"https://github.com/skp-1997/videoStabilizationOpenCV","commit_stats":null,"previous_names":["skp-1997/videostabilizationopencv"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/skp-1997/videoStabilizationOpenCV","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skp-1997%2FvideoStabilizationOpenCV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skp-1997%2FvideoStabilizationOpenCV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skp-1997%2FvideoStabilizationOpenCV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skp-1997%2FvideoStabilizationOpenCV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skp-1997","download_url":"https://codeload.github.com/skp-1997/videoStabilizationOpenCV/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skp-1997%2FvideoStabilizationOpenCV/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32999194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["computer-vision","feature-detection","image-transformations","opencv","optical-flow","video-stabilization"],"created_at":"2024-11-09T00:57:46.726Z","updated_at":"2026-05-13T20:31:49.919Z","avatar_url":"https://github.com/skp-1997.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Video Stabilization using Optical Flow\n\nThis code is simple attempt to stabilize (smoothen) a video using just traditional computer vision techniques using OpenCV. It's not best but will surely help learn many small concepts in computer vision like feature detection, optical flow, transformation and warping.\n\n# Demonstration:\n\n\n\nhttps://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/7abd54a9-cde6-4c06-968b-88dc28d48825\n\n\n\n\n\n\n\n\n# Steps for the Video Stabilization\n\n## [1] Detectng features from the frame\n\nHere, I am using 'goodFeaturesToTrack' from OpenCV to detect feature points\n\u003cimg width=\"600\" alt=\"Screenshot 2024-02-17 at 7 11 31 PM\" src=\"https://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/10f914a1-6df9-4a3b-b2df-38773ebf300b\"\u003e\n\n\n\n\n\n\n## [2] Calculating Optical Flow\n\nI am using 'calcOpticalFlowPyrLK' from OpenCV to calculate optical flow in concurrent frames from features ppints detected in previous frame. It uses Lucas-Kanade Pyramid method to calculate the pixel positions.\n\u003cimg width=\"614\" alt=\"Screenshot 2024-02-17 at 7 11 31 PM\" src=\"https://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/bcafc23b-33d9-47b4-b7b8-26cec5d2412b\"\u003e\n\n\n## [3] Estimate motion b/w two frames\n\nWith the help of 'estimateRigidTransform' module, I calculated the transformation values [x, y, theta] b/w frames.\n\n\u003cimg width=\"614\" alt=\"Screenshot 2024-02-17 at 7 11 31 PM\" src=\"https://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/db84705d-3e05-484c-bca6-3634ac6461f2\"\u003e\n\nTo get the idea of how it smoothen the curve, here is the picturization.\n\n\u003cimg width=\"615\" alt=\"Screenshot 2024-02-17 at 7 16 17 PM\" src=\"https://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/49f4a21f-f4e9-4fa8-bb63-4c5581d539da\"\u003e\n\n\n## [4] Calculate the smooth motion for entire video\n\nFirst, I use 'numpy.cumsum' to get trajectory for entire video, which later was used to smoothen the transformation using filtering.\nI am using 'MovingAverageFilter', the logic is defined below.\n\u003cimg width=\"615\" alt=\"Screenshot 2024-02-17 at 8 25 22 PM\" src=\"https://github.com/skp-1997/videoStabilizationOpenCV/assets/97504177/f048ea51-e11b-4f0f-aeb2-5743d9a1765b\"\u003e\n\n\nThe filter is applied trajectory matrix which smoothen values along translation along x, y and rotation along x direction. \n\n## [5] Warping using smoothen transformation matrix calculated before.\n\nUsing 'cv2.warpAffine' to wrap consecutive frames from the filtered trajectory matrix.\n\n\n\n## [6] Fixing the borders\n\nSince we are warping image, to maintain the frame size. This will led to some dead pixels along border which will be visible in the output video.\n\n\n# References:\n\n1. Video Stabilization Using Point Feature Matching in OpenCV - Abhishek Singh Thakur\nhttps://learnopencv.com/video-stabilization-using-point-feature-matching-in-opencv/\n\n2. Optical Flow in OpenCV (C++/Python) - Maxim Kuklin (Xperience.AI)\nhttps://learnopencv.com/optical-flow-in-opencv/\n\n3. CS231M · Mobile Computer Vision - Standford University\nhttps://web.stanford.edu/class/cs231m/lectures/lecture-7-optical-flow.pdf\n\n# Scope of Improvement\n\nThe method is primitive and doesn't work if there are objects moving in video at faster pace. The other approached would be to find where optical flow is maximum and compensate for that using mathematical logic or use deep learning model.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskp-1997%2Fvideostabilizationopencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskp-1997%2Fvideostabilizationopencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskp-1997%2Fvideostabilizationopencv/lists"}