Skip to main content

Convert images into 3D drawing paths suitable for robotic arms.

Project description

AmericoDraws

AmericoDraws é uma biblioteca Python para processar imagens e gerar trajetórias 3D para braços robóticos. A biblioteca transforma imagens em caminhos de desenho otimizados que podem ser executados por braços robóticos.

Input Background Removed Contour

Input Top view sketch

Input Background Removed Contour

Input Top view sketch

Características Principais

  • Remoção automática de fundo de imagens usando IA
  • Extração de contornos e bordas de imagens
  • Geração de trajetórias 3D otimizadas para braços robóticos
  • Simplificação e otimização de caminhos para movimentos suaves
  • Visualização 3D dos caminhos gerados
  • Geração de comandos para controle de braços robóticos

Instalação

pip install AmericoDraws

Dependências

  • rembg>=2.0.0
  • numpy>=1.19.0
  • matplotlib>=3.3.0
  • opencv-python>=4.5.0
  • Pillow>=8.0.0
  • scikit-learn>=0.24.0
  • networkx>=2.5.0

Uso Rápido

from AmericoDraws import independencia_ou_morte

# Processar uma imagem e gerar trajetória 3D
pontos = independencia_ou_morte(
    "caminho/para/imagem.png",
    "diretorio/saida",
    process_cell_size=1,
    points_cell_width=1,
    z_up=10,
    remove_background=True
)

print(f"Gerados {len(pontos)} pontos para trajetória do braço robótico")

Função Principal

A função independencia_ou_morte() é o ponto de entrada principal da biblioteca:

independencia_ou_morte(
    input_path,             # Caminho para a imagem de entrada
    output_dir="output",    # Diretório para salvar os resultados
    process_cell_size=1,    # Tamanho da célula para processamento
    points_cell_width=1,    # Largura da célula para geração de pontos
    upper_left_edge=None,   # Coordenadas do canto superior esquerdo [x, y, z, a, e, r]
    bottom_right_edge=None, # Coordenadas do canto inferior direito [x, y, z, a, e, r]
    z_up=10,                # Valor do eixo Z para movimento com caneta levantada
    remove_background=True, # Remover o fundo da imagem
    bg_threshold=10,        # Limiar para limpeza de bordas alfa
    bg_erode_pixels=1,      # Pixels para erosão do canal alfa
    threshold1=120,         # Primeiro limiar para detecção de bordas Canny
    threshold2=191,         # Segundo limiar para detecção de bordas Canny
    blur_size=3,            # Tamanho do kernel para blur Gaussiano
    distance_threshold=3,   # Limiar de distância para filtrar pontos
    epsilon=0.25            # Valor epsilon para algoritmo Douglas-Peucker
)

Fluxo de Processamento

  1. Remoção de Fundo: Remove o fundo da imagem usando IA (opcional)
  2. Extração de Contornos: Detecta bordas e contornos na imagem
  3. Conversão para Matriz: Converte a imagem em uma matriz binária
  4. Geração de Pontos: Cria uma matriz de pontos 3D otimizada
  5. Visualização: Gera visualizações 3D e 2D dos caminhos
  6. Exportação: Salva os comandos para o braço robótico

Arquivos de Saída

A biblioteca gera vários arquivos de saída:

  • background_removed.png: Imagem com fundo removido
  • contour.png: Imagem com contornos extraídos
  • final_result.png: Visualização 2D do desenho final
  • 3d_path.png: Visualização 3D do caminho do braço robótico
  • robot_commands.txt: Comandos para o braço robótico (formato CSV)

Exemplos Adicionais

Personalização da Área de Desenho

from AmericoDraws import independencia_ou_morte

# Definir área de desenho personalizada
upper_left = [0, 1000, 0, 0, 0, 0]   # [x, y, z, a, e, r]
bottom_right = [1000, 0, 0, 0, 0, 0] # [x, y, z, a, e, r]

pontos = independencia_ou_morte(
    "imagem.png",
    "saida",
    upper_left_edge=upper_left,
    bottom_right_edge=bottom_right,
    z_up=20
)

Controle de Parâmetros de Detecção de Bordas

pontos = independencia_ou_morte(
    "imagem.png",
    "saida",
    threshold1=100,    # Mais sensível à detecção de bordas
    threshold2=200,
    blur_size=5,       # Blur maior para reduzir ruído
    epsilon=0.5        # Simplificação de caminho mais agressiva
)

Módulos

A biblioteca está organizada nos seguintes módulos:

  • contour_extraction.py: Funções para extração de contornos
  • image_processor.py: Processamento principal de imagens
  • path_planning.py: Planejamento de trajetórias para o braço robótico
  • utils.py: Funções utilitárias
  • visualization.py: Ferramentas de visualização

Contribuições

Contribuições são bem-vindas! Por favor, abra um issue ou pull request no repositório GitHub.

Licença

Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.

Autor

Repositório

https://github.com/lucasddoliveira/AmericoDraws

AmericoDraws

AmericoDraws is a Python library for processing images and generating 3D trajectories for robotic arms. The library transforms images into optimized drawing paths that can be executed by robotic arms.

Input Background Removed Contour

Input Top view sketch

Input Background Removed Contour

Input Top view sketch

Key Features

  • Automatic background removal using AI
  • Contour and edge extraction from images
  • Generation of optimized 3D trajectories for robotic arms
  • Path simplification and optimization for smooth movement
  • 3D visualization of generated paths
  • Generation of commands for robotic arm control

Installation

pip install AmericoDraws

Dependencies

  • rembg>=2.0.0
  • numpy>=1.19.0
  • matplotlib>=3.3.0
  • opencv-python>=4.5.0
  • Pillow>=8.0.0
  • scikit-learn>=0.24.0
  • networkx>=2.5.0

Quick Start

from AmericoDraws import independencia_ou_morte

# Process an image and generate a 3D trajectory
pontos = independencia_ou_morte(
    "caminho/para/imagem.png",
    "diretorio/saida",
    process_cell_size=1,
    points_cell_width=1,
    z_up=10,
    remove_background=True
)

print(f"Generated {len(points)} points for robotic arm trajectory")

Main Function

The independencia_ou_morte() function is the main entry point of the library:

independencia_ou_morte(
    input_path,             # Path to input image
    output_dir="output",    # Directory to save results
    process_cell_size=1,    # Cell size for processing
    points_cell_width=1,    # Cell width for point generation
    upper_left_edge=None,   # Coordinates of upper left corner [x, y, z, a, e, r]
    bottom_right_edge=None, # Coordinates of bottom right corner [x, y, z, a, e, r]
    z_up=10,                # Z-axis value for pen-up movement
    remove_background=True, # Remove background from image
    bg_threshold=10,        # Threshold for alpha edge cleanup
    bg_erode_pixels=1,      # Pixels to erode from alpha channel
    threshold1=120,         # First Canny edge detection threshold
    threshold2=191,         # Second Canny edge detection threshold
    blur_size=3,            # Kernel size for Gaussian blur
    distance_threshold=3,   # Distance threshold for point filtering
    epsilon=0.25            # Epsilon value for Douglas-Peucker algorithm
)

Processing Pipeline

  1. Background Removal: Removes image background using AI (optional)
  2. Contour Extraction: Detects edges and contours in the image
  3. Matrix Conversion: Converts image to binary matrix
  4. Point Generation: Creates an optimized 3D point matrix
  5. Visualization: Generates 3D and 2D path visualizations
  6. Export: Saves commands for the robotic arm

Output Files

The library generates several output files:

  • background_removed.png: Image with background removed
  • contour.png: Image with extracted contours
  • final_result.png: 2D visualization of final drawing
  • 3d_path.png: 3D visualization of robotic arm path
  • robot_commands.txt: Commands for robotic arm (CSV format)

Additional Examples

Custom Drawing Area

from AmericoDraws import independencia_ou_morte

# Define custom drawing area
upper_left = [0, 1000, 0, 0, 0, 0]   # [x, y, z, a, e, r]
bottom_right = [1000, 0, 0, 0, 0, 0] # [x, y, z, a, e, r]

points = independencia_ou_morte(
    "image.png",
    "output",
    upper_left_edge=upper_left,
    bottom_right_edge=bottom_right,
    z_up=20
)

Edge Detection Parameter Control

points = independencia_ou_morte(
    "image.png",
    "output",
    threshold1=100,    # More sensitive edge detection
    threshold2=200,
    blur_size=5,       # Larger blur to reduce noise
    epsilon=0.5        # More aggressive path simplification
)

Modules

The library is organized into the following modules:

  • contour_extraction.py: Functions for contour extraction
  • image_processor.py: Main image processing
  • path_planning.py: Trajectory planning for the robotic arm
  • utils.py: Utility functions
  • visualization.py: Visualization tools

Contributions

Contributions are welcome! Please open an issue or pull request on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Repository

https://github.com/lucasddoliveira/AmericoDraws

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

americodraws-0.1.4.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

americodraws-0.1.4-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file americodraws-0.1.4.tar.gz.

File metadata

  • Download URL: americodraws-0.1.4.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for americodraws-0.1.4.tar.gz
Algorithm Hash digest
SHA256 804f70eb8193834872d3249c12e95b5896bd1d11140577599a6c8e6fd7ec1016
MD5 9aaa93f0896d7a33b83ac7344139a2b9
BLAKE2b-256 bc0969010b4ce95a584c29f05a9eac0b7692f3bd8a35ae649038b83021bd132d

See more details on using hashes here.

File details

Details for the file americodraws-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: americodraws-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for americodraws-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 07f84c2ba4ae8781a9e399b3ed46928f7a8f04429343d7a7150c154918086856
MD5 5cf766fceb4446782ce3daf6f9a35347
BLAKE2b-256 735d7ec0df5e2b4e651e9a73450e415bd20747053bbdd0c48f19ffbb7ca11f91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page