Skip to content

C Wrapper

TianZerL edited this page Aug 8, 2020 · 1 revision

About C Wrapper

This is a C binding of Anime4KCPP core API, which supports standard C language, and can also be used as an intermediary for binding to other programming languages.

Simple Example

/*  
 *  Description: Example for showing a processed image by GPUCNN
 *  Author: TianZerL
 */

#include <stdio.h>

#include "AC.h"

int main(void)
{
    ac_error err;
    ac_parameters p;
    // set parameters
    err = acInitParameters(&p);
    if (err != AC_OK)
        fprintf(stderr, "ERROR CODE: %d", err);
    p.HDN = AC_TRUE;
    p.HDNLevel = 3;
    // get ac instance, initialize GPUCNN, and set processor type as GPUCNN
    ac_instance ac = acGetInstance(AC_FALSE, AC_TRUE, 0, 0, &p, AC_GPUCNN, &err);
    if (err != AC_OK)
        fprintf(stderr, "ERROR CODE: %d", err);
    // load image from disk
    err = acLoadImage(ac, "./p1.png");
    if (err != AC_OK)
        fprintf(stderr, "ERROR CODE: %d", err);

    err = acProcess(ac);
    if (err != AC_OK)
        fprintf(stderr, "ERROR CODE: %d", err);

    err = acShowImage(ac, AC_FALSE);
    if (err != AC_OK)
        fprintf(stderr, "ERROR CODE: %d", err);
    // free ac instance and release GPU
    acFreeInstance(ac, AC_TRUE, AC_TRUE);

    return 0;
}
Clone this wiki locally