makalin/KeyForge3D
소개
KeyForge3D는 열쇠 사진을 3D 프린팅 가능한 STL 파일로 변환하는 앱입니다. 자물쇠공과 취미 사용자에게 적합하며, 이미지 처리로 열쇠의 비팅 패턴을 분석해 빠른 복제를 위한 정확한 3D 모델을 생성합니다.
디자인 및 미디어What you can do
- Key Shape Extraction: Upload a photo of a key to extract its 2D profile.
- Bitting Analysis: Automatically detect and analyze the key's bitting pattern (e.g., "05624").
- 3D Model Generation: Convert the 2D key profile into a 3D model with accurate cuts and dimensions.
- STL Export: Export the 3D model as an STL file, ready for 3D printing.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- +5
- in 1 month
- +13
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalKeyForge3D

KeyForge3D is an innovative application that extracts the shape of a physical key from a photo, generates a 3D model of the key, and exports it as an STL file for 3D printing. This tool is designed for locksmiths, hobbyists, or anyone needing a quick way to replicate a key using a 3D printer. The app features a user-friendly GUI built with Tkinter, making it easy to upload an image, process the key, and generate a 3D model.
Features
- Key Shape Extraction: Upload a photo of a key to extract its 2D profile.
- Bitting Analysis: Automatically detect and analyze the key's bitting pattern (e.g., "05624").
- 3D Model Generation: Convert the 2D key profile into a 3D model with accurate cuts and dimensions.
- STL Export: Export the 3D model as an STL file, ready for 3D printing.
- User-Friendly GUI: Simple interface to upload images and generate models with a single click.
- Scalability: Scale the key to real-world dimensions (default: 1 pixel = 0.1 mm; can be adjusted with a reference object).
Demo

The app processes a photo of a key, extracts its shape, and generates a 3D model like the one shown above. The bitting code (e.g., "05624") is also displayed for reference.
Installation
Prerequisites
- Python 3.8+: Ensure Python is installed on your system.
- pip: Python package manager for installing dependencies.
- 3D Printer (Optional): To print the generated key models.
Dependencies
KeyForge3D relies on the following Python libraries:
opencv-python: For image processing and key shape extraction.numpy: For numerical operations.trimesh: For 3D model generation and STL export.shapely: For polygon operations.pillow: For image display in the GUI.
Install the dependencies using the following command:
pip install opencv-python numpy trimesh shapely pillow
Clone the Repository
Clone the KeyForge3D repository to your local machine:
git clone https://github.com/makalin/KeyForge3D.git
cd KeyForge3D
Usage
Run the App:
- Run the main script to launch the GUI:
python keyforge3d.pyUpload a Key Photo:
- Click the "Upload Key Image" button and select a photo of a key.
- The key should be placed on a plain background (e.g., white paper) with good lighting for best results.
- Optionally, include a reference object (e.g., a coin) for accurate scaling (scaling is currently set to 1 pixel = 0.1 mm).
Process the Key:
- Click the "Process Key and Generate 3D Model" button.
- The app will process the image, display the bitting code, and save the 3D model as
key_model.stl.
3D Printing:
- Open the
key_model.stlfile in your 3D printing software (e.g., Cura, PrusaSlicer). - Print the key using a strong material like PLA or ABS. Use a high resolution (e.g., 0.1 mm layer height) for accurate bitting cuts.
- Open the
Code Overview
The main script (keyforge3d.py) includes:
- GUI: Built with Tkinter for user interaction.
- Image Processing: Uses OpenCV to detect the key's outline and analyze its bitting pattern.
- 3D Model Generation: Uses Trimesh to create a 3D model and export it as an STL file.
- Error Handling: Includes basic error handling for invalid images or processing failures.
Roadmap
- Add a 3D model preview within the app.
- Support for scaling using a reference object (e.g., a coin).
- Add key type identification (e.g., Schlage SC4, Kwikset KW1).
- Improve bitting analysis accuracy with machine learning.
- Create a mobile app version with camera integration.
- Add support for more key profiles and bitting standards.
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Make your changes and commit them (
git commit -m "Add your feature"). - Push to your branch (
git push origin feature/your-feature). - Open a pull request.
Please ensure your code follows the project's coding style and includes appropriate tests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Inspired by locksmith tools for key bitting analysis.
- Built with the help of open-source libraries like OpenCV, Trimesh, and Tkinter.
Contact
For questions, suggestions, or feedback, feel free to open an issue or reach out.
관련 프로젝트 살펴보기
불러오는 중…