{"id":16520018,"url":"https://github.com/pageauc/opencv3-setup","last_synced_at":"2025-03-21T08:32:02.525Z","repository":{"id":74954770,"uuid":"90212629","full_name":"pageauc/opencv3-setup","owner":"pageauc","description":"Raspberry Pi whiptail Menu driven Easy Install and Compile of opencv3 python from source files.","archived":false,"fork":false,"pushed_at":"2020-07-25T11:12:10.000Z","size":385,"stargazers_count":51,"open_issues_count":1,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T23:37:43.774Z","etag":null,"topics":["automated","bash","cmake","compile","curl","install","make","menu-driven","opencv","opencv3","pi","raspberry","rpi","script","setup","source","ver","whiptail-menu"],"latest_commit_sha":null,"homepage":"","language":"Shell","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-04T02:23:26.000Z","updated_at":"2024-01-12T08:43:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"1dafec37-b384-441e-b9e5-250b37424c99","html_url":"https://github.com/pageauc/opencv3-setup","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/pageauc%2Fopencv3-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fopencv3-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fopencv3-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pageauc%2Fopencv3-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pageauc","download_url":"https://codeload.github.com/pageauc/opencv3-setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765596,"owners_count":20506838,"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":["automated","bash","cmake","compile","curl","install","make","menu-driven","opencv","opencv3","pi","raspberry","rpi","script","setup","source","ver","whiptail-menu"],"created_at":"2024-10-11T16:49:15.026Z","updated_at":"2025-03-21T08:32:02.515Z","avatar_url":"https://github.com/pageauc.png","language":"Shell","readme":"## Raspberry Pi Menu Driven OpenCV 3 Compile from Source Script\n#### Whiptail menu enabled script to help compile opencv3 from source\n\n![cv3-install-menu](https://github.com/pageauc/opencv3-setup/blob/master/menu.png)\n\n## Quick Install\nFor system requirements See [***Prerequisites***](https://github.com/pageauc/opencv3-setup#prerequisites)   \n  \n***Step1*** - Use mouse to highlight command below, Then right click copy on highlighted command     \n***Step2*** - On a logged in RPI SSH terminal session right click paste then Enter to Run\n[***setup.sh***](https://github.com/pageauc/opencv3-setup/blob/master/setup.sh) script\n\n    curl -L https://raw.github.com/pageauc/opencv3-setup/master/setup.sh | bash \n\nThe curl comand will run the GitHub [***setup.sh***](https://github.com/pageauc/opencv3-setup/blob/master/setup.sh)\nscript that will install files and configure into the ***~/opencv3-setup*** folder.\nIf you want to review code before running see [***Manual Install***](https://github.com/pageauc/opencv3-setup#manual-install)\n\n## How To Run Menu\n\n    cd ~/opencv3-setup\n    ./cv3-install-menu.sh\n\nStart at Step ***1 UPDATE*** menu pick and follow instructions. You will be prompted to optionally reboot.    \nFor details see [***How to Run Menu Picks***](https://github.com/pageauc/opencv3-setup#how-to-run-menu-picks)   \nTo change cv3_tmp folder location or opencv version see\n[***How to Change Configuration***](https://github.com/pageauc/opencv3-setup#how-to-change-configuration)\n\n## Operation\nAfter update/upgrade and optional reboot is complete, Select **DEP** menu pick. If there are no problems,\nyou will be prompted with a simple y/n to continue without having to return to the main menu. If there are\nissues that need to be resolved you can continue by selecting the appropriate main menu pick.\n\nThe [***cv3-install-menu.sh***](https://github.com/pageauc/opencv3-setup/blob/master/cv3-install-menu.sh) script will\n\n* Online validate that ***OPENCV_VER*** variable setting is correct\n* Check if ***INSTALL_DIR*** variable exists and points to a Non Fat File System.\n* Creates ***cv3-log.txt*** file If It Does Not Exist. Records system information, date/times of steps including execution time.\n* ***UPDATE*** menu pick to update/upgrade Raspbian. Prompts for optional reboot.\n* ***DEP*** menu pick to Install build dependencies, Download opencv3 source zip files and unzip\n* Auto Detect RPI3 and set NEON compile directive for cmake to enhance cv3 performance. Off for non RPI 3's\n* ***COMPILE*** menu pick will Run ***cmake*** to check and configure build\n* Temporarily Increase Swap memory to 1024 MB During make. Returned to original state after make.\n* Auto Detect Total RAM memory and set compile cores. -j2 for 1 GB, -j1 for the Rest\n* Run ***make*** to Compile opencv3 source code\n* ***INSTALL*** Menu pick will Run ***make install*** to install new opencv python ***.so*** files to production.\n* Optional run ***make clean*** to clear build directory to force full recompile.\n* ***DELETE*** menu pick to optionally recover disk space by deleting the ***tmp_cv3*** folder containing\nopencv source, build files and folders.\n* ***SETTINGS*** menu pick to nano edit the [***cv3-install-menu.conf***](https://github.com/pageauc/opencv3-setup/blob/master/cv3-install-menu.conf) file\n\n## Prerequisites\n* Basic knowledge of unix terminal commands.\nThere are some optional configuration steps that\nmust be done manually using nano.\n* Patience since this will take a few hours\n* Recent Jessie or Stretch Raspbian Release\n* Working RPI \n* Working Internet connected to RPI WIFI or RJ45 network cable\n* Recommended min 16GB SD card with at least 6 GB Free.\nIf Free disk space is low or You have a smaller system SD card.\nYou can mount Non fat USB stick or hard disk see\n[***How to Change Location of Temporary Working Folder***](https://github.com/pageauc/opencv3-setup#how-to-change-location-of-temporary-working-folder) \n\n## Manual Install\nFrom a logged in RPI SSH session or console terminal perform the following.\nThis will allow you to review the code before installing.\n\n    cd ~\n    wget -o setup.sh https://raw.github.com/pageauc/opencv3-setup/master/setup.sh\n    more setup.sh\n    chmod +x setup.sh\n    ./setup.sh\n    rm setup.sh\n    cd ~/opencv3-setup\n    ./cv3-install-menu.sh\n\n## How to Change Configuration\nRun the ***SETTINGS*** menu pick or Edit ***cv3-install-menu.conf*** file using nano per the following commands.\n\n    cd ~/opencv3-setup\n    nano cv3-install-menu.conf\n \nPress ctrl-x y to save changes and exit nano\n \n### How to Change OpenCV Version\nEdit variable OPENCV_VER='3.4.2' and change to a valid version per information at  \nhttps://github.com/opencv/opencv/releases The version number will be verified at launch\nagainst repo at https://github.com/Itseez/opencv/archive/    \nSee  https://github.com/opencv/opencv/releases    \nand https://github.com/opencv/opencv_contrib/releases for valid zip versions    \n\n### How to Change Location of Temporary Working Folder\n***cv3-menu-install.sh*** will create a working folder per\n***INSTALL_DIR*** variable. Default is ***/home/pi/tmp_cv3***. \nThis folder will store downloaded opencv source and build files.\nFor a Full Build on a New OS, it is recommended you have a minimum 16GB SD card with at least 6GB free.\nLess space may be needed depending on what dependencies are already installed.   \nTo check free disk space run\n\n    df -h\n\nYou can recover most disk space after the build/install by running the DELETE menu pick. \nIf there is not enough room on the system SD you can point the ***INSTALL_DIR*** to\nUSB Stick or disk drive media.  \n***IMPORTANT:*** The USB memory stick or disk media must ***NOT be formatted as FAT***\nsince it does not support symbolic links that are needed to compile opencv.\nUse a unix format like ext4 or microsoft NTFS format to avoid a failed make compile.   \nFor details see \n[***How To Mount External USB Storage***](https://github.com/pageauc/opencv3-setup#how-to-mount-external-usb-storage)\n\nctrl-x y to save changes and exit. Run ***cv3-install.menu.sh***.\nThe script will create the temporary working folder at the designated location. \n \n## RAM Memory\nIf RPI has 1GB of RAM memory make will use 2 cores -j2, otherwise 1 core -j1\nwill be used. Both will have Swap Memory temporarily set to 1024 MB during\nthe make compile process step. At the end of the compile the original Swap\nconfig will be returned.\n\n## How to Run Menu Picks\nFrom the main menu select ***1 UPDATE* menu pick. Follow Instructions that\nwill guide you through the menu steps.  If there are errors you can\nexit to the terminal to review output messages.  Problems will most likely\nbe related to Disk Space or Memory problems.    \n\nYou will be asked to reboot during some installation steps.\nIf you answer yes on successful completion of a step, you will be\nsent to the next step otherwise you will be sent to the terminal\nto review errors or back to the main menu as appropriate.\nYou may see warnings or not found messages and this is normal.  \n Eg tesseract (OCR) Not Found.\n\nUsers will be prompted to review output for errors and elect to continue.\nYou can repeat a particular step from the menu if required after\ncorrecting or resolving any issues or errors.\n\nOnce compiling starts it will show you a percent progress.  ***Note*** If for some reason\nthe compile is interrupted, You can restart the compile Menu again and it will quickly\nscan progress and will continue compile where it left off (was interrupted).\nIf a make clean is done (per menu prompt) then a full compile will restart from beginning again.\n\n## Logging\nA log file called ***cv3_log.txt*** will be created to record system\ninformation and the date/time and details for each operation.  \nReview the log to check how long various steps took to complete.\nOn exit you will be prompted if you want to clear the log file.\nA backup copy will be saved to ***cv3_log.txt.bak***. A new log will be created\n. The log can span multiple sessions. You must intentionally clear the log\nfrom the LOG menu or per commands below to clear.\n\n    cd ~/opencv3-setup\n    cp cv3-log.txt cv3-log.txt.bak\n    rm cv3-log.txt\n\n## How To Mount External USB Storage\n***IMPORTANT*** If there is limited space on the Raspbian SD card\nyou may want to change ***INSTALL_DIR*** variable to point to\nan Non Fat external storage drive/device.\n\n    cd ~/opencv3-setup\n    nano cv3-install-menu.sh\n\nChange the ***INSTALL_DIR*** variable to point to the desired mount location\nor a symbolic link to the desired external storage device. ctrl-x y to save\nand exit nano. See example mount commands below.\n\nFor more details on mounting external USB storage   \nsee https://www.htpcguides.com/properly-mount-usb-storage-raspberry-pi/\n\nSample commands to mount and use an external ntfs USB hard drive.\nPlug ntfs formatted disk into a RPI USB slot.  From SSH or terminal session\nuse sample commands below. (Note) modify to suit your conditions.  \nIf you reboot you will need to redo sudo mount command unless you add\nan entry to the /etc/fstab file (not covered here).\n\n    cd ~\n    sudo apt-get update\n    sudo apt-get install ntfs-3g   # Make sure ntfs support installed\n    sudo fdisk -l                  # will list drive if installed\n    cd ~/\n    mkdir /media/usb_1\n    sudo mount -t ntfs-3g /dev/sda1 /media/usb_1\n    df -h   #check space on usb device\n    cd ~/opencv-setup\n    nano cv3-install-menu.sh\n    \nIn nano edit the variable per below. \n\n    INSTALL_DIR='/media/usb_1/tmp_cv3'\n    \nctrl-x y to save changes and exit.   \n\n## How to Test Build\nTo Test build for python or python3. See Example below\nStart the required python interpreter by running the appropriate\ncommand for python 2 or 3 below.\n\n    python2\n\nor\n\n    python3    \n    \nAt the \u003e\u003e\u003e python prompt enter the following commands\n\n    import cv2\n    cv2.__version__\n\nYou should see output indicating the opencv version installed.\nPress ctrl-d to exit python interpreter\nAlso check python3 opencv version using python3 interpreter.\n\nIf after a successful compile and install you see an older version of opencv\nyou may have to uninstall a previous apt-get version per the following\n\n    sudo apt-get purge python-opencv\n    \nCheck the opencv version again to see if the version is updated.  Otherwise\nyou can return the previous opencv per\n\n    sudo apt-get install python-opencv    \n\nSee my other github repo at https://github.com/pageauc    \nfor various opencv motion and opencv camera projects.\n\n## Credits\nScript Steps Based on GitHub Repo\nhttps://github.com/Tes3awy/OpenCV-3.2.0-Compiling-on-Raspberry-Pi\n\nFor Additional Details See https://github.com/pageauc/opencv3-setup\n\nHave Fun\nClaude Pageau   \nYouTube Channel https://www.youtube.com/user/pageaucp   \nGitHub Repo https://github.com/pageauc   \n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fopencv3-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpageauc%2Fopencv3-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpageauc%2Fopencv3-setup/lists"}