{
  "openapi": "3.0.0",
  "info": {
    "title": "髪密度分析",
    "description": "# 概要\nAI 髪密度分析では、アップロードした 1 枚の画像から頭皮の可視性と髪の分布パターンを評価し、髪の密度を 4 つのレベルに分類します。\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/strapi/assets/AI_hair_density_S3_02_b34f2db2ce.jpg)\n\n## 統合ガイド\n* AI 髪密度分析用の写真の撮影方法\n* セルフィーを撮影する\n  - カメラを正面に向け、適切な照明の下で頭を45度下げてください。髪を結ばず、生え際全体がはっきりと見えるようにしてください。\n\n  ![](https://d3ss46vukfdtpo.cloudfront.net/static/media/img_popup_step_animated_02.aadf7a34.png)\n\n  - 代わりに、JS Camera Kit を使用して写真を撮影してください。\n\n* AI による髪密度の検出方法\n* ***/s2s/v2.0/file*** API を使用して、以下のアセットをアップロードします：\n  - セルフィー写真。\n\n* AI タスク ***/s2s/v2.0/task/hair-density-detection*** を実行 </br>\n正面から45度下げたセルフィー画像を1枚送信して検出タスクを実行します。AI のソース入力としてそのファイル ID を使用します。\n\n* タスクのステータスを成功またはエラーになるまでポーリングして確認する</br>\nこの ***task_id*** は、GET 'task/hair-density-detection' によるポーリングを通じてタスクのステータスを監視するために使用され、現在のエンジンステータスを取得します。エンジンがタスクを完了するまで、ステータスは 'running' のままであり、この段階ではユニットは消費されません。\n\n\n## 髪密度の分類\n\n|サムネイル|髪密度の分類|説明|\n| ----  | ----  | ----  |\n|![](https://d3ss46vukfdtpo.cloudfront.net/static/media/dt_classification_LV01.5097a6c2.png)|レベル 1<br>極めて低い密度|髪が著しくまばらで、広い範囲で頭皮が見えます。|\n|![](https://d3ss46vukfdtpo.cloudfront.net/static/media/dt_classification_LV02.7966983d.png)|レベル 2<br>低い密度|特に頭頂部や分け目で頭皮がはっきりと見える、目立つ薄毛があります。|\n|![](https://d3ss46vukfdtpo.cloudfront.net/static/media/dt_classification_LV03.c49dbfb7.png)|レベル 3<br>中程度の密度|直射日光の下で頭皮が部分的に見えますが、髪は中程度のボリュームとカバー率を維持しています。|\n|![](https://d3ss46vukfdtpo.cloudfront.net/static/media/dt_classification_LV04.e467f2aa.png)|レベル 4<br>高い密度|髪はふさふさで厚く見え、頭皮はほとんどまたは全く見えません。|\n\n\n* 撮影方法のヒント\n\n![撮影方法のヒント](https://bcw-media.s3.ap-northeast-1.amazonaws.com/strapi/assets/icon_S2_step1_20d0a161da.png \"撮影方法のヒント\")\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/strapi/assets/AI_hair_density_S1_02_f60369b14d.jpg)\n\n## ファイル仕様とエラー\n* 対応フォーマットと寸法\n\n|タイプ|対応寸法|対応ファイルサイズ|対応フォーマット|\n|  ----  | ----  | ----  | ----  |\n|AI 髪密度分析|画像は幅と高さが少なくとも100ピクセル、いずれかの次元で4096ピクセル以下である必要があります。画像の片方の辺が1080ピクセルを超える場合、分析のためにその制限内に自動的にリサイズされます。|< 10MB|jpg/png|\n\n* エラーコード\n\n|エラーコード|説明|\n|  ----  | ----  |\n|error_below_min_image_size|画像の幅または高さが100ピクセル未満の場合、小さすぎて使用できません|\n|error_face_position_invalid|画像内で顔全体が完全に可視であり、一部が切れていない必要があります|\n|error_face_position_too_small|写真内の顔が小さすぎて適切に分析できません|\n|error_face_position_out_of_boundary|顔が大きすぎるか、写真の端の一部が外れています|\n|error_insufficient_lighting|照明が暗すぎて、分析が困難です|\n|error_face_angle_invalid|顔の角度が正しくありません。正面を向いた撮影では、頭を正面から10度以内に保ってください。横を向いた撮影では、角度は15度以上である必要があります|\n\n* 環境と依存関係\n\n| サンプルコード言語 / ツール | 推奨ランタイムバージョン |\n|---|---|\n| cURL | - bash >= 3.2</br>   - curl >= 7.58 (モダンな TLS/HTTP サポート)</br>   - jq >= 1.6 (堅牢な JSON 解析) |\n| Node.js (JavaScript) | Node >= 18 (グローバル fetch のため) |\n| JavaScript | - Chrome / Edge >= 80</br>   - Firefox >= 74</br>   - Safari >= 13.1 |\n| PHP | PHP >= 7.4 (モダンな TLS/互換性のため)、ext-curl (推奨) または allow_url_fopen=On + ext-openssl、ext-json |\n| Python | Python >= 3.10 (f-strings のため)、requests >= 2.20.0 |\n| Java | Java 11+ (HttpClient のため)、Jackson Databind >= 2.12.0 |\n\n---\n\n## JS Camera Kit\n{% partial file=\"/_partials/js-camera-kit.md\" /%}\n\n---\n\n## ユニット消費\n\n| AI 機能 | 消費ユニット |\n|---|---|\n| AI 髪密度分析 V1.0 | 1 |\n\n---\n",
    "version": "",
    "termsOfService": "https://www.makeupar.com/perfectbeauty/youcam/terms-of-service-api",
    "contact": {
      "email": "YouCamOnlineEditor_API@perfectcorp.com"
    },
    "license": {
      "name": "Privacy policy",
      "url": "https://www.makeupar.com/perfectbeauty/youcam/privacy-policy-api"
    }
  },
  "servers": [
    {
      "url": "https://yce-api-01.makeupar.com"
    }
  ],
  "tags": [
    {
      "name": "V1.0",
      "description": "分析用の AI 駆動型髪密度検出機能。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/hair-density-detection": {
      "post": {
        "summary": "髪密度分析タスクを実行します。",
        "description": "タスクのステータスを確認するにはポーリングが必要です。詳細はポーリングガイドを参照してください。",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasicRunTaskV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "タスクの実行に成功しました",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicRunTaskResponseV2"
                }
              }
            }
          },
          "400": {
            "description": "タスクの実行に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/responses/RunError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/s2s/v2.0/task/hair-density-detection/{task_id}": {
      "get": {
        "summary": "髪密度分析タスクのステータスを確認します。",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
            },
            "description": "確認するタスクの ID"
          }
        ],
        "responses": {
          "200": {
            "description": "髪密度分析タスクのステータス確認に成功しました。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "description": "レスポンスステータス",
                      "example": 200
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "task_status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "success",
                            "error"
                          ],
                          "description": "このタスクのステータス"
                        },
                        "error": {
                          "$ref": "#/components/schemas/EngineErrorCode"
                        },
                        "error_message": {
                          "type": "string",
                          "description": "エラーの詳細な説明"
                        },
                        "results": {
                          "allOf": [
                            {
                              "type": "object",
                              "properties": {
                                "timed": {
                                  "type": "number"
                                },
                                "hair_density": {
                                  "$ref": "#/components/schemas/BasicHairDensityRespHairDensity"
                                }
                              }
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidTaskId"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "500": {
            "$ref": "#/components/responses/TaskTimeout"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "exceed_max_filesize",
          "invalid_parameter",
          "error_download_image",
          "error_download_mask",
          "error_decode_image",
          "error_decode_mask",
          "error_nsfw_content_detected",
          "error_no_face",
          "error_pose",
          "error_face_parsing",
          "error_inference",
          "exceed_nsfw_retry_limits",
          "error_upload",
          "unknown_internal_error"
        ],
        "description": "エラー:\n- `exceed_max_filesize` - 入力ファイルサイズが最大制限を超えています\n- `invalid_parameter` - 無効なパラメータ値\n- `error_download_image` - ソース画像のダウンロードエラー\n- `error_download_mask` - マスク画像のダウンロードエラー\n- `error_decode_image` - ソース画像のデコードエラー\n- `error_decode_mask` - マスク画像のデコードエラー\n- `error_nsfw_content_detected` - ソース画像に NSFW コンテンツが検出されました\n- `error_no_face` - ソース画像に顔が検出されませんでした\n- `error_pose` - ソース画像でのポーズ検出に失敗しました\n- `error_face_parsing` - ソース画像での顔セグメンテーションに失敗しました\n- `error_inference` - 推論パイプラインエラー\n- `exceed_nsfw_retry_limits` - NSFW 画像生成を避けるためのリトライ制限を超えました\n- `error_upload` - 結果画像のアップロードエラー\n- `unknown_internal_error` - その他\n"
      },
      "FileV1.1": {
        "title": "File V1.1",
        "description": "このオブジェクトはファイルを表現します。",
        "type": "object",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "content_type",
                "file_name",
                "file_size"
              ],
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "このファイルのコンテンツ MIME タイプ。現在利用可能な値は enum に記載されています。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "このファイルの名前"
                },
                "file_size": {
                  "type": "integer",
                  "example": 50000,
                  "description": "このファイルのコンテンツ長（バイト単位）。10MB を超えてはいけません。"
                }
              }
            }
          }
        }
      },
      "BasicFileResponse": {
        "type": "object",
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "このファイルのコンテンツ MIME タイプ。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "このファイルの名前"
                },
                "file_id": {
                  "type": "string",
                  "example": "U8aqJbsXGT537jtGnEDFHqxdDXqh8+oTF/cSkLimzuvVwMP+Jb1XbjPsf7ZgUgLY",
                  "description": "このファイルの ID。他のタスク実行 API ではこの `file_id` が必要です。"
                },
                "requests": {
                  "type": "array",
                  "description": "以下の `url`、`headers`、`method` を使用してファイルをアップロードします。完了後、`file_id` を使用してタスク実行 API の呼び出しを進めます。",
                  "items": {
                    "type": "object",
                    "properties": {
                      "headers": {
                        "type": "object",
                        "example": {
                          "Content-Type": "image/jpg",
                          "Content-Length": 50000
                        },
                        "description": "ファイルのアップロード時に含めるヘッダー"
                      },
                      "url": {
                        "type": "string",
                        "example": "https://example.com/presigned-upload-url",
                        "description": "このファイルをアップロードする URL"
                      },
                      "method": {
                        "type": "string",
                        "example": "PUT",
                        "description": "このファイルをアップロードするための HTTP メソッド"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "FileResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 200,
            "description": "レスポンスステータス"
          },
          "data": {
            "$ref": "#/components/schemas/BasicFileResponse"
          }
        }
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "レスポンスステータス",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "このタスクの ID。タスクの結果はこの ID で 24 時間有効です。",
                "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
              }
            }
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "title": "src ファイル ID でタスクを実行",
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "タスクを実行するファイルの ID。ファイルアップロード API からのファイル ID です。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskV2SrcFileUrl": {
        "title": "src ファイル URL でタスクを実行",
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "タスクを実行するファイルの URL。この URL は公開アクセス可能である必要があります。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2": {
        "title": "BasicRunTaskV2",
        "anyOf": [
          {
            "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
          },
          {
            "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
          }
        ]
      },
      "BasicHairDensityRespHairDensity": {
        "type": "object",
        "properties": {
          "mapping": {
            "type": "string",
            "description": "文字列形式の float",
            "minimum": "0",
            "maximum": "3",
            "example": "2.16"
          },
          "term": {
            "type": "string",
            "enum": [
              "Extremely Low Density",
              "Low Density",
              "Medium Density",
              "High Density"
            ]
          }
        }
      }
    },
    "responses": {
      "BadRequestAndInvalidParameters": {
        "description": "クライアントエラーまたは無効なリクエストパラメータによりリクエストを処理できません",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "レスポンスステータス"
                },
                "error": {
                  "type": "string",
                  "description": "エラーメッセージ",
                  "example": "The operation could not be completed"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "BadRequest",
                    "InvalidParameters"
                  ],
                  "description": "エラーコード:\n  * BadRequest - 予期しないリクエストパラメータまたはボディ\n  * InvalidParameters - 無効なリクエストパラメータまたはボディ\n"
                }
              }
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "無効な API キー、非アクティブな API キー、または期限切れの API キー",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "レスポンスステータス"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidApiKey",
                    "InactiveApiKey",
                    "ExpiredApiKey"
                  ],
                  "description": "エラーコード:\n  * InvalidApiKey - API キーが指定されていないか、有効ではありません\n  * InactiveApiKey - API キーが非アクティブ化されています\n  * ExpiredApiKey - API キーが期限切れです\n"
                }
              }
            }
          }
        }
      },
      "RunError": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "レスポンスステータス",
            "example": 400
          },
          "error": {
            "type": "string",
            "description": "エラーメッセージ",
            "example": "The operation could not be completed"
          },
          "error_code": {
            "type": "string",
            "enum": [
              "CreditInsufficiency",
              "InvalidStyleGroup",
              "InvalidStyle",
              "BadRequest",
              "InvalidParameters"
            ],
            "description": "エラーコード:\n  * CreditInsufficiency - 実行に必要なユニットが不足しています\n  * BadRequest - 予期しないリクエストパラメータ\n  * InvalidStyleGroup - 無効なスタイルグループ ID\n  * InvalidStyle - 無効なスタイル ID\n  * InvalidParameters - 無効なリクエストパラメータ\n"
          }
        }
      },
      "InvalidTaskId": {
        "description": "無効なタスク ID",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "レスポンスステータス",
                  "example": 400
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidTaskId"
                  ],
                  "description": "エラーコード:\n  * InvalidTaskId - 無効なタスク ID\n"
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "一定時間内にリクエストが多すぎます"
      },
      "TaskTimeout": {
        "description": "タスクが期待される時間内にレスポンスを返しません",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "レスポンスステータス",
                  "example": 500
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "TaskTimeout"
                  ],
                  "description": "エラーコード:\n  * TaskTimeout - タスクが期待される時間内にレスポンスを返しません\n"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "標準の 'Bearer authentication' を使用します。ヘッダーに 'API Key' を設定します: `Authorization:Bearer YOUR_API_KEY`。'Bearer' と 'YOUR_API_KEY' の間にスペースがあることに注意してください。"
      }
    }
  }
}