{"id":16520067,"url":"https://github.com/pageauc/cam-track","last_synced_at":"2026-03-04T13:32:09.678Z","repository":{"id":74954747,"uuid":"70693757","full_name":"pageauc/cam-track","owner":"pageauc","description":"Windows, Unix, Raspberry Pi Computer python program to Track Camera X, Y Movements and Convert to Camera Pointing Position.  Useful for Stabilization or Robotics Course Correction","archived":false,"fork":false,"pushed_at":"2018-03-10T02:43:31.000Z","size":46,"stargazers_count":41,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T15:53:50.576Z","etag":null,"topics":["cam-track","camera-movement","camera-tracking","debian","motion-tracking","opencv-python","pan-tilt","python","raspberry-pi-computer","rpi-camera","search-rectangles","template-matching","threshold","tracking","unix","usb-cameras","video-stream","windows"],"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/pageauc.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}},"created_at":"2016-10-12T11:35:53.000Z","updated_at":"2025-03-06T02:59:33.000Z","dependencies_parsed_at":"2023-07-25T20:19:15.860Z","dependency_job_id":null,"html_url":"https://github.com/pageauc/cam-track","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pageauc/cam-track","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fcam-track","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fcam-track/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fcam-track/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fcam-track/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pageauc","download_url":"https://codeload.github.com/pageauc/cam-track/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fcam-track/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30081430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"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":["cam-track","camera-movement","camera-tracking","debian","motion-tracking","opencv-python","pan-tilt","python","raspberry-pi-computer","rpi-camera","search-rectangles","template-matching","threshold","tracking","unix","usb-cameras","video-stream","windows"],"created_at":"2024-10-11T16:49:28.697Z","updated_at":"2026-03-04T13:32:09.655Z","avatar_url":"https://github.com/pageauc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CAM-TRACK - Camera Movement Position Tracker Demo\n### Pan-Tilt Camera Position Tracker using python, opencv template matching. Runs on Windows, Unix using a Web Cam or Raspberry Pi Camera or Web Cam\n\n## Quick Install   \nEasy Install of cam-track onto Raspberry Pi or Debian Computer with latest Raspbian. \n\n    curl -L https://raw.github.com/pageauc/cam-track/master/cam-track-install.sh | bash\n\nFrom a computer logged into the RPI via ssh(Putty) session use mouse to highlight command above, right click, copy.  \nThen select ssh(Putty) window, mouse right click, paste.  The command should \ndownload and execute the github cam-track-install.sh for the raspberry pi camera pan-tilt tracker.  \nThis install can also be done directly on an Internet connected Raspberry Pi via a terminal session and web browser.      \nNote - A Raspbian apt-get update and upgrade will be performed as part of install \nso it may take some time if these are not up-to-date\n\n## Windows and Non RPI Unix Install\nFor Windows and Unix computer platforms(non RPI or Debian) ensure you have the most up-to-date\npython version see https://www.python.org/downloads/ for latest versions.  The latest versions\ninclude numpy and recent opencv that is required to run this code.  You will also need a USB\nweb cam installed and working.  To install this program access the GitHub project page at\nhttps://raw.github.com/pageauc/cam-track and select the green Clone or download zip option.\nthe files will be cloned or zipped to a cam-track folder.  You can run the code from\nconsole, gui desktop or from python IDLE application. \n \n## Manual Install   \nFrom logged in RPI SSH session or console terminal perform the following.\n\n    wget https://raw.github.com/pageauc/cam-track/master/cam-track-install.sh\n    chmod +x can-track-install.sh\n    ./cam-track-install.sh\n    cd rpi-cam-track\n    ./cam-track.py\n\n## Reference Links\nYouTube Video Demo https://youtu.be/yjA3UtwbD80   \nYouTube Video Code Walkthrough https://youtu.be/lkh3YbbNdYg   \nRPI Forum Post https://www.raspberrypi.org/forums/viewtopic.php?p=1027463#p1027463  \nGithub Repo https://github.com/pageauc/rpi-cam-track   \n    \n## Program Description\nThis is a Windows, Unix or Raspberry pi computer openCV2 program that tracks camera (pan/tilt)\n movements using opencv template matching. It requires a Video File, Web Cam, \n RPI camera module installed and working. The program is \nwritten in python2/3 and uses openCV2 or 3.  \n\n## How It Works\nCamera video stream (or video file) captures image frames then crops a search rectangle\nfrom the center of an image. It then locates the cropped image rectangle in subsequent\nimages based on a score value and returns the x y location in the image based on a\nthreshold accuracy. If movement gets too close to the sides of the image or\na suitable image search match cannot be found, then another search rectangle\nis selected. This data is processed to track a cumulative pixel location based on\nan initial camera image center value of 0,0. \n   \nThis code could be used for a simple robotics application, movement stabilization, \nsearching for an object image in the video stream rather than taking a search\nrectangle from the stream itself.  Eg look for a dog.\nwhere the camera is mounted on a moving platform or object, Etc. \nI will be working to implement Robot (without wheel encoders) Navigation\nTest using this camera tracking.\n\n## Project Improvements\nMore accurate Robot Navigation without wheel encoders using camera tracking\nI am looking at saving high value search rectangles that\nare spaced out around the full xy range of the camera movement and use those\nto correct any tracking errors. These check point rectangles will also need to\nbe updated if a better check point rectangle (higher maxVal) is found in the same region. \nI was thinking approx every half image spacing in xy cam position. \nThis would allow it to self correct position drift (self calibrating). \nI am hoping to test this on a robot that does not have wheel encoders. \nCamera tracking could allow the robot to more accurately navigate and rotate.\nI am pleased with the current FPS with ver 0.85. The multi version is not very\nstable due to segment faults so I will stick with only the video stream being\nthreaded. \nIf you decide to try this as well, let me know.\nClaude ...\n\n***Note:*** This application is a demo and is currently still in development, but I \nthought it could still be useful, since I was not able to find a similar\nRPI application that does this.  Will try to implement an object searcher based\non this demo.\n                         \n## Tuning\nYou may have to experiment with some settings to optimize performance. See comments in\nconfig.py regarding MATCH_METHOD values.     \nFor more information regarding match\nmethods see http://docs.opencv.org/3.1.0/d4/dc6/tutorial_py_template_matching.html\n\nPossible match methods are below (passed via config.py MATCH_METHOD variable as integer)    \n\n* cv2.TM_SQDIFF = 0    \n* cv2.TM_SQDIFF_NORMED = 1    \n* cv2.TM_CCORR = 2    \n* cv2.TM_CCORR_NORMED = 3  (default)  \n* cv2.TM_CCOEFF = 4    \n* cv2.TM_CCOEFF_NORMED = 5    \n\nIf there are plain backgrounds or random motions in camera view then the\ntracking coordinate values may drift out of sync.\nEdit the config.py file per variable comments using the nano editor or similar.\nI personally like to use filezilla configured with SFTP-SSH Protocol to transfer files to/from my\nvarious Raspberry Pi computers and then edit on my PC using NotePad ++.\n\nThe main variables are\n\n### MAX_SEARCH_THRESHOLD - default is .97\nThis variable sets the value for the highest accuracy for maintaining a \nlock on the search rectangle found in the stream images.  Otherwise another similar block will be returned.  \nSetting this higher will force a closer match to the original search rectangle. \nIf you have a unique background features then set this higher eg .98, .99 \nor for a background with fewer unique features set it lower since the match criteria\nwill not be able to be met.  Review debug data for your environment.\n\n### cam_move_x and cam_move_y - defaults 10 and 8\nThese variables set the maximum x and y pixel movement allowed in one loop cycle.\nThis reduces unexpected cam position changes when objects move through the \ncamera image view quickly.  \n\nThe search_rect can lock onto the moving objects pixel pattern and track it. \nWhen this happens, the cam position will get out of sync since it is not \ntracking the image background properly. Balance the setting with the normal\nexpected cam movement speed. defaults are 10 and 8\n\nUse a text editor to review config.py file for other variable settings.  Eg. \n\n    nano config.py\n    \nnano editor is just a suggestion.  You can use whatever editor you are\ncomfortable with\n\n## Development Ideas\n\n* Save high value search rectangles and position data so when the camera\nview is later in the same zone or vicinity it can use the reference to correct\ncamera position.\n* Have a library of pre-set images of objects or things that can be recognized.\nthis could be used for finding something in the camera view.\n* Change or add feature to have camera position tracked in degrees so left\nwould start at 360 and right 0 rather than left starting negative and right positive.\n* Add feature to remember a course via larger search rectangles that can be played back\nto repeat course or retrace backwards\n* Add feature to remember camera position data changes (only save changed values within a\nspecific +- range) This could include since last reading.  This might be useful for\nrepeating actions based on camera tracking.\n* Add passing of video file path and/or other information via command line parameter(s)\n\n## Credits\n\nThanks to Adrian Rosebrock jrosebr1 at http://www.pyimagesearch.com \nfor the PiVideoStream Class code available on github at\nhttps://github.com/jrosebr1/imutils/blob/master/imutils/video/pivideostream.py\n\nHave Fun Claude Pageau\n\nYouTube Channel https://www.youtube.com/user/pageaucp     \nGitHub https://github.com/pageauc   \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fcam-track","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpageauc%2Fcam-track","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fcam-track/lists"}