0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

iOSアプリにTencent Cloud TRTCのBeauty SDKを導入する方法

Posted at

🎯 導入の背景

iOSアプリでリアルタイムビデオ通話を行う際、ユーザーから「自然な美顔機能を付けてほしい」という要望が多くありました。
以下の条件でSDKを検討しました:

  • 通話中にリアルタイムで美顔・美白・顔補正が可能
  • 他SDKと同時に利用できる(TRTC通話機能との統合)
  • iOSネイティブアプリに短期間で導入できる

🔍 技術調査と選定理由

項目 TRTC Beauty SDKの特徴
機能 美肌、ホワイトニング、赤み、顔細見、目拡大など
パフォーマンス iPhone 11以上で60fpsに近い処理可能
UI 組み込みの美顔パネル(TRTCBeautyViewController)
柔軟性 プログラムからパラメータを個別に設定できる
サポート 日本語サポートは限定的だが英語/中国語は充実

📦 プロジェクトセットアップ

1. PodfileにTRTC SDKを追加

pod 'TXLiteAVSDK_TRTC'

インストール後:

pod install

2. Info.plist権限

<key>NSCameraUsageDescription</key>
<string>ビデオ通話のためカメラを使用します</string>
<key>NSMicrophoneUsageDescription</key>
<string>音声通話のためマイクを使用します</string>

🚀 実装ステップ

1. TRTCCloudの初期化と通話開始

#import <TXLiteAVSDK_TRTC/TRTCCloud.h>

TRTCCloud *trtcCloud = [TRTCCloud sharedInstance];

TRTCParams *params = [[TRTCParams alloc] init];
params.sdkAppId = 1400000000;
params.userId = @"user001";
params.userSig = @"xxxxxx";
params.roomId = 1234;
params.role = TRTCRoleAnchor;

[trtcCloud enterRoom:params appScene:TRTCAppSceneVideoCall];
[trtcCloud startLocalPreview:YES view:self.localView];
[trtcCloud startLocalAudio:TRTCAudioQualityDefault];

2. Beauty Managerを取得し設定

TXBeautyManager *beautyManager = [trtcCloud getBeautyManager];

// 美肌スタイル
[beautyManager setBeautyStyle:TRTCBeautyStyleSmooth];
// 美肌レベル (0-9)
[beautyManager setBeautyLevel:5];
// ホワイトニング (0-9)
[beautyManager setWhitenessLevel:3];
// 赤み補正 (0-9)
[beautyManager setRuddyLevel:2];
// 目の拡大 (0-9)
[beautyManager setEyeScaleLevel:2];
// 顔の細見 (0-9)
[beautyManager setFaceSlimLevel:3];

3. ビルトイン美顔パネルを表示する

#import <TXLiteAVSDK_TRTC/TRTCBeautyPanel.h>

TRTCBeautyPanel *beautyPanel = [[TRTCBeautyPanel alloc] initWithTRTCCloud:trtcCloud frame:CGRectMake(0, self.view.bounds.size.height - 300, self.view.bounds.size.width, 300)];
[self.view addSubview:beautyPanel];

🌟 追加サンプル:動的パラメータ調整

通話中に美顔レベルを変更する例:

- (void)beautyLevelChanged:(float)value {
    TXBeautyManager *beautyManager = [trtcCloud getBeautyManager];
    [beautyManager setBeautyLevel:value];
}

顔補正プリセットを作る例:

- (void)applyNaturalPreset {
    TXBeautyManager *beautyManager = [trtcCloud getBeautyManager];
    [beautyManager setBeautyStyle:TRTCBeautyStyleNature];
    [beautyManager setBeautyLevel:3];
    [beautyManager setWhitenessLevel:2];
    [beautyManager setRuddyLevel:1];
}

✅ テスト結果

項目 結果
処理速度 iPhone12でfps低下なし
効果 肌補正・目の拡大とも自然に適用
安定性 通話中にON/OFFしてもクラッシュなし
UI ビルトインパネルは分かりやすく操作性が高い

📝 まとめ

TRTC Beauty SDKは以下の特徴で非常に実用的です:

  • SDK一体型で設定がシンプル
  • ビルトインUI・プログラム設定両方対応
  • 高速・高画質な処理が可能

今後の計画:

  • プリセット保存機能の追加
  • CDN配信との併用テスト
  • 複数カメラ切替との統合

🔗 参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?