{"id":28206643,"url":"https://github.com/iwatake2222/play_with_ncnn","last_synced_at":"2025-06-11T21:30:42.058Z","repository":{"id":55682646,"uuid":"216198402","full_name":"iwatake2222/play_with_ncnn","owner":"iwatake2222","description":"Sample projects to use ncnn","archived":false,"fork":false,"pushed_at":"2022-09-04T11:33:39.000Z","size":85366,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-17T10:11:10.773Z","etag":null,"topics":["cpp","deeplearning","ncnn"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iwatake2222.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-19T11:51:32.000Z","updated_at":"2023-10-14T10:07:15.000Z","dependencies_parsed_at":"2022-08-15T06:20:46.345Z","dependency_job_id":null,"html_url":"https://github.com/iwatake2222/play_with_ncnn","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/iwatake2222/play_with_ncnn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatake2222%2Fplay_with_ncnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatake2222%2Fplay_with_ncnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatake2222%2Fplay_with_ncnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatake2222%2Fplay_with_ncnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iwatake2222","download_url":"https://codeload.github.com/iwatake2222/play_with_ncnn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iwatake2222%2Fplay_with_ncnn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259345454,"owners_count":22843532,"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":["cpp","deeplearning","ncnn"],"created_at":"2025-05-17T10:10:14.231Z","updated_at":"2025-06-11T21:30:42.053Z","avatar_url":"https://github.com/iwatake2222.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Play with ncnn\r\n- Sample projects to use ncnn in C++ for multi-platform\r\n- Typical project structure is like the following diagram\r\n    - ![00_doc/design.jpg](00_doc/design.jpg)\r\n\r\n## Target\r\n- Platform\r\n    - Linux (x64)\r\n    - Linux (armv7)\r\n    - Linux (aarch64)\r\n    - Android (aarch64)\r\n    - Windows (x64). Visual Studio 2019\r\n- Option\r\n    - with Vulkan\r\n    - without Vulkan\r\n\r\n## Usage\r\n```\r\n./main [input]\r\n\r\n - input = blank\r\n    - use the default image file set in source code (main.cpp)\r\n    - e.g. ./main\r\n - input = *.mp4, *.avi, *.webm\r\n    - use video file\r\n    - e.g. ./main test.mp4\r\n - input = *.jpg, *.png, *.bmp\r\n    - use image file\r\n    - e.g. ./main test.jpg\r\n - input = number (e.g. 0, 1, 2, ...)\r\n    - use camera\r\n    - e.g. ./main 0\r\n```\r\n\r\n## How to build a project\r\n### 0. Requirements\r\n- OpenCV 4.x\r\n- Vulkan SDK (even if you don't use it)\r\n    - https://github.com/iwatake2222/InferenceHelper#extra-steps-ncnn\r\n\r\n### 1. Download \r\n- Download source code and pre-built libraries\r\n    ```sh\r\n    git clone https://github.com/iwatake2222/play_with_ncnn.git\r\n    cd play_with_ncnn\r\n    git submodule update --init\r\n    sh InferenceHelper/third_party/download_prebuilt_libraries.sh\r\n    ```\r\n- Download models\r\n    ```sh\r\n    sh ./download_resource.sh\r\n    ```\r\n- If you want to change pre-built library to be used, modify the following file\r\n    - `InferenceHelper/third_party/cmakes/ncnn.cmake`\r\n\r\n### 2-a. Build in Linux\r\n```\r\ncd pj_ncnn_cls_mobilenet_v2   # for example\r\nmkdir -p build \u0026\u0026 cd build\r\ncmake ..\r\nmake\r\n./main\r\n```\r\n\r\n### 2-b. Build in Windows (Visual Studio)\r\n- Configure and Generate a new project using cmake-gui for Visual Studio 2019 64-bit\r\n    - `Where is the source code` : path-to-play_with_ncnn/pj_ncnn_cls_mobilenet_v2\t(for example)\r\n    - `Where to build the binaries` : path-to-build\t(any)\r\n- Open `main.sln`\r\n- Set `main` project as a startup project, then build and run!\r\n\r\n**Note:** Debug mode in Visual Studio doesn't work because debuggable libraries are not provided\r\n\r\n### 2-c. Build in Android Studio\r\n- Please refer to\r\n    - https://github.com/iwatake2222/InferenceHelper_Sample#2-d-build-in-android-studio\r\n- Copy `resource` directory to `/storage/emulated/0/Android/data/com.iwatake.viewandroidncnn/files/Documents/resource`\r\n    - the directory will be created after running the app (so the first run should fail because model files cannot be read)\r\n- Modify `ViewAndroid\\app\\src\\main\\cpp\\CMakeLists.txt` to select a image processor you want to use\r\n    - `set(ImageProcessor_DIR \"${CMAKE_CURRENT_LIST_DIR}/../../../../../pj_ncnn_cls_mobilenet_v2/image_processor\")`\r\n    - replace `pj_ncnn_cls_mobilenet_v2` to another\r\n- In case you encounter `error: use of typeid requires -frtti` error, modify `ViewAndroid\\sdk\\native\\jni\\include\\opencv2\\opencv_modules.hpp`\r\n    - `//#define HAVE_OPENCV_FLANN`\r\n\r\n# License\r\n- Copyright 2020 iwatake2222\r\n- Licensed under the Apache License, Version 2.0\r\n    - [LICENSE](LICENSE)\r\n\r\n# Acknowledgements\r\n- This project utilizes OSS (Open Source Software)\r\n    - [NOTICE.md](NOTICE.md)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwatake2222%2Fplay_with_ncnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiwatake2222%2Fplay_with_ncnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiwatake2222%2Fplay_with_ncnn/lists"}