Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,7 @@ __marimo__/

# Streamlit
.streamlit/secrets.toml

# Custom for this project
hand_landmarker.task
screenshot_*.png
79 changes: 79 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic
status, nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political
attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards
of acceptable behavior and will take appropriate and fair corrective action
in response to any behavior that they deem inappropriate, threatening,
offensive, or harmful.

Community leaders have the right to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not
aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies
when an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email
address, posting via an official social media account, or acting as an
appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[tbd@yourproject.com] or via the project's issue tracker. All complaints
will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of
the reporter of any incident.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing to Gesture Camera Effects

Thank you for your interest in contributing! Please follow these guidelines to help make the project better.

## How to Contribute

1. Fork the repository
2. Create a new branch for your feature or bugfix (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Ensure your code follows the project's style (we use [PEP 8](https://www.python.org/dev/peps/pep-0008/))
5. Test your changes thoroughly
6. Commit your changes (`git commit -m 'Add some amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request

## Reporting Issues

Please use the GitHub Issues tracker to report bugs or request features. Include:

- A clear and descriptive title
- Steps to reproduce the issue (if applicable)
- Expected vs actual behavior
- Screenshots or logs if helpful
- Your environment (OS, Python version, etc.)

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details.

## License

By contributing, you agree that your contributions will be licensed under the MIT License.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 <your name or organization>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
207 changes: 206 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,206 @@
# gesture-camera-effects
# Interactive Gesture Rectangle Camera with Multi Visual Effects

## Description

Membangun aplikasi Computer Vision berbasis Python + OpenCV + MediaPipe Hands yang memungkinkan pengguna membuat area efek kamera secara interaktif menggunakan gesture dua tangan.

Pengguna membuat sebuah rectangle dengan melakukan gesture pinch pada kedua tangan. Rectangle mengikuti pergerakan tangan selama pinch masih dilakukan. Ketika pinch dilepas, rectangle akan terkunci (locked) dan langsung menerapkan efek visual unik hanya pada area rectangle.

Aplikasi mendukung beberapa rectangle aktif secara bersamaan, sehingga setiap area dapat memiliki efek yang berbeda.

## Alur Penggunaan

1. Deteksi Tangan

Program mendeteksi:

- Tangan kiri
- Tangan kanan

Menggunakan MediaPipe Hands.

2. Gesture Membuat Rectangle

Syarat:

- Kedua tangan harus melakukan pinch (ujung ibu jari dan ujung telunjuk bersentuhan).

- Ketika kondisi ini terpenuhi:

- Rectangle dibuat.
- Sudut diagonal rectangle menggunakan:
- Ujung telunjuk tangan kiri
- Ujung telunjuk tangan kanan

- Rectangle akan terus mengikuti pergerakan kedua telunjuk selama pinch dipertahankan.

3. Lock Rectangle

Saat salah satu atau kedua tangan melepaskan pinch:

- Rectangle berhenti bergerak.
- Posisi rectangle disimpan secara permanen.
- Efek visual langsung diterapkan pada area rectangle.

Rectangle yang sudah terkunci tidak dapat dipindahkan lagi.

## Efek Kamera

Efek hanya diterapkan di dalam area rectangle, sedangkan area di luar rectangle tetap menampilkan tampilan kamera normal.

Empat efek yang digunakan:

| Urutan | Efek | Deskripsi |
|--------|----------------|----------------------------------------------------------------------|
| 1 | 🌫️ Gaussian Blur | Area menjadi buram dengan transisi halus. |
| 2 | 🟦 Pixelation | Area berubah menjadi tampilan kotak-kotak (mosaic). |
| 3 | 🎨 Cartoon | Area berubah menjadi gaya kartun menggunakan kombinasi smoothing dan edge detection. |
| 4 | ⚡ Edge Detection | Area hanya menampilkan garis tepi objek sehingga terlihat futuristik. |

Setiap rectangle baru akan mendapatkan efek secara berurutan:

Rectangle 1 → Gaussian Blur
Rectangle 2 → Pixelation
Rectangle 3 → Cartoon
Rectangle 4 → Edge Detection
Rectangle 5 → Gaussian Blur
...

## Multi Rectangle

Pengguna dapat membuat beberapa rectangle.

Contoh:

Rectangle 1 → Gaussian Blur
Rectangle 2 → Pixelation
Rectangle 3 → Cartoon
Rectangle 4 → Edge Detection

Seluruh rectangle tetap aktif secara bersamaan.

## Gesture Hapus

Gesture:

- Closed Fist (tangan mengepal)

Fungsi:

- Menghapus rectangle terakhir yang dibuat (Undo).
- Rectangle lainnya tetap aktif beserta efeknya.

## Arsitektur Program

Webcam
OpenCV
MediaPipe Hands
Gesture Detector
Rectangle Manager
Effect Manager
Renderer
Camera Display

## Struktur Projekt

gesture-camera-effects/
├── main.py
├── camera.py
├── hand_tracker.py
├── gesture_detector.py
├── rectangle.py
├── rectangle_manager.py
├── effects.py
├── effect_manager.py
├── renderer.py
├── utils.py
├── assets/
└── requirements.txt

## State Machine

Idle
Both Hands Pinch
Drawing Rectangle
Release Pinch
Rectangle Locked
Effect Applied
Idle

Gesture Closed Fist:

Closed Fist
Delete Last Rectangle
Render Ulang

## Fitur Tambahan

- Border rectangle memiliki warna berbeda sesuai efek.
- Nama efek ditampilkan di sudut rectangle (Blur, Pixel, Cartoon, Edge).
- Maksimal 10 rectangle aktif untuk menjaga performa.
- Tombol keyboard:
- R → Hapus semua rectangle.
- S → Simpan screenshot.
- Q → Keluar aplikasi.
- Animasi singkat saat rectangle berhasil terkunci agar interaksi terasa lebih hidup.

## Instalasi

1. Clone repository ini
2. Install dependensi:
```
pip install -r requirements.txt
```
3. Jalankan aplikasi:
```
python main.py
```

## Penggunaan

- Pastikan webcam terhubung dan bekerja.
- Jadikan kedua tangan menghadap kamera.
- Lakukan pinch (ujung ibu jari dan jeli telunjuk menyentuh) dengan kedua tangan sekaligus untuk mulai membuat rectangle.
- Gerakkan tangan untuk mengubah ukuran rectangle.
- Lepaskan pinch untuk mengunci rectangle dan menerapkan efek.
- Untuk menghapus rectangle terakhir, buat kepalan tangan (closed fist) dengan salah satu tangan.
- Tekan 'R' untuk menghapus semua rectangle.
- Tekan 'S' untuk menyimpan screenshot.
- Tekan 'Q' untuk keluar.

## Catatan

- Aplikasi ini menggunakan MediaPipe Hands untuk deteksi tangan, sehingga kinerja mungkin tergantung pada hardware.
- Untuk hasil terbaik, pastikan pencahayaan adekuat dan background tidak terlalu ramai.
Loading
Loading