All Products
Search
Document Center

ApsaraVideo Live:Integrate for Windows

Last Updated:Jul 18, 2023

This topic describes how to integrate for Windows.

Prerequisites

The requirements described in the following table are met.

Item

Description

Operating system

Windows 7 or later.

Development environment

Visual Studio 2010 or later. We recommend that you use Visual Studio 2017.

Integrate for C++

This section describes how to integrate and use Queen SDK for Windows. In this example, Visual Studio 2017 is used to create a C++ console app project, and for C++ is integrated with the project.

  1. Click Download to download Queen SDK.

    Decompress the downloaded SDK package. The following table describes the folders inside.

    Folder

    Description

    include

    Contains header files. The header files contain detailed comments on methods.

    lib

    Contains the .lib file for compilation and the .dll files to be loaded when you run the SDK.

    queen_res

    Contains the resource files that are necessary when you run the SDK.

    res

    Contains the resource files for retouching effects. Files in this folder are optional if you want to use custom retouching materials.

  2. Create a project.

    Open Visual Studio and create a C++ console app project named AliyunQueenSDKDemo.

  3. Copy the files.

    In the directory where the AliyunQueenSDKDemo.vcxproj file is located, create a folder named AliyunQueenSDK. Copy the folders decompressed from the SDK package to the AliyunQueenSDK folder that you create.

  4. Configure the project.

    In the Solution Explorer section, right-click AliyunQueenSDKDemo and select Properties. In the AliyunQueenSDKDemo Property Pages dialog box, perform the following steps:

    1. Add the include directory. In the left-side navigation pane, choose C/C++ > General. In the Additional Include Directories field, enter $(ProjectDir)AliyunQueenSDK\include.

    2. Add the library directory. In the left-side navigation pane, choose Linker > General. In the Additional Library Directories field, enter $(ProjectDir)AliyunQueenSDK\lib\$(PlatformShortName).

    3. Add the library file. In the left-side navigation pane, choose Linker > Input. In the Additional Dependencies field, enter queen.lib.

    4. Add copy commands. In the left-side navigation pane, choose Build Events > Post-Build Event. In the Command Line field, enter the following commands.

      Note

      If you configure the copy commands, Visual Studio automatically copies the .dll files, queen_res folder, and res folder to the project folder after compilation.

      xcopy "$(ProjectDir)AliyunQueenSDK\lib\$(PlatformShortName)\*.dll" "$(TargetDir)" /y

      xcopy "$(ProjectDir)AliyunQueenSDK\queen_res" "$(TargetDir)queen_res" /i /s /y

      xcopy "$(ProjectDir)AliyunQueenSDK\res" "$(TargetDir)res" /i /s /y

  5. Call the methods in the SDK and run your program.

    1. Replace the content of the AliyunQueenSDKDemo.cpp file with the following code:

      #include 
      #include "queen_engine.h"
      using namespace queen;
      using namespace std;
      int main()
      {
      const char* queenSDKVersion = queen_engine_getSDKVersion();
      cout << "Hello QueenEngine: " << queenSDKVersion << endl;
      }
    2. Press the F5 key on the keyboard. The console is enabled after the code is compiled.

Usage examples of Queen SDK

  1. Initialize QueenEngine.

    // Build the OpenGL environment. You can skip this step if an OpenGL environment exists.
    queen::GlfwWindow* glWindow = new queen::GlfwWindow();// The OpenGL environment.
    if (!glWindow->Init(width, height, false))// A GPU driver may be not installed on your computer.
    {
      return;
    }
    // Create QueenEngine.
    // Replace rootPath with the parent directory where the queen_res folder resides. If you do not specify this parameter, the exe directory is used.
    queen_engine_t handle_beauty;
    if (QUEEN_RESULT_CODE_OK != queen_engine_create(&handle_beauty, rootPath,
    "123456"))
    {
      return;
    }
  2. Enable effects and set effect parameters.

    // Enable skin smoothing.
    queen_engine_enableBeautyType(handle_beauty, kQueenBeautyTypeSkinBuffing,
    true);
    // Set the parameters for skin smoothing and image sharpening.
    queen_engine_setBeautyParams(handle_beauty,
    kQueenBeautyParamsSkinBuffing, 0.6f); // The level of skin smoothing. Valid values: [0,1].
    queen_engine_setBeautyParams(handle_beauty, kQueenBeautyParamsSharpen,
    0.8f); //// The level of image sharpening. Valid values: [0,1].
  3. Process the frame image data.

    // Process the frame image data and return the processed data to the bufferOut parameter.
    if (QUEEN_RESULT_CODE_OK != queen_engine_render_with_i420(handle_beauty,
    bufferIn, width, height, bufferOut))
    {
      return;
    }
  4. Destroy QueenEngine.

    // Release the engine. Make sure that the thread for processing the frame image data is used to release the engine.
    queen_engine_destory(handle_beauty);
    // Remove the OpenGL environment.
    delete glWindow;

References

  • For more usage examples of Queen SDK, see the ConsoleDemo/AliyunQueenSDKDemo/AliyunQueenSDKDemo/AliyunQueenSDKDemo.cpp file in the downloaded SDK package.

  • For more information about the methods of Queen SDK, see AliyunQueenSDK.