Skip to content

Latest commit

History

175 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Online Documentation (Recommended)

🌐 https://insta360develop.github.io/Insta360-Developer_Docs/

⚠️ If the above Pages site fails to load (access to github.io is unstable on some networks), you may directly browse the Markdown documents at the link below: https://github.com/Insta360Develop/Insta360-Developer_Docs

⚠️ This repository will no longer be maintained moving forward; all subsequent content will be migrated to the aforementioned Online Documentation.

Note:

Currently on V1.9.4 branch. To view other versions, please switch branches.

32-bit library (armeabi-v7a) is no longer maintained, please use 64-bit library (arm64-v8a) to build!

FAQ

How to get?

Please visit https://www.insta360.com/sdk/apply to apply for the latest SDK.

Support

Developers' Page: https://www.insta360.com/developer/home
Insta360 Enterprise: https://www.insta360.com/enterprise
Issue Report: https://insta.jinshuju.com/f/hZ4aMW

Overview

The Android SDK is mainly used for connecting, setting and obtaining camera parameters, controlling the camera for taking photos and recording, downloading files, firmware upgrades, and supporting video and image exports.

Supported models: X5, X4, X3, ONE X2, ONE X, ONE RS, ONE RS 1-Inch.

Table of contents

Camera SDK Function

Environmental Preparation

Add the Maven repository to the build file (the build.gradle file in the project root):

allprojects {
repositories {
...
maven {
url 'x.x.x'// see sdk demo
credentials {
// see sdk demo
username ='***'
password ='***'
} }
}
}
  • Import the dependency library in the build.gradle file located in the Demo directory:
dependencies {
implementation 'com.arashivision.sdk:sdkcamera:x.x.x'// see sdk demo
}
  • Initialize the SDK in the application
publicclassMyAppextendsApplication {
@OverridepublicvoidonCreate() {
super.onCreate(); InstaCameraSDK.init(this);
}
}

Connection Module

Determine if the Camera is Connected

You can determine if the camera is connected by obtaining the current camera connection type.

privatebooleanisCameraConnected() {
inttype = InstaCameraManager.getInstance().getCameraConnectedType();
returntype != InstaCameraManager.CONNECT_TYPE_NONE;
}

The connection types have the following four outcomes:

  1. Not connected:InstaCameraManager.CONNECT_TYPE_NONE
  2. USB connection:InstaCameraManager.CONNECT_TYPE_USB
  3. Wi-Fi connection:InstaCameraManager.CONNECT_TYPE_WIFI
  4. Bluetooth connection:InstaCameraManager.CONNECT_TYPE_BLE

Connecting the Camera

You can connect to the camera via Bluetooth, Wi-Fi, or USB

Note: You must perform the connection operation on the main thread.

Note: When the camera is connected, if the app switches to the background, it will disconnect due to the characteristics of the Android system. Therefore, it is necessary to enable a foreground service to prevent disconnection from the camera. This foreground server is implemented by the developer themselves. The relevant code can refer to the SDK Demo.

Bluetooth Connection

Note: Bluetooth connection requires successful authorization of Bluetooth-related permissions.

Note: In the case of a Bluetooth connection, large data transmission is not supported. Therefore, functions that transmit large amounts of data are not supported.

For example: live streaming, preview, support list, firmware upgrade, playback, export, etc.

  1. Initialize Bluetooth Scanning
InstaCameraManager.getInstance().startBleScan();
  1. Set the Bluetooth Scanning Listener
InstaCameraManager.getInstance().setScanBleListener(newIScanBleListener() {
@OverridepublicvoidonScanStartSuccess() {
//Bluetooth is about to start scanning
}
@OverridepublicvoidonScanStartFail() {
//Bluetooth scanning failed
}
@OverridepublicvoidonScanning(BleDevicebleDevice) {
//A new Bluetooth device has been scanned; you can update the Bluetooth device list here
}
@OverridepublicvoidonScanFinish(List<BleDevice> bleDeviceList) {
//Bluetooth scanning finished
}
});
  1. Stopping Bluetooth Scanning
InstaCameraManager.getInstance().stopBleScan();
  1. Checking if Bluetooth is Scanning
InstaCameraManager.getInstance().isBleScanning();
  1. Establishing a Bluetooth Connection with the Camera
InstaCameraManager.getInstance().connectBle(bleDevice);

Wi-Fi Connection

Note: Ensure that the phone is already connected to the camera’s Wi-Fi.The Wi-Fi password of the camera can be viewed in the settings menu of the camera, or by connecting via Bluetooth and calling to read the Wi-Fi information (SSID and password) of the camera.

InstaCameraManager.getInstance().openCamera(InstaCameraManager.CONNECT_TYPE_WIFI);

USB Connection

Note: Ensure that the phone and camera have established a USB connection, and the camera must be switched to Android mode.

InstaCameraManager.getInstance().openCamera(InstaCameraManager.CONNECT_TYPE_USB);

Disconnecting the Camera

When you want to disconnect the camera, you can call the following code.

InstaCameraManager.getInstance().closeCamera();

Wi-Fi Management Module

Camera Wi-Fi On and Off

When connected to Bluetooth, the camera's Wi-Fi can be turned on and off using the following code.

ICameraOperateCallbackcallback = newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// The command was executed successfully
}
@OverridepublicvoidonFailed() {
// Command execution failed
}
@OverridepublicvoidonCameraConnectError() {
// The camera is disconnected or not connected
}
};
// Turn on the camera's wifi and use the camera's default channelInstaCameraManager.getInstance().openCameraWifi(callback);
// Open the camera wifi on the specified channelInstaCameraManager.getInstance().openCameraWifi(intcountryChannel ,callback);
// Turn off camera wifiInstaCameraManager.getInstance().closeCameraWifi(callback)
// Restart the camera Wi-Fi, including two operations: turn off and turn on, use the camera's default channel to turn onInstaCameraManager.getInstance().resetCameraWifi(callback)
// Restart the camera Wi-Fi by specifying a channelInstaCameraManager.getInstance().resetCameraWifi(intcountryChannelcallback)

Get Wi-Fi Information

// Get camera Wi-Fi informationWifiInfowifiInfo = InstaCameraManager.getInstance().getWifiInfo();
// Wi-Fi nameStringssid = wifiInfo.getSsid();
// Wi-Fi passwordStringssid = wifiInfo.getPwd();
// Password versionintpwdVersion= wifiInfo.getPwdVersion();
// Wi-Fi channelintchannel= wifiInfo.getChannel();
// mac addressStringaddress = wifiInfo.getMacAddress();
// Get the Wi-Fi country codeStrincountry = InstaCameraManager.getInstance().getWifiCountry();

Switch Wi-Fi Channel

// Get current country code and Wi-Fi channelInstaCameraManager.getInstance().fetchWifiChannel((countryCode, cameraChannel) -> {
// Get country code and current Wi-Fi channel
});
// Set Wi-Fi country codeInstaCameraManager.getInstance().setWifiCountry("CN", newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// Setup successful
}
@OverridepublicvoidonFailed() {
// Setup failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection error
}
});
// Get Wi-Fi channel listint[] channelList = InstaCameraManager.getInstance().getWifiChannelList();

Information Acquisition Module

Synchronizing Camera Parameters

Synchronizing camera parameters means reading all the internal camera parameters at once and caching them in the application. Call the following code to synchronize all camera parameters (Synchronization of all parameters and status).

InstaCameraManager.getInstance().fetchCameraOptions(newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// Camera parameters synchronized successfully
}
@OverridepublicvoidonFailed() {
// Camera parameter synchronization failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection failed, which may indicate a camera disconnection event
}
});

Get the Camera Support List

For X4 and later cameras, the capturing mode and capturing properties of the camera are based on the properties configured in the support list. Different cameras support different capturing modes, and there are also differences in the capturing properties supported under different capturing modes. Before capturing, synchronize the camera's supported list (Json file).

Initialize Support List

When entering the prep page or switching lenses, the support list needs to be initialized. This can be achieved by calling the following code:

InstaCameraManager.getInstance().initCameraSupportConfig(success -> {
// success: Whether initialization was successful
});

Capturing Mode Support

Each lens of the camera supports different capturing modes. You need to use the following code to obtain its supported capturing modes.

// Get all supported capturing modesList<CaptureMode> support = InstaCameraManager.getInstance().getSupportCaptureMode();

Capturing Attribute Support

Each capturing mode supports different capturing attributes. You need to use the following code to obtain the supported capturing attributes.

// Pass in the specified capturing mode as parametersList<CaptureSetting> support = InstaCameraManager.getInstance().getSupportCaptureSettingList(CaptureMode.CAPTURE_NORMAL);

The Range of Values for Capturing Attributes

The value range of the capturing attribute is also configured in the support list. You need to use the following code to obtain the value range of the supported capturing attribute.

// Gets the property value range of CaptureSetting.RECORD_DURATION, returns a List < RecordDuration >InstaCameraManager.getInstance().getSupportRecordDurationList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.RECORD_RESOLUTION and return a List < RecordResolution >InstaCameraManager.getInstance().getSupportRecordResolutionList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.PHOTO_RESOLUTION and return a List < PhotoResolution >InstaCameraManager.getInstance().getSupportPhotoResolutionList(CaptureMode.CAPTURE_NORMAL);
// Get the range of property values of CaptureSetting. INTERVAL and return a List < Interval > listInstaCameraManager.getInstance().getSupportIntervalList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.HDR_STATUS and return a List < HdrStatus >InstaCameraManager.getInstance().getSupportHdrStatusList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.PHOTO_HDR_TYPE and return a List < PhotoHdrType >InstaCameraManager.getInstance().getSupportPhotoHdrTypeList(CaptureMode.CAPTURE_NORMAL);
// Get the value range of the property value of CaptureSetting.GAMMA_MODE and return a List < GammaMode >InstaCameraManager.getInstance().getSupportGammaModeList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.RAW_TYPE and return a List < RawType >InstaCameraManager.getInstance().getSupportRawTypeList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting.PANO_EXPOSURE_MODE and return a List < PanoExposureMode >InstaCameraManager.getInstance().getSupportPanoExposureList(CaptureMode.TIMELAPSE);
// Get the property value range of CaptureSetting. EXPOSURE and return a List < Exposure >InstaCameraManager.getInstance().getSupportExposureList(CaptureMode.TIMELAPSE);
// Get the value range of the CaptureSetting. ISO property and return a List < ISO >InstaCameraManager.getInstance().getSupportISOList(CaptureMode.TIMELAPSE);
// Gets the value range of the CaptureSetting.ISO_TOP_LIMIT property and returns a List < ISOTopLimit >InstaCameraManager.getInstance().getSupportISOTopLimitList(CaptureMode.TIMELAPSE);
// Gets the value range of the CaptureSetting.SHUTTER_MODE property and returns a List < ShutterMode >InstaCameraManager.getInstance().getSupportShutterModeList(CaptureMode.TIMELAPSE);
// Get the value range of the property value of CaptureSetting. SHUTTER and return a List < Shutter >InstaCameraManager.getInstance().getSupportShutterList(CaptureMode.TIMELAPSE);
// Get the value range of the attribute value of CaptureSetting. EV and return a List < Ev >InstaCameraManager.getInstance().getSupportEVList(CaptureMode.CAPTURE_NORMAL);
// Get the value range of the property value of CaptureSetting.EV_INTERVAL and return a List < EVInterval >InstaCameraManager.getInstance().getSupportEVIntervalList(CaptureMode.TIMELAPSE);
// Get the value range of the attribute value of CaptureSetting. AEB and return a List < AEB >InstaCameraManager.getInstance().getSupportAEBList(CaptureMode.TIMELAPSE);
// Get the value range of the CaptureSetting. WB attribute and return a List < WB >InstaCameraManager.getInstance().getSupportWBList(CaptureMode.TIMELAPSE);
// Gets the property value range of CaptureSetting.INTERNAL_SPLICING and returns a List < InternalSplicing >InstaCameraManager.getInstance().getSupportInternalSplicingList(CaptureMode.TIMELAPSE);
// Gets the value range of the CaptureSetting.DARK_EIS_ENABLE property and returns a List < DarkEisType >InstaCameraManager.getInstance().getSupportDarkEisList(CaptureMode.TIMELAPSE);
// Gets the property value range of CaptureSetting.BURST_CAPTURE, returns a List < BurstCapture >InstaCameraManager.getInstance().getSupportBurstCaptureList(CaptureMode.TIMELAPSE);
// Get the property value range of CaptureSetting.I_LOG and return a List<ILogStatus> listInstaCameraManager.getInstance().getSupportILogStatusList(CaptureMode.TIMELAPSE);

Camera Information Acquisition

Camera Type

// Get the camera type, such as: Insta360 X4StringcameraType = InstaCameraManager.getInstance().getCameraType();
// Get enumerationCameraTypetype = CameraType.getForType(cameraType);

Camera Serial Number

InstaCameraManager.getInstance().getCameraSerial();

Firmware Version

// Get the camera firmware version, e.g. 0.9.24StringfwVersion = InstaCameraManager.getInstance().getCameraVersion();

Camera Activation Time

// Get the camera activation time; the inactive time is 0.longactiveTime = InstaCameraManager.getInstance().getActiveTime();

SD Card Total Storage Capacity

// Get the total space size of the SD cardlongtotalSpace = InstaCameraManager.getInstance().getCameraStorageTotalSpace();

SD Card Available Storage Capacity

// Get the free space size of the SD cardlongfreeSpace = InstaCameraManager.getInstance().getCameraStorageFreeSpace();
// Get the remaining space size of the SD card (for photos, the unit is shots; for videos, the return value is the remaining recording time)intremaining= InstaCameraManager.getInstance().getRemaining(CaptureModecaptureMode);

Battery

// Get battery type// THICK = 0; //Thick battery// THIN = 1; //Thin battery (camera default)// VERTICAL; //Vertical shot battery// NONE; //Only USB power supply without batteryInstaCameraManager.getInstance().getBatteryType();
// Get current battery: 0-100intlevel = InstaCameraManager.getInstance().getCameraCurrentBatteryLevel();

Camera System Time

// Get camera system timelongmediaTime = InstaCameraManager.getInstance().getMediaTime();

Get Camera Status

Determine if the Camera is Charging

// Check if the camera is chargingbooleanisCharging = InstaCameraManager.getInstance().isCameraCharging();

Determine if the Camera is Working

// Check if the camera is workingbooleanisWorking = InstaCameraManager.getInstance().isCameraWorking();
//Check if the specified capturing mode is currently workingbooleanisNormalCapturing = InstaCameraManager.getInstance().isCameraWorking(CaptureMode.CAPTURE_NORMAL);

Determine if the SD Card is Usable

// Check if the SD card is usablebooleanisEnable = InstaCameraManager.getInstance().isSdCardEnabled();

Notification Module

You can register/unregister theICameraChangedCallback on multiple pages to monitor changes in the camera status.

publicabstractclassBaseObserveCameraActivityextendsAppCompatActivityimplementsICameraChangedCallback {
@OverrideprotectedvoidonCreate(@NullableBundlesavedInstanceState) {
super.onCreate(savedInstanceState);
InstaCameraManager.getInstance().registerCameraChangedCallback(this);
}
@OverrideprotectedvoidonDestroy() {
super.onDestroy();
InstaCameraManager.getInstance().unregisterCameraChangedCallback(this);
}
/** * Camera status change * * @param enabled: whether the camera is available * @param connectType: connection type */@OverridepublicvoidonCameraStatusChanged(booleanenabled, intconnectType) {
}
/** * Camera coneection failure * <p> * A common scenario is that another phone or another application on this phone has already established a connection with the camera, leading to a failure in establishing the connection, in which case, other phones must first disconnect from this camera. * @param errorCode: Error code, refer to the camera connection error code */@OverridepublicvoidonCameraConnectError(interrorCode) {
}
/** * SD card insertion notification * * @param enabled: whether the current SD card is available */@OverridepublicvoidonCameraSDCardStateChanged(booleanenabled) {
}
/** * SD card storage status change * * @param freeSpace: the current available capacity * @param totalSpace: the total capacity */@OverridepublicvoidonCameraStorageChanged(longfreeSpace, longtotalSpace) {
}
/** * Low battery notification */@OverridepublicvoidonCameraBatteryLow() {
}
/** * Camera power change notification * * @param batteryLevel: current power level(0-100,always returns 100 when charging) * @param isCharging: whether the camera is charging */@OverridepublicvoidonCameraBatteryUpdate(intbatteryLevel, booleanisCharging) {
}
/** * Camera temperature change notification * * @param tempLevel: temperature level */@OverridepublicvoidonCameraTemperatureChanged(TemperatureLeveltempLevel) {
}
}

Camera Lens Control Module

Camera lenses are divided into the following three types:

  1. Panoramic lens: SensorMode.PANORAMA
  2. Front camera: SensorMode.FRONT
  3. Rear lens: SensorMode.REAR

Determine the Sensor Mode

// Get the current sensor modeSensorModesensorMode = InstaCameraManager.getInstance().getCurrentSensorMode();
// Determine whether it is single sensor modeInstaCameraManager.getInstance().isCameraSingleSensorMode();
// Determine whether it is dual sensor modeInstaCameraManager.getInstance().isCameraDualSensorMode();

Switch Camera Lenses

Note: The SDK currently only supports panoramic lenses. Unknown issues may occur with non-panoramic lenses. Please switch to using the SDK under panoramic lenses.

// Switch to camera panorama lensInstaCameraManager.getInstance().switchPanoramaSensorMode(newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// Lens switch successful
}
@OverridepublicvoidonFailed() {
// Lens switch failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection error
}
});

Preview Module

Note: Must be used with Media SDK.

Open Preview Stream

After successfully connecting the camera, you can manipulate the camera preview stream like this.

If the camera is passively disconnected, or if closeCamera() is called directly during the preview, the SDK will automatically turn off the preview stream processing related state without calling closePreviewStream()

Note: The following code only enables the preview stream and cannot display the preview content. You need to use the InstaCapturePlayerView control of MediaSDK to display the preview content.

publicclassPreviewActivityextendsBaseObserveCameraActivityimplementsIPreviewStatusListener {
@OverrideprotectedvoidonCreate(@NullableBundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
// Open previewInstaCameraManager.getInstance().setPreviewStatusChangedListener(this);
InstaCameraManager.getInstance().startPreviewStream(PreviewStreamResolution.STREAM_1440_720_30FPS, InstaCameraManager.PREVIEW_TYPE_NORMAL);
}
@OverrideprotectedvoidonStop() {
super.onStop();
if (isFinishing()) {
// Close previewInstaCameraManager.getInstance().setPreviewStatusChangedListener(null);
InstaCameraManager.getInstance().closePreviewStream();
}
}
@OverridepublicvoidonOpening() {
// Preview stream is opening 
}
@OverridepublicvoidonOpened() {
// The preview stream has been opened and can be played
}
@OverridepublicvoidonIdle() {
// Preview stream has stopped
}
@OverridepublicvoidonError() {
// Preview failed
}
@OverridepublicvoidonExposureData(ExposureDataexposureData) {
// Callback frequency 500Hz// exposureData.timestamp: Time after the camera is turned on// exposureData.exposureTime: Rolling shutter exposure time
}
@OverridepublicvoidonGyroData(List<GyroData> gyroList) {
// Callback frequency 10Hz, 50 data per group// gyroData.timestamp: Time after the camera is turned on// gyroData.ax, gyroData.ay, gyroData.az: Triaxial acceleration// gyroData.gx, gyroData.gy, gyroData.gz: Three-axis gyroscope
}
@OverridepublicvoidonVideoData(VideoDatavideoData) {
// Callback frequency 500Hz// videoData.timestamp: Time after the camera is turned on// videoData.data: Preview raw stream data per frame// videoData.size: Length of each frame of data
}
}

Get Preview Status

intpreviewStatus = InstaCameraManager.getInstance().getPreviewStatus();
// Preview status// InstaCameraManager.PREVIEW_STATUS_IDLE:Preview stream is not opening// InstaCameraManager.PREVIEW_STATUS_OPENING:Preview stream is opening// InstaCameraManager.PREVIEW_STATUS_OPENED:The preview stream has been opened

Set Preview Parameters

There are three types of preview streams:

  1. PREVIEW_TYPE_NORMAL:For normal preview or capturing
  2. PREVIEW_TYPE_RECORD:Only for recording
  3. PREVIEW_TYPE_LIVE:LIVE

Preview Resolution

You need to use the following code to get real-time support for camera resolution

List<PreviewStreamResolution> supportedList = InstaCameraManager.getInstance().getSupportedPreviewStreamResolution(InstaCameraManager.PREVIEW_TYPE_LIVE);

Note: For X4 and X5, the preview stream resolution cannot be adjusted. The default setting for X4 is 2880x1440, and the default setting for X5 is 2656x1328. The X3 can be manually set to 3840x1920/1440x720.

//Set resolution and preview stream typeInstaCameraManager.getInstance().startPreviewStream(
PreviewStreamResolution.STREAM_368_368_30FPSInstaCameraManager.PREVIEW_TYPE_LIVE
);

Preview Audio

You can set whether to turn on audio during preview.

PreviewParamsBuilderbuilder = newPreviewParamsBuilder()
.setStreamResolution(PreviewStreamResolution.STREAM_368_368_30FPS)
.setPreviewType(InstaCameraManager.PREVIEW_TYPE_LIVE)
// Whether to turn on audio
.setAudioEnabled(true);
InstaCameraManager.getInstance().startPreviewStream(builder);

Capture Control Module

Get the Current Capturing Mode

CaptureModecaptureMode = InstaCameraManager.getInstance().getCurrentCaptureMode();
// The current SDK supports the following capturing modes. Specific camera models may exhibit slight variations; refer to your camera's display for exact details:NormalCaptureCaptureMode.CAPTURE_NORMALHDRCaptureCaptureMode.HDR_CAPTURENightSceneCaptureMode.NIGHT_SCENEBurstModeCaptureMode.BURSTIntervalShootingCaptureMode.INTERVAL_SHOOTINGStarlapseShootingCaptureMode.STARLAPSE_SHOOTINGNormalVideoRecordingCaptureMode.RECORD_NORMALHDRRecordingCaptureMode.HDR_RECORDBulletTimeCaptureMode.BULLETTIMETimelapseModeCaptureMode.TIMELAPSETimeShiftModeCaptureMode.TIME_SHIFTLoopRecordingModeCaptureMode.LOOPER_RECORDINGSuperRecordingCaptureMode.SUPER_RECORDSlowMotionCaptureMode.SLOW_MOTIONSelfieTrackingModeCaptureMode.SELFIE_RECORDPureVideoMode (NightScene):CaptureMode.PURE_RECORDLIVECaptureMode.LIVE

Switching Capturing Mode

InstaCameraManager.getInstance().setCaptureMode(captureMode, errorCode -> {
if (errorCode == 0) {
// Switching successful
} else {
// Switching failed
}
});

Capturing Status Notification

Note: For the X3 and earlier camera models, videos exceeding 30 minutes will be split into two recordings. The camera will automatically stop recording the first segment and begin recording the second segment.

InstaCameraManager.getInstance().setCaptureStatusListener(newICaptureStatusListener() {
@OverridepublicvoidonCaptureCountChanged(intcaptureCount) {
// Number of shots captured for modes such as interval shooting and starry sky mode,
}
@OverridepublicvoidonCaptureStarting() {
// Capture is about to start
}
@OverridepublicvoidonCaptureStopping() {
// Capture is about to stop
}
@OverridepublicvoidonCaptureTimeChanged(longcaptureTime) {
// Recording time callback, applicable only in video recording mode
}
@OverridepublicvoidonCaptureWorking() {
// Capturing in progress
}
@OverridepublicvoidonCaptureFinish(String[] filePaths) {
// Capture finished, returns the file paths of the final products
}
@OverridepublicvoidonCaptureError(interrorCode) {
// capturing failed error reference capturing failed error code
}
});

Parameter Settings

Capturing Properties

The current SDK supports the following capturing properties:

  • Exposure Mode: CaptureSetting.EXPOSURE
FULL_AUTO = Exposure.FULL_AUTO, // Full Auto
AUTO = Exposure.AUTO, // Auto
ISO_FIRST = Exposure.ISO_FIRST, // ISO Priority
SHUTTER_FIRST = Exposure.SHUTTER_FIRST, // Shutter Priority
MANUAL = Exposure.MANUAL, // Manual
ADAPTIVE = Exposure.ADAPTIVE // Panorama Adaptive Exposure
  • Full Auto: Exposure.FULL_AUTO

  • Auto: Exposure.AUTO

  • ISO Priority: Exposure.ISO_FIRST

  • Shutter Priority: Exposure.SHUTTER_FIRST

  • Manual: Exposure.MANUAL

  • Panorama Adaptive Exposure: Exposure.ADAPTIVE

  • EV:CaptureSetting.EV

  • EV Interval: CaptureSetting.EV_INTERVAL

  • Shutter Speed: CaptureSetting.SHUTTER

  • Shutter Mode: CaptureSetting.SHUTTER_MODE

AUTO = ShutterMode.AUTO, // Auto
SPORT = ShutterMode.SPORT, // Indoor Low-light Stabilization
FASTER = ShutterMode.FASTER // Extra Fast
  • ISO: CaptureSetting.ISO

  • Max ISO: CaptureSetting.ISO_TOP_LIMIT

  • Video Resolution & Frame Rate: CaptureSetting.RECORD_RESOLUTION

  • Photo Resolution: CaptureSetting.PHOTO_RESOLUTION

  • White Balance: CaptureSetting.WB

  • AEB: CaptureSetting.AEB

  • Interval Duration: CaptureSetting.INTERVAL

  • Color Mode: CaptureSetting.GAMMA_MODE

STAND = GammaMode.STAND, // Standard
VIVID = GammaMode.VIVID, // LOG
LOG = GammaMode.LOG, // Vivid
FLAT = GammaMode.FLAT // Flat
  • Photo Format: CaptureSetting.RAW_TYPE
JPG = RawType.OFF, // JPG
JPG_RAW = RawType.DNG, // JPG & RAW
PURESHOT = RawType.PURESHOT, // PURESHOT
PURESHOT_RAW = RawType.PURESHOT_RAW, // PURESHOT & RAW
INSP = RawType.INSP, // INSP
INSP_RAW = RawType.INSP_RAW // RAW & INSP
  • Recording Duration: CaptureSetting.RECORD_DURATION

  • Low Light Stabilization: CaptureSetting.DARK_EIS_ENABLE

  • Panorama Adaptive Exposure: CaptureSetting.PANO_EXPOSURE_MODE

OFF = PanoExposureMode.OFF, // Off
ON = PanoExposureMode.ON, // Independent Exposure
LIGHT = PanoExposureMode.LIGHT, // Standard
LSOLATED = PanoExposureMode.LSOLATED // High

Note: For cameras prior to Insta360 X4, only ON and OFF were supported. From X4 onwards, ON is split into LIGHT and LSOLATED.

  • Burst Capture Count: CaptureSetting.BURST_CAPTURE

  • In-camera Splicing: CaptureSetting.INTERNAL_SPLICING

ON = InternalSplicing.ON, // On
OFF = InternalSplicing.OFF // Off
  • Video HDR Mode: CaptureSetting.HDR_STATUS
ON = HdrStatus.ON, // On
OFF = HdrStatus.OFF // Off

Note: From Insta360 X5 onwards, CaptureMode.HDR_RECORD is removed. Use CaptureSetting.HDR_STATUS instead.

  • Photo HDR Mode: CaptureSetting.PHOTO_HDR_TYPE
On: PhotoHdrType.HDR_ON
Off: PhotoHdrType.HDR_OFF
AEB: PhotoHdrType.HDR_AEB

Note: From Insta X5 onwards, CaptureMode.HDR_CAPTURE is removed. Use CaptureSetting.PHOTO_HDR_TYPE instead.

  • I-LOG: CaptureSetting.I_LOG
ON = ILogStatus.ON, // On
OFF = ILogStatus.OFF // Off
  • Photo Countdown:CaptureSetting.LATENCY

Note: Only supported on X5

Get Capturing Parameters

You can use the InstaCameraManager.getInstance().getXxx(CaptureMode) method to retrieve the corresponding capturing properties.

MethodParameterReturn TypeDescription
getRecordDuration()CaptureModeRecordDurationGet recording duration
getRecordResolution()CaptureModeRecordResolutionGet video resolution and frame rate
getPhotoResolution()CaptureModePhotoResolutionGet photo resolution
getInterval()CaptureModeIntervalGet capturing interval duration
getHdrStatus()CaptureModeHdrStatusGet HDR status for normal video recording
getPhotoHdrType()CaptureModePhotoHdrTypeGet HDR status for normal photo capture
getGammaMode()CaptureModeGammaModeGet color mode
getRawType()CaptureModeRawTypeGet photo format
getPanoExposureMode()CaptureModePanoExposureModeGet panorama independent exposure status
getExposure()CaptureModeExposureGet exposure mode
getISO()CaptureModeISOGet ISO value
getISOTopLimit()CaptureModeISOTopLimitGet ISO upper limit
getShutterMode()CaptureModeShutterModeGet shutter mode
getShutter()CaptureModeShutterGet shutter speed
getEv()CaptureModeEvGet EV value
getEVInterval()CaptureModeEVIntervalGet EV interval
getAEB()CaptureModeAEBGet AEB
getWB()CaptureModeWBGet white balance
getInternalSplicingEnable()CaptureModeInternalSplicingGet in-camera stitching status
getDarkEisType()CaptureModeDarkEisTypeGet low-light stabilization status
getBurstCapture()CaptureModeBurstCaptureGet burst mode parameters
getILogStatus()CaptureModeILogStatusGet the I-LOG Switch
getLatency()CaptureModeLatencyGet the photo countdown

Set Capturing Properties

You can use the*InstaCameraManager.getInstance().setXxx(CaptureMode)* method to set the corresponding capturing properties.

MethodParameter 1Parameter 2Return TypeDescription
setRecordDuration()CaptureModeRecordDurationvoidSet recording duration
setRecordResolution()CaptureModeRecordResolutionvoidSet video resolution and frame rate
setPhotoResolution()CaptureModePhotoResolutionvoidSet photo resolution
setInterval()CaptureModeIntervalvoidSet capturing interval duration
setHdrStatus()CaptureModeHdrStatusvoidSet HDR status for normal video
setPhotoHdrType()CaptureModePhotoHdrTypevoidSet HDR status for normal photo
setGammaMode()CaptureModeGammaModevoidSet color mode
setRawType()CaptureModeRawTypevoidSet photo format
setPanoExposureMode()CaptureModePanoExposureModevoidSet panorama independent exposure status
setExposure()CaptureModeExposurevoidSet exposure mode
setISO()CaptureModeISOvoidSet ISO value
setISOTopLimit()CaptureModeISOTopLimitvoidSet ISO upper limit
setShutterMode()CaptureModeShutterModevoidSet shutter mode
setShutter()CaptureModeShuttervoidSet shutter speed
setEv()CaptureModeEvvoidSet EV value
setEVInterval()CaptureModeEVIntervalvoidSet EV interval
setAEB(CaptureModeCaptureModeAEBvoidSet AEB
setWB()CaptureModeWBvoidSet white balance
setInternalSplicingEnable()CaptureModeInternalSplicingvoidSet in-camera stitching
setDarkEisType()CaptureModeDarkEisTypevoidSet low-light stabilization
setBurstCapture()CaptureModeBurstCapturevoidSet burst mode parameters
setILogStatusCaptureModeILogStatusvoidSetting the I-LOG switch
setLatency()CaptureModeLatencyvoidSet a photo countdown

Batch Set Capturing Properties

//Start batch setting of capturing propertiesInstaCameraManager.getInstance().beginSettingOptions();
InstaCameraManager.getInstance().setEv(captureMode, EV.EV_0);
InstaCameraManager.getInstance().setShutter(captureMode, Shutter.SHUTTER_1_2);
...
InstaCameraManager.getInstance().setWB(captureMode, WB.WB_2200K);
//Submit batch settings to take effectInstaCameraManager.getInstance().commitSettingOptions();

Dependency between Capturing Properties

There are interdependencies among different capturing properties. Setting property A may affect the support list of property B. Therefore, after setting a property, it is necessary to check the other affected properties.

Note: Since the callback function may be invoked multiple times, the elements in the CaptureSetting list may differ each time it is called.

Example:

// The example only demonstrates setting PhotoHdrType; other property settings follow the same pattern;InstaCameraManager.getInstance().setPhotoHdrType(captureMode, photoHdrType, newInstaCameraManager.IDependChecker() {
@Overridepublicvoidcheck(List<CaptureSetting> captureSettings) {
// captureSettings:list of affected capturing properties// UI updates can be handled here
}
});

Photo Capture

Determine whether the Camera is in Photo Mode

booleanisPhotoMode = CaptureMode.PURE_RECORD.isPhotoMode();

Start Capturing

// Start Normal capture
InstaCameraManager.getInstance().startNormalCapture();
// Start HDR capture
InstaCameraManager.getInstance().startHDRCapture();
// Start super night scene
InstaCameraManager.getInstance().startNightScene();
// Start burst capture
InstaCameraManager.getInstance().startBurstCapture();
// Start Interval Shooting
InstaCameraManager.getInstance().startIntervalShooting();
// Stop interval shooting
InstaCameraManager.getInstance().stopIntervalShooting();
// Start starlapse shooting
InstaCameraManager.getInstance().startStarLapseShooting();
// Stop starlapse shooting
InstaCameraManager.getInstance().stopStarLapseShooting();

Video Recording

Determine if it is Video Mode

booleanisVideoMode = CaptureMode.PURE_RECORD.isVideoMode();

Start/Stop Recording

// Start normal recording
InstaCameraManager.getInstance().startNormalRecord();
// Stop normal recording
InstaCameraManager.getInstance().stopNormalRecord();
// Start HDR recording
InstaCameraManager.getInstance().startHDRRecord();
// Stop HDR recording
InstaCameraManager.getInstance().stopHDRRecord();
// Start Bullet Time
InstaCameraManager.getInstance().startBulletTime();
// Stop Bullet Time
InstaCameraManager.getInstance().stopBulletTime();
// Start timelapse recording
InstaCameraManager.getInstance().startTimeLapse();
// Stop timelapse recording
InstaCameraManager.getInstance().stopTimeLapse();
// Start time shift recording
InstaCameraManager.getInstance().startTimeShift();
// Stop time shift recording
InstaCameraManager.getInstance().stopTimeShift();
// Start loop recording
InstaCameraManager.getInstance().startLooperRecord();
// Stop loop recording
InstaCameraManager.getInstance().stopLooperRecord();
// Start super recording
InstaCameraManager.getInstance().startSuperRecord();
// Stop super recording
InstaCameraManager.getInstance().stopSuperRecord();
// Start slow motion recording
InstaCameraManager.getInstance().startSlowMotionRecord();
// Stop slow motion recording
InstaCameraManager.getInstance().stopSlowMotionRecord();
// Start selfie tracking mode
InstaCameraManager.getInstance().startSelfieRecord();
// Stop selfie tracking mode
InstaCameraManager.getInstance().stopSelfieRecord();
// Start night scene recording
InstaCameraManager.getInstance().startPureRecord();
// Stop night scene recording
InstaCameraManager.getInstance().stopPureRecord();

LIVE Module

Note: Required to use with the Media SDK.

Determine if it is Live Streaming Mode

booleanisLiveMode = CaptureMode.PURE_RECORD.isLiveMode();

Start Live Streaming

Note: After the preview stream is turned off, the camera will automatically switch the capturing mode to normal recording. Before starting LIVE, you need to check whether the current capturing mode is LIVE. Specific parameters are set using CaptureSetting.

InstaCameraManager.getInstance().startLive(rtmp, netid, newILiveStatusListener() {
@OverridepublicvoidonLiveFpsUpdate(intfps) {
// fps:当前直播帧率
}
@OverridepublicvoidonLivePushError(interror, Stringdesc) {
// 直播推流失败
}
@OverridepublicvoidonLivePushFinished() {
// 直播推流结束
}
@OverridepublicvoidonLivePushStarted() {
// 直播推流开始
}
});

End LIVE

InstaCameraManager.getInstance().stopLive();

File Management Module

Get the Camera Socket Address

// Return value example:http://192.168.42.1:80InstaCameraManager.getInstance().getCameraHttpPrefix();

Get Camera File URL

// Return value example:[/DCIM/Camera01/VID_20250326_184618_00_001.insv]List<String> usls = InstaCameraManager.getInstance().getAllUrlList();
// Includes files in the videoList<String> usls = InstaCameraManager.getInstance().getAllUrlListIncludeRecording();

Delete Camera Files

// Delete a single camera fileInstaCameraManager.getInstance().deleteFile(StringfilePathnewICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// Delete successfully
}
@OverridepublicvoidonFailed() {
// Delete failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection error
}
});
// Batch delete camera filesInstaCameraManager.getInstance().deleteFileList(List<String> fileUrlListnewICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// Delete successfully
}
@OverridepublicvoidonFailed() {
// Delete failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection error
}
});

Logging Module

Set Log Root Path

The SDK's log system supports saving logs to local files. Call the following code to set the log save location.

// Set the log cache path. If not set, no cache will be performed.LogManager.instance.setLogRootPath(StorageUtils.getInternalRootPath() + "/log");

Start/Stop Logging

Enable the global log real-time capture function, which will capture all logs, including SDK logs, system logs, host APP logs, etc., and save them in the directory specified above.

// Enable real-time log captureLogManager.instance.startLogDumper();
// Stop real-time log captureLogManager.instance.stopLogDumper();

GPS Data Module

Settings in Photo Mode

// android.location.Location class,developer obtains it via system APILocationlocation;
// Set GPS data when taking a photoGpsDatagpsData = newGpsData();
gpsData.setLatitude(location.getLatitude());
gpsData.setLongitude(location.getLongitude());
gpsData.setAltitude(location.getAltitude());
InstaCameraManager.getInstance().startNormalCapture(gpsData.simpleGpsDataToByteArray());

GPS Data Interface for Input in Different Photo Modes

// Start normal capturing and input GPS data.
InstaCameraManager.getInstance().startNormalCapture(byte[]);
// Start HDR capturing and input GPS data.
InstaCameraManager.getInstance().startHDRCapture(byte[]);
// Start burst capturing and input GPS data.
InstaCameraManager.getInstance().startBurstCapture(byte[]);
// Start interval shooting and input GPS data.
InstaCameraManager.getInstance().stopIntervalShooting(byte[]);

Settings in Record Mode

GPS data for recording settings can be divided into the following two situations:

When the Recording is Stopped

Stopping recording is the same as taking photos. The example code is as follows:

// android.location.Location class, developer obtains it via system APILocationlocation;
// Set GPS data when stopping the recordingGpsDatagpsData = newGpsData();
gpsData.setLatitude(location.getLatitude());
gpsData.setLongitude(location.getLongitude());
gpsData.setAltitude(location.getAltitude());
InstaCameraManager.getInstance().stopNormalRecord(gpsData.simpleGpsDataToByteArray());

In Recording

GPS data can be set at any time in the video recording. GPS data is usually used to create the camera's motion trajectory. Therefore, it is recommended to set the GPS interval as much as possible each time. The example code is as follows:

// Collect GPS data every 100ms; once 20 GPS data points are accumulated, send them to the cameraprivateHandlermMainHandler = newHandler(Looper.getMainLooper());
// List of GPS dataprivateList<GpsData> mCollectGpsDataList = newArrayList<GpsData>();
privateRunnablemCollectGpsDataRunnable = newRunnable() {
@Overridepublicvoidrun() {
// android.location.Location class, developer obtains it via system APILocationlocationif (location != null) {
GpsDatagpsData = newGpsData();
gpsData.setLatitude(location.getLatitude());
gpsData.setLongitude(location.getLongitude());
gpsData.setSpeed(location.getSpeed());
gpsData.setBearing(location.getBearing());
gpsData.setAltitude(location.getAltitude());
gpsData.setUTCTimeMs(location.getTime());
gpsData.setVaild(true);
mCollectGpsDataList.add(gpsData);
if (mCollectGpsDataList.size() >= 20) {
InstaCameraManager.getInstance().setGpsData(GpsData.gpsDataToByteArray(mCollectGpsDataList));
mCollectGpsDataList.clear();
}
}
mMainHandler.postDelayed(this, 100);
}
};
// Start collecting GPS datamMainHandler.post(mCollectGpsDataRunnable);

GPS Data Interface for Input in Different Recording Modes

// Stop normal recording and input GPS data.
InstaCameraManager.getInstance().stopNormalRecord(byte[]);
// Stop HDR recording and input GPS data.
InstaCameraManager.getInstance().stopHDRRecord(byte[]);
// Stop Bullet Time and input GPS data.
InstaCameraManager.getInstance().stopBulletTime(byte[]);
// Stop Timelapse and input GPS data.
InstaCameraManager.getInstance().stopTimeLapse(byte[]);
// Stop Time Shift and input GPS data.
InstaCameraManager.getInstance().stopTimeShift(byte[]);
// Stop super Recording and input GPS data.
InstaCameraManager.getInstance().stopSuperRecord(byte[]);
// Stop loop Recording and input GPS data.
InstaCameraManager.getInstance().stopLooperRecord(byte[]);
// Stop night Scene recording and input GPS data.
InstaCameraManager.getInstance().stopPureRecord(byte[]);
// Stop selfie tracking recording and input GPS data.
InstaCameraManager.getInstance().stopSelfieRecord(byte[]);

Other Features Module

Camera Activation

Activating the camera requires the use of two pieces of data, appIdand secretKey. These two data need to be applied for by the official Insta360.

Note: Activation requires network permissions

Note: Nano S cameras do not support this feature.

Example code is as follows:

Stringappid = "xxxxxxxx";
StringmSecretKey = "xxxxxxx";
InstaCameraManager.getInstance().activateCamera(newSecretInfo(appid , mSecretKey), newInstaCameraManager.IActivateCameraCallback() {
@OverridepublicvoidonStart() {
// Began to activate
}
@OverridepublicvoidonSuccess() {
// Activation successful
}
@OverridepublicvoidonFailed(Stringmessage) {
// Activation failed
}
});

Camera Prompt Sound

Note: The Nano S camera does not support the prompt sound switch, but supports the setting.

The switch for camera prompt sound. Example code is as follows:

// Turn on the camera prompt toneInstaCameraManager.getInstance().setCameraBeepSwitch(true);
// Determine whether the camera has a prompt tone turned onbooleanisBeep = InstaCameraManager.getInstance().isCameraBeep();

Format the SD Card

InstaCameraManager.getInstance().formatStorage(newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
// SD card formatted successfully
}
@OverridepublicvoidonFailed() {
// SD card formatting failed
}
@OverridepublicvoidonCameraConnectError() {
// Camera connection error
}
});

Camera Lock Screen

Note: Nano S cameras do not support this feature.

After the camera is locked, the user cannot operate the camera screen. Example code is as follows:

// true: lock screen false: unlock screenInstaCameraManager.getInstance().setCameraLockScreen(true);

Turn off the Camera

Instructions to control camera shutdown, sample code is as follows:

Note: Only Insta360X5 and later cameras support this feature.

InstaCameraManager.getInstance().shutdownCamera();

Calibration of Gyroscope

Note: Nano S cameras do not support this feature.

When the camera is connected to Wi-Fi, this function should be used. Before calibration, make sure the camera is placed vertically on a stable and horizontal surface.

InstaCameraManager.getInstance().calibrateGyro(newICameraOperateCallback() {
@OverridepublicvoidonSuccessful() {
}
@OverridepublicvoidonFailed() {
}
@OverridepublicvoidonCameraConnectError() {
}
});

Firmware Upgrade

Use the FwUpgradeManager class to upgrade the firmware version. The example code is as follows:

Note: Nano S cameras do not support this feature.

Note: Please make sure to upload the correct files to the camera to prevent any potential damage. For example, do not upload the ONE X firmware upgrade package to the ONE X2 camera.

// Determine if an upgrade is in progressFwUpgradeManager.getInstance().isUpgrading();
// Cancel the upgradeFwUpgradeManager.getInstance().cancelUpgrade();
StringfwFilePath = "/xxx/InstaOneXFW.bin";
// Upgrade firmwareFwUpgradeManager.getInstance().startUpgrade(fwFilePath, newFwUpgradeListener() {
@OverridepublicvoidonUpgradeSuccess() {
// Callback after successful upgrade
}
@OverridepublicvoidonUpgradeFail(interrorCode, Stringmessage) {
// Upgrade failure callback// Firmware error code
}
@OverridepublicvoidonUpgradeCancel() {
// Upgrade cancel callback
}
@OverridepublicvoidonUpgradeProgress(doubleprogress) {
// Upgrade progress callback: 0-1
}
});

Sharpness Settings (Currently Unsupported)

Error Code

Camera Connection Error Code

Error CodeExplanation
-122Bluetooth device disconnected
501Bluetooth disconnection occurred
2201System error BleException.ERROR_CODE_SYSTEM_STATUS_133
2002Open camera timed out
2206System error BleException.ERROR_CODE_NOTIFY_FAILURE
2207System error BleException.ERROR_CODE_SHAKE_HAND
3201Socket connection failed
3205Socket connection timed out
3206Socket reconnect timed out
4001System error BleException.ERROR_CODE_SYNC_PACK
4101Camera type error
4103Camera sync parameter timed out
4402Camera operating system error
4403Camera is occupied
4405Parsing proto failed
4406Camera sync parameter retry timeout
4407Camera data exception
4414Failed to wake up Bluetooth
4417Camera disconnected during operation
4504Camera disconnected when connected
4505Bluetooth binding rejected
4507Bluetooth write failed
4508Device Bluetooth busy
4602Device Wi-Fi busy
4605USBerror
4606Socket Disconnected Due to Dirty Data
-14169Failed to synchronize camera parameters due to Bluetooth failure

Firmware Upgrade Error Code

Error CodeExplanation
-1000Already upgrading
-1001Camera not connected
-1002When the camera battery is below 12%, the upgrade will fail, please make sure the camera battery is fully charged
-14004Http server error
400Http server error
500Http server error
-14005Socket IO exception
  1. Capturing Failed Error Code

Error CodeExplanation
-14161Low battery
-14162Exceeded the maximum recording time limit
-14163SD card is full
-14165Exceeded the file limit
-14166SD card speed is low
-14167Coding anomaly
-14168Frame loss
-14180Excessive file fragmentation
-14181Camera temperature is too high
-14182Low power start
-14183Storage Deflection Start
-14184High temperature start
-14164Other situations
  1. Camera Activation Error Code

Error CodeExplanation
400Parameter error, possibly due to the camera type or serial number not being obtained
401Interface signature verification failed
402Data encryption verification failed
403The nonce credential has already been used
406The timestamp has expired
429Frequent interface requests
500Internal system exception
3001Device serial number does not match device type
3002Camera has been activated
3003Activation denied; IP address is not within a valid region
3004Unable to generate a valid serial number
3005The system does not support activating devices of this model
3006The serial number has been locked by the backend and cannot be activated
429The activation IP is subject to rate limiting. Rate limiting policy: 45 attempts per IP per day

Media SDK Function

Environmental Preparation

  • Add the maven address to the build file (build.gradle file in the project root directory)
allprojects {
repositories {
...
maven {
url 'XXXXXX'
credentials {
// see sdk demo
username ='***'
password ='***'
}
}
}
}
  • Import the dependency library in thebuild.gradle file of the app directory
dependencies {
implementation 'com.arashivision.sdk:sdkmedia:x.x.x'
}

Preview Module

If you have integrated the Camera SDK, you can open and display the preview content.

Preview Control Initalization

You need to put *InstaCapturePlayerView*into your XML file and bind the lifecycle of the Activity:

<com.arashivision.sdkmedia.player.capture.InstaCapturePlayerView
android:id="@+id/player_capture"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@android:color/darker_gray"
/>
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
mCapturePlayerView.setLifecycle(getLifecycle());
}

Display Preview Screen

Show preview screen in IPreviewStatusListener.onOpen() callback of Camera SDK

@OverridepublicvoidonOpened() {
InstaCameraManager.getInstance().setStreamEncode();
mCapturePlayerView.setPlayerViewListener(newPlayerViewListener() {
@OverridepublicvoidonLoadingFinish() {
// Fixed writingInstaCameraManager.getInstance().setPipeline(mCapturePlayerView.getPipeline());
}
@OverridepublicvoidonLoadingStatusChanged(booleanisLoading) {
// loading status change
}
@OverridepublicvoidonFail(Stringdesc) {
}
@OverridepublicvoidonFirstFrameRender() {
// First frame rendered successfully
}
});
// Set parameters, which will be described in detail latermCapturePlayerView.prepare(createParams());
// PlaymCapturePlayerView.play();
// Keep the screen always onmCapturePlayerView.setKeepScreenOn(false);
}

Release Resources

When closing the preview stream, you need to release the InstaCapturePlayerView

@OverrideprotectedvoidonStop() {
super.onStop();
if (isFinishing()) {
InstaCameraManager.getInstance().setPreviewStatusChangedListener(null);
InstaCameraManager.getInstance().closePreviewStream();
mCapturePlayerView.destroy();
}
}
// yilanli@OverridepublicvoidonIdle() {
mCapturePlayerView.destroy();
mCapturePlayerView.setKeepScreenOn(false);
}

Set Preview Parameters

privateCaptureParamsBuilderV2createParams() {
CaptureParamsBuilderV2builder = newCaptureParamsBuilderV2()
// (Optional) Set your resolution and frame rate. The default values are generated intelligently by the SDK.
.setWidth(intwidth)
.setHeight(intheight)
.setFps(intfps) //Max 30fps// (optional) achromatic Default value is true
.setImageFusionEnabled(booleanenable)
// (Optional) Set the gesture switch. The default value is generated intelligently by the SDK
.setGestureEnabled(booleanenable)
// (Optional) Set the number of frames cached for anti-shake. The more frames cached, the better the anti-shake effect, but the higher the image delay.
.setStabCacheFrameNum(5)
// (Optional) Set the stabilization type. The default value is generated intelligently by the SDK.
.setStabType(@InstaStabType.StabTypeintmStabType)
// (Optional) Set the rendering mode; the default value is “RenderModel.AUTO”.
.setRenderModel(RenderModel.PLANE_STITCH)
// (Optional) Set the screen ratio. For example, 9:16. The default value is generated by the SDK.// If the rendering mode type is “PLANE_STITCH”, it is recommended to set the aspect ratio to 2:1.
.setScreenRatio(int,int)
// (Optional) Set custom Surface information
.setCameraRenderSurfaceInfo(CameraRenderSurfaceInfo);
returnbuilder;
}

Switch Rendering Mode

// OrdinarymCapturePlayerView.switchNormalMode();
// Fish eyemCapturePlayerView.switchFisheyeMode();
// PerspectivemCapturePlayerView.switchPerspectiveMode();

Field of View Distance

You can customize the viewing angle and distance according to your preferences.

Fov: Angle range 0~180

Distance: line of sight range 0~∞

mCapturePlayerView.setConstraint(floatminFov, floatmaxFov, floatdefaultFov, floatminDistance, floatmaxDistance, floatdefaultDistance);

Gesture Operation

You can set PlayerGestureListener to observe gesture actions:

mCapturePlayerView.setGestureListener(newPlayerGestureListener() {
@OverridepublicbooleanonDown(MotionEvente) {
// Use finger press eventreturnPlayerGestureListener.super.onDown(e);
}
@OverridepublicbooleanonTap(MotionEvente) {
// User finger click event, similar to View. OnClickListener. OnClick (v)returnPlayerGestureListener.super.onTap(e);
}
@OverridepublicvoidonUp() {
// User finger lift eventPlayerGestureListener.super.onUp();
}
@OverridepublicvoidonLongPress(MotionEvente) {
// User long press eventPlayerGestureListener.super.onLongPress(e);
}
@OverridepublicvoidonZoom() {
// User two-finger zoom eventPlayerGestureListener.super.onZoom();
}
@OverridepublicvoidonZoomAnimation() {
// Rebound animation when scaling to maximum or minimumPlayerGestureListener.super.onZoomAnimation();
}
@OverridepublicvoidonZoomAnimationEnd() {
// Zoom rebound animation endsPlayerGestureListener.super.onZoomAnimationEnd();
}
@OverridepublicvoidonScroll() {
// User finger swipe eventPlayerGestureListener.super.onScroll();
}
@OverridepublicvoidonFlingAnimation() {
// Fling animationPlayerGestureListener.super.onFlingAnimation();
}
@OverridepublicvoidonFlingAnimationEnd() {
// Quick swipe animation endsPlayerGestureListener.super.onFlingAnimationEnd();
}
});

WorkWrapper

WorkWrapper is a collection of all data in a slice file. For example: Continuous capturing generates multiple files, which are then encapsulated into a single WorkWrapper for unified processing. Subsequent operations such as playback, export, and information retrieval are all performed by manipulating the WorkWrapper object.

How to Get WorkWrapper

You can scan media files from your camera or local directory to obtainList<WorkWrapper>

Note: This is a time-consuming operation that needs to be handled in a child thread.

// Get from the cameraList<WorkWrapper> list = WorkUtils.getAllCameraWorks();
// Get from local fileList<WorkWrapper> list = WorkUtils.getAllLocalWorks(StringdirPath);
// If you have the URL of the media file, you can also create WorkWrapper yourselfString[] urls = {img1.insv, img2.insv, img3.insv};
WorkWrapperworkWrapper = newWorkWrapper(urls);

Load File Trailer Data

Call the WorkWrapper.loadExtraData() function to load the file trailer data. The play and export functions can be used only after the file trailer data is loaded.

Call the WorkWrapper.isExtraDataLoaded() function to determine whether the file trailer data has been loaded.

Note: This method is a time-consuming operation and needs to be executed in the IO thread.

Read the Content of WorkWrapper

The information you can obtain from WorkWrapper is as follows:

MethodParameterReturn Value TypeExplanantion
getIdenticalKey()-StringFor Glide or other DiskCacheKeys
getUrls()-String[]Get media file URL
getUrls()booleanString[]Get the URL of the media file. Set true/false to determine whether to include the dng file path
getAllUrls()-String[]Get all file paths for operations such as downloading and deletion.
getWidth()-intGet width
getHeight()-intGet height
getBitrate()-intGet the video bitrate. If it is a photo, return 0
getFps()-doubleGet the video frame rate. If it is a photo, return 0
isPhoto()-booleanWhether it is a photo
isHDRPhoto()-booleanIs it an HDR photo
supportPureShot()-booleanWhether to support PureShot algorithm
isVideo()-booleanWhether it is a video
isHDRVideo()-booleanIs it HDR video
isCameraFile()-booleanIs the media file sourced from the camera device
isLocalFile()-booleanIs the media file sourced from a mobile device
getCreationTime()-longObtain media file shooting timestamp, unit: ms
getFirstFrameTimeOffset()-longObtain the offset of timestamp relative to camera startup when shooting media files, used to match gyroscope, exposure, and other data, unit: ms
getGyroInfo()-GyroInfo[]Obtain gyroscope data for media files
getExposureData()-ExposureData[]Obtain exposure data for media files
loadThumbnail()-BitmapLoading thumbnails (time-consuming operation)
loadExtraData()--Load file trailer data (time-consuming operation)
isExtraDataLoaded()-booleanWhether the file trailer data has been loaded

Image Player

If you want to play images or videos, you must first create a WorkWrapper

Player Initialization

Put the InstaImagePlayerView into an XML file and bind the lifecycle of the Activity.

<com.arashivision.sdkmedia.player.image.InstaImagePlayerView
android:id="@+id/player_image"android:layout_width="match_parent"android:layout_height="match_parent" />
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
mImagePlayerView.setLifecycle(getLifecycle());
}

Set Playback Parameters

ImageParamsBuilderbuilder = newImageParamsBuilder()
// (Optional) Whether to enable dynamic stitching, default is true
.setDynamicStitch(booleandynamicStitch)
// (Optional) Set the stabilization type, default is InstaStabType STAB_TYPE_OFF
.setStabType(@InstaStabType.StabTypeintmStabType)
// (Optional) Set the playback proxy file, such as HDR.jpg generated by splicing, which is empty by default
.setUrlForPlay(Stringurl)
// (Optional) Sets the render model type, default is Render_MODE_AUTO
.setRenderModel(RenderModel.PLANE_STITCH)
// (Optional) Set the aspect ratio of the screen, default is full screen display//If the render mode type is "RENDER_mode_PLANE_STITCH", the recommended setting ratio is 2:1
.setScreenRatio(intratioX, intratioY)
// (Optional) Eliminate color difference in image stitching, default is false
.setImageFusion(booleanimageFusion)
// (Optional) Set the lens guards type, default is OffsetType. ORIGINAL
.setOffsetType(OffsetTypeoffsetType)
// (Optional) Set the color enhancement switch; default is false.
.setColorPlusEnable(booleanenabled);
// (Optional) Set the color enhancement intensity, default value is 1, valid range 0-1
.setColorPlusFilterIntensity(floatcolorPlusFilterIntensity);
// (Optional) Whether to allow gesture operations, default is true
.setGestureEnabled(booleanenabled);
// (Optional) thumbnail cache folder, default is getCacheDir () + "/ work_thumbnail "
.setCacheWorkThumbnailRootPath(Stringpath)
// (Optional) Stabilizer data cache folder, default is get CacheD ir () + "/ stabilizer "
.setStabilizerCacheRootPath(Stringpath)
// (Optional) Cache folder, default is getExternalCacheDir () + "/ template_blender "
.setCacheTemplateBlenderRootPath(Stringpath)
// (Optional) Star mode image cache folder, default is getCacheDir () + "/ cut_scene "
.setCacheCutSceneRootPath(Stringpath);

Start Playing

WorkWrapper and playback parameters need to be set before playback.

// Set WorkWrapper and playback parametersmImagePlayerView.prepare(workWrapper, newImageParamsBuilder());
// Start playingmImagePlayerView.play();

Release Resources

When the Activity is destroyed, release InstaImagePlayerView

@OverrideprotectedvoidonDestroy() {
super.onDestroy();
mImagePlayerView.destroy();
}

Switch Rendering Mode

Note: If you want to switch between tiling mode and other modes, you must first restart the player.

If the rendering mode you are using is RENDER_MODE_AUTO, you can switch between the following modes.

// Switch to normal modemImagePlayerView.switchNormalMode();
// Switch to fisheye modemImagePlayerView.switchFisheyeMode();
// Switch to perspective modemImagePlayerView.switchPerspectiveMode();
// To switch to tiling mode, you need to restart the playerImageParamsBuilderbuilder = newImageParamsBuilder();
builder.setRenderModelType(ImageParamsBuilder.RENDER_MODE_PLANE_STITCH);
builder.setScreenRatio(2, 1);
mImagePlayerView.prepare(mWorkWrapper, builder);
mImagePlayerView.play();

Field of View Distance

You can customize the viewing angle and distance according to your preferences.

Fov: Angle range 0~180

Distance: line of sight range 0~∞

mImagePlayerView.setConstraint(floatminFov, floatmaxFov, floatdefaultFov, floatminDistance, floatmaxDistance, floatdefaultDistance);

Set Listener

You can set the PlayerViewListener to observe changes in the player state.

mImagePlayerView.setPlayerViewListener(newPlayerViewListener() {
@OverridepublicvoidonLoadingStatusChanged(booleanisLoading) {
// Player loading status changed//isLoading:whether loading
}
@OverridepublicvoidonLoadingFinish() {
// Player loading complete
}
@OverridepublicvoidonFail(interrorCode, StringerrorMsg) {
// if GPU not support, errorCode is -10003 or -10005 or -13020// Player error
}
@OverridepublicvoidonFirstFrameRender() {
// First frame rendering successfully
}
});

Gesture Operation

You can set PlayerGestureListener to observe gesture actions:

mImagePlayerView.setGestureListener(newPlayerGestureListener(){
@Overridepublic boolean onDown(MotionEvente){// User finger press eventreturnPlayerGestureListener.super.onDown(e);}
@Overridepublic boolean onTap(MotionEvente){// User finger click event, similar to View.OnClickListener.OnClick(v)returnPlayerGestureListener.super.onTap(e);}
@OverridepublicvoidonUp(){// User finger lift eventPlayerGestureListener.super.onUp();}
@OverridepublicvoidonLongPress(MotionEvente){// User long press eventPlayerGestureListener.super.onLongPress(e);}
@OverridepublicvoidonZoom(){// User two-finger zoom eventPlayerGestureListener.super.onZoom();}
@OverridepublicvoidonZoomAnimation(){// Rebound animation when scaling to maximum or minimumPlayerGestureListener.super.onZoomAnimation();}
@OverridepublicvoidonZoomAnimationEnd(){// Zoom rebound animation endsPlayerGestureListener.super.onZoomAnimationEnd();}
@OverridepublicvoidonScroll(){// User finger swipe eventPlayerGestureListener.super.onScroll();}
@OverridepublicvoidonFlingAnimation(){// Quick slide animationPlayerGestureListener.super.onFlingAnimation();}
@OverridepublicvoidonFlingAnimationEnd(){// Quick swipe animation endsPlayerGestureListener.super.onFlingAnimationEnd();}});

Video Player

Player Initialization

Put the *InstaVideoPlayerView *into an XML file and bind the lifecycle of the Activity.

<com.arashivision.sdkmedia.player.video.InstaVideoPlayerView
android:id="@+id/player_video"android:layout_width="match_parent"android:layout_height="match_parent"
/>
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
mVideoPlayerView.setLifecycle(getLifecycle());
}
  1. Set Playback Parameters

VideoParamsBuilderbuilder = newVideoParamsBuilder()
// (Optional) Load icon, default is empty
.setLoadingImageResId(intresId)
// (Optional) Background color during loading, default is black
.setLoadingBackgroundColor(intcolor)
// (Optional) Whether to play automatically
.setAutoPlayAfterPrepared(booleanautoPlayAfterPrepared)
// (Optional) Set the stabilization type, default is InstaStabType STAB_TYPE_OFF
.setStabType(@InstaStabType.StabTypeintstabType)
// (Optional) Whether to play in loop; default is true
.setIsLooping(booleanisLooping)
// (Optional) Set whether to play the LRV
.setLrvEnable(booleanisLrvEnable)
// (Optional) Whether to enable dynamic stitching, default is true
.setDynamicStitch(booleandynamicStitch)
// (Optional) Eliminate color difference in image stitching, default is false
.setImageFusion(booleanimageFusion)
// (Optional) Set the lens guards type, default is OffsetType. ORIGINAL
.setOffsetType(OffsetTypeoffsetType)
// (Optional) Remove purple fringing. Default value is false. Requires adding an algorithm file.
.setDePurpleFilterOn(booleanisDePurpleFilterOn)
// (Optional) Set the color enhancement switch, default is false
.setColorPlusEnable(booleanenabled);
// (Optional) Set the color enhancement intensity, default value is 1, valid range 0-1
.setColorPlusFilterIntensity(floatcolorPlusFilterIntensity);
// (Optional) Sets the render model type, default is Render_MODE_AUTO
.setRenderModel(RenderModel.PLANE_STITCH)
// (Optional) Set the aspect ratio of the screen, default is full screen display.// If the render mode type is "RENDER_MODE_PLANE_STITCH", it is recommended to set the ratio to 2:1
.setScreenRatio(intratioX, intratioY)
// (Optional) Whether to allow gesture operations, default is true
.setGestureEnabled(booleanenabled)
// (Optional) thumbnail cache folder, default is getCacheDir () + "/ work_thumbnail "
.setCacheWorkThumbnailRootPath(Stringpath)
// (Optional) Star mode image cache folder, default is getCacheDir () + "/ cut_scene "
.setCacheCutSceneRootPath(Stringpath);

Start Playing

WorkWrapper and playback parameters need to be set before playback.

mVideoPlayerView.prepare(workWrapper, newVideoParamsBuilder());
mVideoPlayerView.play();

Release Resources

When the Activity is destroyed, release InstaVideoPlayerView

@OverrideprotectedvoidonDestroy() {
super.onDestroy();
mVideoPlayerView.destroy();
}

Playback Control

You can control the playback progress, pause/resume, playback volume, etc. Of the video by calling the code in VideoPlayerView.

方法参数返回值说明
isPlaying-booleanIs the video playing
isLooping-booleanWhether play it on a loop
setLoopingbooleanvoidSet whether play it on a loop
setVolumefloat (Range 0-1)voidSet playback volume
pause-voidPause playback
resume-voidResume playback
seekTolongvoidFast forward to the specified progress playback
isSeeking-booleanIs it fast forwarding?
getVideoCurrentPosition-longGet the current playback progress of the video
getVideoTotalDuration-longGet the total length of the video.

Switch Rendering Mode

Note: If you want to switch between tiling mode and other modes, you must first restart the player.

If the rendering mode you are using is RENDER_MODE_AUTO, you can switch between the following modes.

// Switch to normal modemVideoPlayerView.switchNormalMode();
// Switch to fisheye modemVideoPlayerView.switchFisheyeMode();
// Switch to perspective modemVideoPlayerView.switchPerspectiveMode();
// To switch to tiling mode, you need to restart the playerVideoParamsBuilderbuilder = newVideoParamsBuilder();
builder.setRenderModelType(ImageParamsBuilder.RENDER_MODE_PLANE_STITCH);
builder.setScreenRatio(2, 1);
mImagePlayerView.prepare(mWorkWrapper, builder);
mImagePlayerView.play();

Field of View Distance

You can customize the viewing angle and distance according to your preferences.

Fov:Angle range 0~180

Distance:line of sight range 0~∞

mVideoPlayerView.setConstraint(floatminFov, floatmaxFov, floatdefaultFov, floatminDistance, floatmaxDistance, floatdefaultDistance);

Set Listener

You can set the PlayerViewListener to observe changes in the player state.

mVideoPlayerView.setPlayerViewListener(newPlayerViewListener() {
@OverridepublicvoidonLoadingStatusChanged(booleanisLoading) {
// Player loading status change//isLoading:whether loading
}
@OverridepublicvoidonLoadingFinish() {
// Player loading complete
}
@OverridepublicvoidonFail(interrorCode, StringerrorMsg) {
// if GPU not support, errorCode is -10003 or -10005 or -13020// Player error
}
@OverridepublicvoidonFirstFrameRender() {
// First frame rendering successfully
}
});

You can set VideoStatusListener to observe changes in video status.

mVideoPlayerView.setVideoStatusListener(newVideoStatusListener() {
@OverridepublicvoidonProgressChanged(longposition, longlength) {
// Play progress callback// position:played length// length:Total length of the video
}
@OverridepublicvoidonPlayStateChanged(booleanisPlaying) {
// Video playback status callback// isPlaying:whether it is playing
}
@OverridepublicvoidonSeekComplete() {
// Fast forward completed
}
@OverridepublicvoidonCompletion() {
// Video playback finished
}
});

Gesture Operation

You can set PlayerGestureListener to observe gesture actions.

mVideoPlayerView.setGestureListener(newPlayerGestureListener(){
@Overridepublic boolean onDown(MotionEvente){// User finger press eventreturnPlayerGestureListener.super.onDown(e);}
@Overridepublic boolean onTap(MotionEvente){// User finger click event, similar to View.OnClickListener.OnClick(v)returnPlayerGestureListener.super.onTap(e);}
@OverridepublicvoidonUp(){// User finger lift eventPlayerGestureListener.super.onUp();}
@OverridepublicvoidonLongPress(MotionEvente){// User long press eventPlayerGestureListener.super.onLongPress(e);}
@OverridepublicvoidonZoom(){// User two-finger zoom eventPlayerGestureListener.super.onZoom();}
@OverridepublicvoidonZoomAnimation(){// Rebound animation when scaling to maximum or minimumPlayerGestureListener.super.onZoomAnimation();}
@OverridepublicvoidonZoomAnimationEnd(){// Zoom rebound animation endsPlayerGestureListener.super.onZoomAnimationEnd();}
@OverridepublicvoidonScroll(){// User finger swipe eventPlayerGestureListener.super.onScroll();}
@OverridepublicvoidonFlingAnimation(){// Quick slide animationPlayerGestureListener.super.onFlingAnimation();}
@OverridepublicvoidonFlingAnimationEnd(){// Quick swipe animation endsPlayerGestureListener.super.onFlingAnimationEnd();}});

Export

Export Parameters

If you want to export images, you need to first understand the ExportImageParamsBuilder image export parameters.

ExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
// (Must) Export file path
.setTargetPath(Stringpath)
// (Optional) Set the width of the exported image, the default value is obtained from WorkWapper.
.setWidth(intwidth)
// (Optional) Set the height of the exported image, the default value is obtained from WorkWapper.
.setHeight(intheight)
// (Optional) Set export mode, default is'PANORAMA'// ExportMode.PANORAMA: Export panoramic images// ExportMode.SPHERE: Export flat thumbnail
.setExportMode(ExportUtils.ExportModemode)
// (Optional) Whether to enable dynamic stitching, default is true.
.setDynamicStitch(booleandynamicStitch)
// (Optional) Set the stabilization type, default is InstaStabType.STAB_TYPE_OFF.
.setStabType(@InstaStabType.StabTypeintstabType)
// (Optional) Eliminate color difference in image stitching, default is false
.setImageFusion(booleanimageFusion)
// (Optional) Remove purple fringing. Default value is false. Requires adding an algorithm file.
.setDePurpleFilterOn(booleanisDePurpleFilterOn)
// (Optional) Set the lens guards type, default is OffsetType. ORIGINAL.
.setOffsetType(OffsetTypeoffsetType)
// (Optional) Set as HDR.jpg generated by splicing, default is null
.setUrlForExport(Stringurl)
// (Optional) Set to use software decoder, default is false
.setUseSoftwareDecoder(booleanuseSoftwareDecoder)
// (Optional) Set the camera angle. It is recommended to use it when exporting thumbnails.// The currently displayed angle parameter can be obtained from'PlayerView.getXXX () '.
.setFov(floatfov)
.setDistance(floatdistance)
.setYaw(floatyaw)
.setPitch(floatpitch)
// (Optional) Cache folder, default is getCacheDir () + "/ work_thumbnail "
.setCacheWorkThumbnailRootPath(Stringpath)
// (Optional) Cache folder, default is get CacheD ir () + "/ stabilizer "
.setStabilizerCacheRootPath(Stringpath)
// (Optional) Cache folder, default is getCacheDir () + "/ cut_scene "
.setCacheCutSceneRootPath(Stringpath);

Export Panoramic Images

Use images to export parameters:

ExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
.setExportMode(ExportUtils.ExportMode.PANORAMA)
.setTargetPath(path)
.setWidth(2048)
.setHeight(1024);
intexportId = ExportUtils.exportImage(WorkWrapper, builder, newIExportCallback() {
@OverridepublicvoidonSuccess() { // Export successful 
}
@OverridepublicvoidonFail() {
// Export failed
}
@OverridepublicvoidonCancel() {
// Cancel export
}
@OverridepublicvoidonProgress(floatprogress) {
// Export progress
}
});

Export Image thumbnail

Use images to export parameters:

ExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
.setExportMode(ExportUtils.ExportMode.SPHERE)
.setTargetPath(path)
.setWidth(512)
.setHeight(512)
.setFov(mImagePlayerView.getFov())
.setDistance(mImagePlayerView.getDistance())
.setYaw(mImagePlayerView.getYaw())
.setPitch(mImagePlayerView.getPitch());
intexportId = ExportUtils.exportImage(WorkWrapper, builder, newIExportCallback() {
@OverridepublicvoidonSuccess() { // Export successful 
}
@OverridepublicvoidonFail() {
// Export faild
}
@OverridepublicvoidonCancel() {
// Cancel export
}
@OverridepublicvoidonProgress(floatprogress) {
// Export progress
}
});

Export Video

Export Video Parameters

To export a video, you first need to understand the video export parameters ExportVideoParamsBuilder

ExportVideoParamsBuilderbuilder = newExportVideoParamsBuilder()
// (Must) Export file path
.setTargetPath(Stringpath)
// (Optional)Set the width of the exported video. It must be a power of 2, and the default value is obtained from WorkWapper.
.setWidth(intwidth)
// (Optional)Set the height of the exported video. It must be a power of 2, and the default value is obtained from WorkWapper.
.setHeight(intheight)
// (Optional)Set the bitrate for exporting videos, with the default value being obtained from WorkWapper.
.setBitrate(intbitrate)
// (Optional)Set the fps for exporting videos, with the default value being obtained from WorkWapper.
.setFps(intfps)
// (Optional) Set export mode, default is'PANORAMA'// ExportMode.PANORAMA: Export panoramic images// ExportMode.SPHERE: Export flat thumbnail
.setExportMode(ExportUtils.ExportModemode)
// (Optional) Remove purple fringing. Default value is false. Requires adding an algorithm file.
.setDePurpleFilterOn(booleanisDePurpleFilterOn)
// (Optional) Enable noise reduction (Noise reduction is enabled by default for exported images; the noise reduction toggle is only supported for exported videos)// The ExportUtils.supportDenoise(WorkWrapper) method must be called in advance to determine whether denoising is supported.// If noise reduction is supported, the setting is effective; otherwise, the setting is ineffective.
.setDenoise(true)
// (Optional) Eliminate color difference in image stitching, default is false
.setImageFusion(booleanimageFusion)
// (Optional) Set the lens guards type, default is OffsetType. ORIGINAL.
.setOffsetType(OffsetTypeoffsetType)
// (Optional) Whether to enable dynamic stitching, default is true.
.setDynamicStitch(booleandynamicStitch)
// (Optional) Set the stabilization type, default is InstaStabType.STAB_TYPE_OFF.
.setStabType(@InstaStabType.StabTypeintstabType)
// (Optional) Set to use software decoder, default is false
.setUseSoftwareDecoder(booleanuseSoftwareDecoder)
// (Optional) Cache folder, default is getCacheDir () + "/ work_thumbnail"
.setCacheWorkThumbnailRootPath(Stringpath)
// (Optional) Cache folder, default is getCacheDir () + "/ cut_scene"
.setCacheCutSceneRootPath(Stringpath)
// (Optional) Set the field of view
.setFov(floatfov)
// (Optional) Set the view distance
.setDistance(floatdistance)
// (Optional) Set the Euler angle - pitch angle
.setPitch(floatpitch)
// (Optional) Set the Euler angle-yaw angle
.setYaw(floatyaw)
// (Optional) Set the Euler angle-roll angle
.setRoll(floatroll);

Export Panoramic Video

Use video export parameters.

ExportVideoParamsBuilderbuilder = newExportVideoParamsBuilder()
.setExportMode(ExportUtils.ExportMode.PANORAMA)
.setTargetPath(path)
.setWidth(2048)
.setHeight(1024)
.setBitrate(20 * 1024 * 1024)
.setFps(30);
intexportId = ExportUtils.exportVideo(WorkWrapper, builder, newIExportCallback() {
@OverridepublicvoidonSuccess() { // Export successful 
}
@OverridepublicvoidonFail() {
// Export failed
}
@OverridepublicvoidonCancel() {
// Cancel export
}
@OverridepublicvoidonProgress(floatprogress) {
// Export progress
}
});

Export Video Thumbnail

Since the exported result is an image, use the image export parameters.

ExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
.setExportMode(ExportUtils.ExportMode.SPHERE)
.setTargetPath(path)
.setWidth(512)
.setHeight(512)
.setFov(mVideoPlayerView.getFov())
.setDistance(mVideoPlayerView.getDistance())
.setYaw(mVideoPlayerView.getYaw())
.setPitch(mVideoPlayerView.getPitch());
intexportId = ExportUtils.exportVideoToImage(WorkWrapper, builder, newIExportCallback() {
@OverridepublicvoidonSuccess() { // Export successful 
}
@OverridepublicvoidonFail() {
// Export failed
}
@OverridepublicvoidonCancel() {
// Cancel export
}
@OverridepublicvoidonProgress(floatprogress) {
// export progress
}
});

Stop Exporting

ExportUtils.stopExport(exportId);

Others

Generate HDR Images

If you have a WorkWrapper with HDR images, you can generate them into an image file using HDR stitching.

Note: This is a time-consuming operation that needs to be handled in a child thread.

booleanisSuccessful = StitchUtils.generateHDR(WorkWrapperworkWrapper, StringhdrOutputPath);

After the successful call of generateHDR, outputPath can be played as a proxy or set as an export URL.

// Set as playback agentImageParamsBuilderbuilder = newImageParamsBuilder()
// If HDR splicing is successful, set it as a playback proxy
.setUrlForPlay(isSuccessful ? hdrOutputPath : null);
mImagePlayerView.prepare(workWrapper, builder);
mImagePlayerView.play();
// Set as export urlExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
.setExportMode(ExportUtils.ExportMode.PANORAMA)
.setTargetPath(exportPath)
// If HDR splicing is successful, set it as export url
.setUrlForExport(hdrOutputPath);

Generate PureShot images

If you have a WorkWrapper of a PureShot image, you can generate it into an image file by stitching it together with PureShot.

Note: This is a time-consuming operation that needs to be handled in a child thread.

booleanisSuccessful = StitchUtils.generatePureShot(WorkWrapperworkWrapper, StringpureshotOutputPath, StringalgoFolderPath);

Note: Generating PureShot images requires algorithm model files. Please request the algorithm model files corresponding to your SDK version from our technical support team.

algoFolderPath is the directory for algorithm model files, which can be either LocalStoragePath or AssetsRelativePath. The SDK will load these files as needed.

After the successful call to generatePureShot, outputPath can be played as a proxy or set as an export URL.

// Set as playback agentImageParamsBuilderbuilder = newImageParamsBuilder()
// If PureShot splicing is successful, set it as a playback proxy
.setUrlForPlay(isSuccessful ? pureshotOutputPath : null);
mImagePlayerView.prepare(workWrapper, builder);
mImagePlayerView.play();
// Set as export urlExportImageParamsBuilderbuilder = newExportImageParamsBuilder()
.setExportMode(ExportUtils.ExportMode.PANORAMA)
.setTargetPath(exportPath)
// If PureShot splicing is successful, set it as the export url
.setUrlForExport(pureshotOutputPath);

Algorithm File

Certain functions require algorithm files. These files can be found in the assets folder within the demo directory. Ensure the file paths match those in the demo.

Below is a table mapping function of their corresponding required algorithms:

FunctionModel FilePath Description
Defringedefringe_lr_dynamic_e28c1212.ins defringe_hr_dynamic_7b56e80f.insDFixed path: file:///android_assets/insta360/model/
Color Pluslut_7a79b17a_32.insFixed path: file:///android_assets/insta360/model/
PureShot GenerationPmdenoise_raw_plus.insraw_denoising_abeda57d.ins283fish.ilp283wide.ilp577.ilp586.ilpX3.ilpDeveloper custom path:Passed in by the StitchUtils.generatePureShot function

Error Code

Picture/Video Export Error Code

Error codeExplanation
-31000Exporting in progress
-31010Stop exporting
-31011Failed to load stabilization data
-31012EXPORT_TERMINATED_BY_WORK_REFERENCE_RELEASABLE
-31016EXPORT_POST_EXECUTE_FAILED
-31017Original thumbnail LRV not found
-31018Original thumbnail LRV loading failed
-31019EXPORT_VIDEO_TO_IMAGE_SEQUENCE_CANCEL
-13016Export timeout
-13017Cancel export
-13018SHADOW_EXPORT_INIT_SHADOW_CLONE_FAIL
-13019SHADOW_EXPORT_PREPARE_EXPORT_INFO_FAIL
-13021Failed to enable hardware encoding
-13022SHADOW_EXPORT_FAIL_TARGET_TIME_NULL
-13023SHADOW_EXPORT_PREPRARE_FRAME_EXPORTER_FAIL
-13024SHADOW_EXPORT_INPUT_TARGET_FAIL
-13025STOP_MOTION_SELECT_POSE_CLIP_NULL
-13026STOP_MOTION_SELECT_CLIP_NOT_MATCH
-13027STOP_MOTION_SELECT_LOAD_STABILIZER_FAIL
-13028STOP_MOTION_SELECT_KEY_NULL
-13029SHADOW_EXPORT_TRACK_TARGET_EMPTY
-13031Frame exporter preparation failed
-13033Reverse video parsing failed
-13034Dual stream frame format is different
-13035Thumbnail Stabilization Error
-13036Video frame rate equals 0
-13038Video width equals zero
-13039Video height equals zero
-13040The denoise model equals null.
-13041Video source frame rate equals 0
-13042Video source duration equals 0
-13043Image Denoise File Transfer Error
-13034Dual stream frame format is different
-13044Failed to load AAA parameters
-13045Failed to create denoise data
-13046Image width equals 0
-13047Image height equals 0

FAQ

Q1: What should I do if I cannot access the Internet when connecting to the camera?

This typically refers to establishing a connection with the camera via Wi-Fi. The app communicates with the camera through two methods: socket and HTTP. Below are the corresponding functions for each communication method:

  • Socket:Preview stream, read camera parameters, set camera parameters, read capture parameters, set capture parameters, etc. // TODO Supported features to be completed
  • Http Initialize the supported list, download camera files. // TODO Supported features to be completed

The root cause of this issue stems from calling ConnectivityManager#bindProcessToNetwork(network) when establishing a socket connection with the camera, which binds the current process to the camera's Wi-Fi network.

Therefore, after establishing a Wi-Fi connection, calling ConnectivityManager#bindProcessToNetwork(4GNetwork) to bind to an available network (such as 4G) resolves the inability to access the internet. Since the socket connection is already established, unbinding still allows continued use of socket-enabled features.

However, this approach introduces a problem. Because the current process is no longer bound to the camera's Wi-Fi, using features dependent on HTTP communication will result in the following error:

image

There are two solutions to this problem:

  1. When using features related to HTTP communication, call the bindProcessToNetwork(camera) method to bind to the camera's Wi-Fi. Upon completing the relevant functionality, call bindProcessToNetwork(4g) to switch back to the available 4G network.
    1. Pros: Simple implementation
    2. Cons: Will temporarily disconnect from the Internet.
  2. Launch a new process named download. Call the bindProcessToNetwork(camera) method to bind the download process to the camera's Wi-Fi network. All HTTP communication-related functions are executed within the download process.
    1. Pros: Perfectly solves the problem of being unable to access the Internet.
    2. Cons: Complex implementation

Q2: What is the data format in the VideoData object?

H.264 format, containing both PPS and SPS frame data.

Q3:How to resolve C++_shared conflicts?

Upgrade to version 1.8.1_build_05 or later

Q4:How to handle the issue regarding OK Go?

implementation("com.github.jeasonlzy.okhttp-OkGo:okgo:v3.0.4")

implementation("com.arashivision.sdk:sdkcamera:1.8.0_build_11"){

exclude("com.github.jeasonlzy","okhttp-OkGo")

}

Q5:Connection error -2110203 issue?

Socket read failure typically occurs when Wi-Fi is disabled by the system. Manually reconnecting to Wi-Fi via the system settings page can reduce the likelihood of automatic disconnection by the system.

Q6:Regarding the issue of some Huawei phones displaying a black screen during playback?

The photo width is 16386 pixels, exceeding the 8192-pixel rendering limit on some Huawei phones.

Q7: What should I do if my Google Play Store submission is rejected after integrating the SDK because the .so file is not aligned to 16K?

Download version 1.8.2-build4 from the Maven repository.

Then, exclude the following libraries from your package (this won't affect SDK functionality), and then submit to the Google Play Store:

libSnpeHtpV68Skel.so (AI acceleration-related auxiliary components)

libSnpeHtpV69Skel.so (AI acceleration-related auxiliary components)

libSnpeHtpV73Skel.so (AI acceleration-related auxiliary components)

iibSnpeHtpV75Skel.so (AI acceleration-related auxiliary components)

libSnpeHtpV7.9Skel.so (AI acceleration-related auxiliary components)

libcalculator_skel.so (AI acceleration-related auxiliary components)

x86_64/libmobvoidsp.so (X86 library; selecting X64 in the package will prevent it from being included)

About

Android SDK enables integration of Insta360 360 cameras into Android apps for control and media management.

Resources

Stars

114 stars

Watchers

10 watching

Forks

Releases

Packages

Contributors