From cacba493ca05535cc988f8ae8873f977eaea0fac Mon Sep 17 00:00:00 2001 From: louiscklaw Date: Fri, 31 Jan 2025 22:31:22 +0800 Subject: [PATCH] update, --- vinniesniper-54816/task1/build_archive.sh | 5 + vinniesniper-54816/task1/clear.py | 12 + vinniesniper-54816/task1/digest.md | 111 ++++++ vinniesniper-54816/task1/journal.md | 13 + .../task1/project/.editorconfig | 18 + vinniesniper-54816/task1/project/.gitignore | 344 ++++++++++++++++++ .../task1/project/.prettierrc.js | 17 + vinniesniper-54816/task1/project/README.md | 60 +++ 8 files changed, 580 insertions(+) create mode 100755 vinniesniper-54816/task1/build_archive.sh create mode 100644 vinniesniper-54816/task1/clear.py create mode 100644 vinniesniper-54816/task1/digest.md create mode 100644 vinniesniper-54816/task1/journal.md create mode 100644 vinniesniper-54816/task1/project/.editorconfig create mode 100644 vinniesniper-54816/task1/project/.gitignore create mode 100644 vinniesniper-54816/task1/project/.prettierrc.js create mode 100644 vinniesniper-54816/task1/project/README.md diff --git a/vinniesniper-54816/task1/build_archive.sh b/vinniesniper-54816/task1/build_archive.sh new file mode 100755 index 00000000..b081ba38 --- /dev/null +++ b/vinniesniper-54816/task1/build_archive.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -ex + +tar -zcvf project.tar.gz project diff --git a/vinniesniper-54816/task1/clear.py b/vinniesniper-54816/task1/clear.py new file mode 100644 index 00000000..5554c680 --- /dev/null +++ b/vinniesniper-54816/task1/clear.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +import os,sys +from pprint import pprint + +for root, dirs, files in os.walk("_lab"): + for file in files: + if file.endswith(".jpg"): + os.remove(os.path.join(root, file)) + if file.endswith(".jpeg"): + os.remove(os.path.join(root, file)) + if file.endswith(".Identifier"): + os.remove(os.path.join(root, file)) diff --git a/vinniesniper-54816/task1/digest.md b/vinniesniper-54816/task1/digest.md new file mode 100644 index 00000000..2b312c98 --- /dev/null +++ b/vinniesniper-54816/task1/digest.md @@ -0,0 +1,111 @@ +# CS4185 Multimedia Technologies and Applications + +## What does this program do? + +- Loads aninput imageand 1000 database imagesto be compared with it. + +- Converts the images to grayscale + +- Compares the base image with the database image using pixel-by-pixel difference. + +- Displays the numerical matching parameters obtained. + +- Displays the input image and the best match result. + +## Basic Requirements (80%) + +- Automatically changing some setting according to the extracted features is allowed. + +Students are required to finish the following four tasks in the basic requirements: + +1. Improve the number of correctly matched images (20%) +1. Modify the above program to retrieve similar images (20%) + + - Utilize color information. + + - Color Models + + - The RGB Color Models + - Quantization + + - Color Histograms + - disadvantages + 1. Color similarity across histogram bins is not considered + 1. Spatial color layout is not considered + + - Using different layout. + + - Color Layout + - http://en.wikipedia.org/wiki/Color_layout_descriptor + - Need for Color Layout -> Global color features give too many false positives. + - How it works: + - Divide the whole image into sub-blocks. + - Extract features from each sub-block. + - Can we go one step further? + - Divide the image into regions based on color feature concentration. + - This process is called segmentation + + - Utilize edge and shape information. + + - Circle Hough transform: + + - https://en.wikipedia.org/wiki/Circle_Hough_Transform + - http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html + + - segmentation + + - Features for local regions in the image + - Interest points: corners, edges and others + - Keypoints: + - points in images, which are invariant to image translation, scale and rotation, and are minimally affected by noise and small distortions + - Scale-invariant feature transform (SIFT) by David Lowe + + - Image content is transformed into local feature coordinates that are invariant to translation, rotation, scale, and other imaging parameters + - advantages: + + - Locality:features are local, so robust to occlusion and clutter (no prior segmentation) + - Distinctiveness:individual features can be matched to a large database of objects + - Quantity:many features can be generated for even small objects + - Efficiency:close to real-time performance - Extensibility:can easily be extended to wide range of differing feature types, with each adding robustness + + - Detect keypoints using the SIFT detector + - `tutorial3` -> page 13 ~ 18 + - R-trees, SR-Trees ? + + - Features fusion + - Image Features Measures + - Image Distance Measures + - db + - tutorial4 -> page 9 + +1. Improve on the Precision (20%) + + - The percentage of retrieved images that are matched + +1. Improve on the Recall (20%) + + - the percentage of matched images that are retrieved. + +## The extension includes two parts, + +technical improvementand UI design. + +### The technical improvement : + +- 15% of marks will be given based on the technical difficulties +- may include new retrieval algorithms + - (e.g., 80+% of precision and 55+% of recall), +- high dimensional data indexing + - (efficiently storing and managing the features extracted from the database, modifying the program so that it does not need to compute the features every time), +- retrieval algorithms for particular types of images(e.g., sunset images, images containing human faces), +- a crawler to obtain images from the internet, or adding semantic informationto help improve the retrieval performance. + +### UI design + +- 10% will be given based on the UI design. + +### Submission + +- Program +- Demo +- Report diff --git a/vinniesniper-54816/task1/journal.md b/vinniesniper-54816/task1/journal.md new file mode 100644 index 00000000..b7597360 --- /dev/null +++ b/vinniesniper-54816/task1/journal.md @@ -0,0 +1,13 @@ +# Journal + +reference +/home/logic/_wsl_workspace/comission-playlist/vinniesniper-54816/task1/_ref/mmta-main + +http://places.csail.mit.edu/cellImgs/b_beach.jpg + + +``` +kill `ps -ef|grep -i draft |awk '{print $2}'` +``` + +https://youtu.be/6hcjr5ISmzo diff --git a/vinniesniper-54816/task1/project/.editorconfig b/vinniesniper-54816/task1/project/.editorconfig new file mode 100644 index 00000000..9fc0ec80 --- /dev/null +++ b/vinniesniper-54816/task1/project/.editorconfig @@ -0,0 +1,18 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false + +[*.yml] +[*.{yml,yaml}] +indent_size = 2 diff --git a/vinniesniper-54816/task1/project/.gitignore b/vinniesniper-54816/task1/project/.gitignore new file mode 100644 index 00000000..2c36b7dc --- /dev/null +++ b/vinniesniper-54816/task1/project/.gitignore @@ -0,0 +1,344 @@ +# Created by https://www.toptal.com/developers/gitignore/api/node,nextjs,python +# Edit at https://www.toptal.com/developers/gitignore?templates=node,nextjs,python + +### NextJS ### +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +### Node ### +# Logs +logs +*.log +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/node,nextjs,python \ No newline at end of file diff --git a/vinniesniper-54816/task1/project/.prettierrc.js b/vinniesniper-54816/task1/project/.prettierrc.js new file mode 100644 index 00000000..36c1742c --- /dev/null +++ b/vinniesniper-54816/task1/project/.prettierrc.js @@ -0,0 +1,17 @@ +module.exports = { + arrowParens: 'avoid', + bracketSpacing: true, + htmlWhitespaceSensitivity: 'css', + insertPragma: false, + bracketSameLine: false, + jsxSingleQuote: true, + printWidth: 120, + proseWrap: 'preserve', + quoteProps: 'as-needed', + requirePragma: false, + semi: false, + singleQuote: true, + tabWidth: 2, + trailingComma: 'none', + useTabs: false +} diff --git a/vinniesniper-54816/task1/project/README.md b/vinniesniper-54816/task1/project/README.md new file mode 100644 index 00000000..f5a65f7d --- /dev/null +++ b/vinniesniper-54816/task1/project/README.md @@ -0,0 +1,60 @@ +# README + +## spin up dev environment + +```bash +# extract archive +$ tar -zxvf project.tar.gz +``` + +### frontend + +```bash +$ cd project/frontend +$ yarn +$ yarn dev +``` + +### backend(py_classifier) +```bash +# install miniconda +# https://docs.anaconda.com/miniconda/ +# https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe + +# download and install miniconda +$ conda create --name opencv3 python=3 +$ conda activate opencv3 + +# optional +$ pip install opencv-contrib-python==3.4.2.16 + +# run classifier backend +$ cd src +$ ./scripts/run.sh +``` + +## directory structure + +```bash +├── docs # some documentation +├── poc # proff of concept workspace + ├── 003-crawler # image crawler + ├── 010-flask # python flask tryout + └── 013-flask-nextjs-draft # python / nextjs integration +├── training # classifier training code +├── frontend # frontend code +├── py_classifier # backend code +└── test_images # test images +``` + +## References + +- https://youtu.be/6hcjr5ISmzo +- https://docs.opencv.org/4.x/dc/d88/tutorial_traincascade.html +- https://github.com/Paradiddle131/Cigarette-Detection-with-Haar-Cascade-Classifier/tree/master +- https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/ +- https://saturncloud.io/blog/installing-opencv-with-conda-a-guide-for-data-scientists/ +- https://stackoverflow.com/questions/38787748/installing-opencv-3-1-with-anaconda-python3 +- https://huggingface.co/chat/conversation/67252f087c8610524e155288 +- https://github.com/search?q=opencv_createsamples&type=code&ref=advsearch +- https://github.com/Paradiddle131/Cigarette-Detection-with-Haar-Cascade-Classifier/tree/master