ApBase API Development Guide

ApBase API Development Guide

Current as of Release 5.0.37

 

Introduction

The ApBase API provides an easy to use interface for controlling Aptina demo kit cameras.
ApBase performs these primary functions:

  •  

    • Enumerate all of the demo kit cameras that are connected to the host PC.

    • Run initialization scripts start the camera or change modes.

    • Provide read/write access to sensor/SOC/ISP registers. Further, ApBase understands what register settings on the sensor do, keeps track of all relevant sensor modes, and automatically updates the demo kit hardware when the sensor mode changes. For example, if a register write enables MIPI output from the sensor, ApBase will automatically enable the MIPI receiver on the demo kit hardware.

    • Receive images from the camera device.

    • Convert the image received from the demo kit into RGB for saving to a file or displaying on the screen.

Additional Information can be found in the following documents

  • State Variables; as used in INI files with "STATE=", see "ap_GetState" and "ap_SetState" for usage.

  • Modes; there are a few modes setings from INI files, see "ap_GetMode" and "ap_SetMode" for usage.

  • "apbase.h"; many other calls are available and found by searching for "ap_".

ApBase API is available in 64-bit only.

Quick Start

To use ApBase in C or C++, include the apbase.h header file, and link to apbase.lib.

When running the application, be sure that the following folders supplied with the DevWare installer are present;

    • apps_data, board_data, and sensor_data

Sample programs can be found here:

    • C:\Aptina Imaging\samples\SimpleQt

    • C:\Aptina Imaging\samples\SimpleCapture

 

Here is a minimal procedure to open a demo kit camera, initialize the Aptina device, grab an image and convert it to RGB.

#include "apbase.h"

AP_HANDLE hApBase = ap_Create(0);
if (hApBase == NULL)
    return;

ap_LoadIniPreset(hApBase, NULL, NULL);   // initialize the sensor with the default from "Demo Initialization" preset

       // Read all sensor registers and configure the Demo3 and software according to the sensor settings.
       ap_CheckSensorState(apbase, 0);

size_t bufSize = ap_GrabFrame(hApBase, NULL, 0);
unsigned char *pBuffer = new unsigned char [bufSize];
ap_GrabFrame(hApBase, pBuffer, bufSize);

unsigned char *pRGB = NULL;
ap_u32 rgbWidth = 0, rgbHeight = 0, rgbBitDepth = 0;
if (ap_GetLastError() == MI_CAMERA_SUCCESS)
    pRGB = ap_ColorPipe(hApBase, pBuffer, bufSize, &rgbWidth, &rgbHeight, &rgbBitDepth);

delete [] pBuffer;
ap_Destroy(hApBase);
ap_Finalize();

Note: The call to ap_LoadIniPreset() with NULL parameters is only applicable in situations where the default initialization is sufficient. For demo kits with multiple possible configurations, such as ISP + sensor combinations or different connection options, you will need to specify the particular initialization preset for the configuration.

Note: when using a Demo3, it is recommended to perform a single call to ap_GrabFrame() after the call to ap_LoadIniPreset() to ensure that the Demo3 FIFO doesn't have a partial frame.

Please check out our YouTube video on ApBase for a quick overview.

Functions for Enumerating and Opening Devices

If using a specific verison of Python, set the path first using ap_SetPythonEnvPath().

To access the camera, first create a device handle using a Create call, or a Probe call followed by a Create call.

void ap_SetPythonEnvPath(const char *szPythonDir)

Parameters

Python install path; for example, "\\Users\\acecoder\\AppData\\Local\\Programs\\Python\\Python39".

Comments