README.md

# SupermakerAI Pose Generator

A lightweight Elixir library for generating pose estimations using AI models.  Simplifies integration with various pose estimation APIs and provides a consistent interface for your Elixir applications.

## Installation

Add `supermaker_ai_pose_generator` to your list of dependencies in `mix.exs`:
elixir
def deps do
  [
    {:supermaker_ai_pose_generator, "~> 0.1.0"}
  ]
end

Then run:
bash
mix deps.get
mix compile

## Usage

This library provides a set of functions for interacting with pose estimation services.  Here are some example usages:

**1. Basic Pose Estimation from Image URL:**
elixir
alias SupermakerAIPoseGenerator.Client

image_url = "https://example.com/image.jpg"

case Client.estimate_pose_from_url(image_url) do
  {:ok, pose_data} ->
    IO.inspect(pose_data, label: "Pose Data")
  {:error, reason} ->
    IO.puts("Error: #{reason}")
end

**2. Extracting Keypoints from Pose Data:**
elixir
alias SupermakerAIPoseGenerator.Client

image_url = "https://example.com/person.png"

Client.estimate_pose_from_url(image_url)
|> case do
  {:ok, pose_data} ->
    keypoints = SupermakerAIPoseGenerator.Keypoints.extract(pose_data)
    IO.inspect(keypoints, label: "Extracted Keypoints")
  {:error, reason} ->
    IO.puts("Error: #{reason}")
end

**3. Filtering Keypoints by Confidence Score:**
elixir
alias SupermakerAIPoseGenerator.Client
alias SupermakerAIPoseGenerator.Keypoints

image_url = "https://example.com/action_shot.jpeg"

Client.estimate_pose_from_url(image_url)
|> case do
  {:ok, pose_data} ->
    filtered_keypoints =
      pose_data
      |> Keypoints.extract()
      |> Keypoints.filter_by_confidence(0.8)  # Only keypoints with confidence >= 0.8
    IO.inspect(filtered_keypoints, label: "Filtered Keypoints")

  {:error, reason} ->
    IO.puts("Error: #{reason}")
end

**4. Calculating Joint Angles (Example - simplified):**
elixir
# Note: This is a simplified example.  Real-world angle calculations require more complex logic.
alias SupermakerAIPoseGenerator.Client
alias SupermakerAIPoseGenerator.Keypoints

defmodule PoseHelper do
  def calculate_angle(keypoints) do
    # This is a placeholder - implement your angle calculation logic here.
    # Example: Assuming keypoints contain :left_shoulder, :left_elbow, :left_wrist
    case {keypoints[:left_shoulder], keypoints[:left_elbow], keypoints[:left_wrist]} do
      {%{x: sx, y: sy}, %{x: ex, y: ey}, %{x: wx, y: wy}} ->
        # Simplified calculation (not accurate, just illustrative)
        angle = abs(atan2(wy - ey, wx - ex) - atan2(sy - ey, sx - ex)) * 180 / :math.pi
        {:ok, angle}
      _ ->
        {:error, :missing_keypoints}
    end
  end
end


image_url = "https://example.com/yoga_pose.jpg"

Client.estimate_pose_from_url(image_url)
|> case do
  {:ok, pose_data} ->
    keypoints = SupermakerAIPoseGenerator.Keypoints.extract(pose_data)
    case PoseHelper.calculate_angle(keypoints) do
      {:ok, angle} ->
        IO.puts("Calculated Angle: #{angle}")
      {:error, reason} ->
        IO.puts("Error calculating angle: #{reason}")
    end
  {:error, reason} ->
    IO.puts("Error: #{reason}")
end

**5. Handling Multiple People in an Image (if supported by the underlying API):**
elixir
alias SupermakerAIPoseGenerator.Client

image_url = "https://example.com/group_photo.jpg"

Client.estimate_pose_from_url(image_url)
|> case do
  {:ok, pose_data_list} when is_list(pose_data_list) -> # Expecting a list of pose data for each person
    Enum.each(pose_data_list, fn pose_data ->
      keypoints = SupermakerAIPoseGenerator.Keypoints.extract(pose_data)
      IO.inspect(keypoints, label: "Keypoints for a person")
    end)
  {:ok, pose_data} -> # Handle case where the API only returns one person.
    keypoints = SupermakerAIPoseGenerator.Keypoints.extract(pose_data)
      IO.inspect(keypoints, label: "Keypoints for a person")
  {:error, reason} ->
    IO.puts("Error: #{reason}")
end

## Features

*   Simplified interface for pose estimation APIs.
*   Functions to extract and filter keypoints from pose data.
*   Consistent data structures for representing pose information.
*   Easy integration into Elixir applications using pipes and pattern matching.
*   Provides a foundation for building more advanced pose-based applications.

## License

MIT

This package is part of the supermaker-ai-pose-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/unlock-perfect-poses-the-ultimate-guide-to-ai-pose-generators/